diff options
author | Nathan Froyd <froydnj@codesourcery.com> | 2010-12-14 20:31:22 +0000 |
---|---|---|
committer | Nathan Froyd <froydnj@gcc.gnu.org> | 2010-12-14 20:31:22 +0000 |
commit | 993acb366ebf8a43f66669950b385710eba931cb (patch) | |
tree | a3f1edf7efd982b0735aec9f5727133cb89fece1 /gcc/cp/error.c | |
parent | ec047df48239928a1776c10e7e5f11c76c6974a5 (diff) | |
download | gcc-993acb366ebf8a43f66669950b385710eba931cb.zip gcc-993acb366ebf8a43f66669950b385710eba931cb.tar.gz gcc-993acb366ebf8a43f66669950b385710eba931cb.tar.bz2 |
re PR c++/45330 (Suggest likely nested-name-specifiers for undeclared identifiers.)
gcc/cp/
PR c++/45330
* cp-tree.h (suggest_alternatives_for): Add location_t parameter.
* name-lookup.c (suggest_alternatives_for): Likewise. Adjust.
* lex.c (unqualified_name_lookup_error): Adjust call to it.
* semantics.c (qualified_name_lookup_error): Move to...
* error.c (qualified_name_lookup_error): ...here. Call.
suggest_alternatives_for.
gcc/testsuite/
PR c++/45330
* g++.dg/lookup/suggestions1.C: New test.
From-SVN: r167814
Diffstat (limited to 'gcc/cp/error.c')
-rw-r--r-- | gcc/cp/error.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/gcc/cp/error.c b/gcc/cp/error.c index e1bac24..3e91115 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -3167,3 +3167,39 @@ pedwarn_cxx98 (location_t location, int opt, const char *gmsgid, ...) va_end (ap); return report_diagnostic (&diagnostic); } + +/* Issue a diagnostic that NAME cannot be found in SCOPE. DECL is what + we found when we tried to do the lookup. LOCATION is the location of + the NAME identifier. */ + +void +qualified_name_lookup_error (tree scope, tree name, + tree decl, location_t location) +{ + if (scope == error_mark_node) + ; /* We already complained. */ + else if (TYPE_P (scope)) + { + if (!COMPLETE_TYPE_P (scope)) + error_at (location, "incomplete type %qT used in nested name specifier", + scope); + else if (TREE_CODE (decl) == TREE_LIST) + { + error_at (location, "reference to %<%T::%D%> is ambiguous", + scope, name); + print_candidates (decl); + } + else + error_at (location, "%qD is not a member of %qT", name, scope); + } + else if (scope != global_namespace) + { + error_at (location, "%qD is not a member of %qD", name, scope); + suggest_alternatives_for (location, name); + } + else + { + error_at (location, "%<::%D%> has not been declared", name); + suggest_alternatives_for (location, name); + } +} |