Fix ICE with spelling hints within explicit namespace aliases (PR c++/79298)
authorDavid Malcolm <dmalcolm@redhat.com>
Tue, 31 Jan 2017 21:30:42 +0000 (21:30 +0000)
committerDavid Malcolm <dmalcolm@gcc.gnu.org>
Tue, 31 Jan 2017 21:30:42 +0000 (21:30 +0000)
gcc/cp/ChangeLog:
PR c++/79298
* name-lookup.c (suggest_alternative_in_explicit_scope): Resolve
any namespace aliases.

gcc/testsuite/ChangeLog:
PR c++/79298
* g++.dg/spellcheck-pr79298.C: New test case.

From-SVN: r245072

gcc/cp/ChangeLog
gcc/cp/name-lookup.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/spellcheck-pr79298.C [new file with mode: 0644]

index 2a8660796e186ced1b937524f7514e7022bc76a1..04d2a6017e810a5d7c256a4d5560291e774fdc8d 100644 (file)
@@ -1,3 +1,9 @@
+2017-01-31  David Malcolm  <dmalcolm@redhat.com>
+
+       PR c++/79298
+       * name-lookup.c (suggest_alternative_in_explicit_scope): Resolve
+       any namespace aliases.
+
 2017-01-31  Nathan Sidwell  <nathan@acm.org>
 
        PR c++/79290
index a3cb7eea9072d68863b93c8c502571b29c5cbe8c..994f7f0c5c36eb6e89fcb76bc920c8e45fbbc52e 100644 (file)
@@ -4545,6 +4545,9 @@ bool
 suggest_alternative_in_explicit_scope (location_t location, tree name,
                                       tree scope)
 {
+  /* Resolve any namespace aliases.  */
+  scope = ORIGINAL_NAMESPACE (scope);
+
   cp_binding_level *level = NAMESPACE_LEVEL (scope);
 
   best_match <tree, tree> bm (name);
index f7cf0f489a2e0cab16ebb3b7765ea292494066ea..ef50edab562224e5e153dbd46fc07a7c97a50576 100644 (file)
@@ -1,3 +1,8 @@
+2017-01-31  David Malcolm  <dmalcolm@redhat.com>
+
+       PR c++/79298
+       * g++.dg/spellcheck-pr79298.C: New test case.
+
 2017-01-31  David Malcolm  <dmalcolm@redhat.com>
 
        PR preprocessor/79210
diff --git a/gcc/testsuite/g++.dg/spellcheck-pr79298.C b/gcc/testsuite/g++.dg/spellcheck-pr79298.C
new file mode 100644 (file)
index 0000000..4d7bbf9
--- /dev/null
@@ -0,0 +1,17 @@
+// Ensure that we can offer suggestions for misspellings via a
+// namespace alias.
+
+namespace N { int x; int color; }
+namespace M = N; 
+namespace O = M; 
+
+int foo () 
+{
+  return M::y; // { dg-error ".y. is not a member of .M." }
+}
+
+int bar () 
+{
+  return O::colour; // { dg-error ".colour. is not a member of .O." }
+  // { dg-message "suggested alternative: .color." "" { target *-*-* } .-1 }
+}