OK.
On Tue, Jan 31, 2017 at 3:10 PM, David Malcolm <dmalc...@redhat.com> wrote: > PR c++/79298 reports a segfault when handling a qualified name lookup error, > where consider_binding_level dereferences a NULL cp_binding_level *. > > The root cause is that suggest_alternative_in_explicit_scope assumes that > NAMESPACE_LEVEL (scope) is non-NULL, but this can be NULL for namespace > aliases. > > This patch adds a use of ORIGINAL_NAMESPACE to look through any namespace > aliases. > > Successfully bootstrapped®rtested on x86_64-pc-linux-gnu. > > OK for trunk? > > 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. > --- > gcc/cp/name-lookup.c | 3 +++ > gcc/testsuite/g++.dg/spellcheck-pr79298.C | 17 +++++++++++++++++ > 2 files changed, 20 insertions(+) > create mode 100644 gcc/testsuite/g++.dg/spellcheck-pr79298.C > > diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c > index a3cb7ee..994f7f0 100644 > --- a/gcc/cp/name-lookup.c > +++ b/gcc/cp/name-lookup.c > @@ -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); > diff --git a/gcc/testsuite/g++.dg/spellcheck-pr79298.C > b/gcc/testsuite/g++.dg/spellcheck-pr79298.C > new file mode 100644 > index 0000000..4d7bbf9 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/spellcheck-pr79298.C > @@ -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 } > +} > -- > 1.8.5.3 >