diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2016-05-30 19:18:13 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2016-05-30 19:18:13 +0000 |
commit | b2f6675b74a6d16ab44202ac0e49587da8f7d4cf (patch) | |
tree | dbbf824a1e3f3eb03d521c288eda3737fe08defe /gcc/cp | |
parent | 9ce542ba4a138f762697778f339da66beeb13991 (diff) | |
download | gcc-b2f6675b74a6d16ab44202ac0e49587da8f7d4cf.zip gcc-b2f6675b74a6d16ab44202ac0e49587da8f7d4cf.tar.gz gcc-b2f6675b74a6d16ab44202ac0e49587da8f7d4cf.tar.bz2 |
re PR c++/71238 (Undeclared function message imprecisely points to error column)
/cp
2016-05-30 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/71238
* lex.c (unqualified_name_lookup_error): Take a location too.
(unqualified_fn_lookup_error): Take a cp_expr.
* cp-tree.h (unqualified_name_lookup_error,
unqualified_fn_lookup_error): Adjust declarations.
* semantics.c (perform_koenig_lookup): Adjust
unqualified_fn_lookup_error call, pass the location of
the identifier too as part of a cp_expr.
/testsuite
2016-05-30 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/71238
* g++.dg/parse/pr71238.C: New.
* g++.dg/concepts/friend1.C: Test column numbers too.
* g++.dg/cpp0x/initlist31.C: Likewise.
* g++.dg/cpp0x/pr51420.C: Likewise.
* g++.dg/cpp0x/udlit-declare-neg.C: Likewise.
* g++.dg/cpp0x/udlit-member-neg.C: Likewise.
* g++.dg/ext/builtin3.C: Likewise.
* g++.dg/lookup/friend12.C: Likewise.
* g++.dg/lookup/friend7.C: Likewise.
* g++.dg/lookup/koenig1.C: Likewise.
* g++.dg/lookup/koenig5.C: Likewise.
* g++.dg/lookup/used-before-declaration.C: Likewise.
* g++.dg/overload/koenig1.C: Likewise.
* g++.dg/template/crash65.C: Likewise.
* g++.dg/template/friend57.C: Likewise.
* g++.dg/warn/Wshadow-5.C: Likewise.
* g++.dg/warn/Wunused-8.C: Likewise.
* g++.old-deja/g++.bugs/900211_01.C: Likewise.
* g++.old-deja/g++.jason/lineno5.C: Likewise.
* g++.old-deja/g++.jason/member.C: Likewise.
* g++.old-deja/g++.jason/report.C: Likewise.
* g++.old-deja/g++.jason/scoping12.C: Likewise.
* g++.old-deja/g++.law/visibility20.C: Likewise.
* g++.old-deja/g++.ns/koenig5.C: Likewise.
* g++.old-deja/g++.other/static5.C: Likewise.
* g++.old-deja/g++.pt/overload2.C: Likewise.
From-SVN: r236896
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 5 | ||||
-rw-r--r-- | gcc/cp/lex.c | 33 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 3 |
4 files changed, 36 insertions, 16 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9b35abc..84d7e0a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,16 @@ 2016-05-30 Paolo Carlini <paolo.carlini@oracle.com> + PR c++/71238 + * lex.c (unqualified_name_lookup_error): Take a location too. + (unqualified_fn_lookup_error): Take a cp_expr. + * cp-tree.h (unqualified_name_lookup_error, + unqualified_fn_lookup_error): Adjust declarations. + * semantics.c (perform_koenig_lookup): Adjust + unqualified_fn_lookup_error call, pass the location of + the identifier too as part of a cp_expr. + +2016-05-30 Paolo Carlini <paolo.carlini@oracle.com> + PR c++/71099 * parser.c (cp_parser_function_specifier_opt): Use current_class_type to improve the diagnostic about wrong uses of 'virtual'. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index f562a52..14ba120 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -5974,8 +5974,9 @@ extern tree build_vtbl_address (tree); extern void cxx_dup_lang_specific_decl (tree); extern void yyungetc (int, int); -extern tree unqualified_name_lookup_error (tree); -extern tree unqualified_fn_lookup_error (tree); +extern tree unqualified_name_lookup_error (tree, + location_t = UNKNOWN_LOCATION); +extern tree unqualified_fn_lookup_error (cp_expr); extern tree build_lang_decl (enum tree_code, tree, tree); extern tree build_lang_decl_loc (location_t, enum tree_code, tree, tree); extern void retrofit_lang_decl (tree); diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c index e69793e..43827e5 100644 --- a/gcc/cp/lex.c +++ b/gcc/cp/lex.c @@ -443,27 +443,29 @@ handle_pragma_java_exceptions (cpp_reader* /*dfile*/) IDENTIFIER_NODE) failed. Returns the ERROR_MARK_NODE. */ tree -unqualified_name_lookup_error (tree name) +unqualified_name_lookup_error (tree name, location_t loc) { + if (loc == UNKNOWN_LOCATION) + loc = EXPR_LOC_OR_LOC (name, input_location); + if (IDENTIFIER_OPNAME_P (name)) { if (name != ansi_opname (ERROR_MARK)) - error ("%qD not defined", name); + error_at (loc, "%qD not defined", name); } else { if (!objc_diagnose_private_ivar (name)) { - error ("%qD was not declared in this scope", name); - suggest_alternatives_for (location_of (name), name); + error_at (loc, "%qD was not declared in this scope", name); + suggest_alternatives_for (loc, name); } /* Prevent repeated error messages by creating a VAR_DECL with this NAME in the innermost block scope. */ if (local_bindings_p ()) { tree decl; - decl = build_decl (input_location, - VAR_DECL, name, error_mark_node); + decl = build_decl (loc, VAR_DECL, name, error_mark_node); DECL_CONTEXT (decl) = current_function_decl; push_local_binding (name, decl, 0); /* Mark the variable as used so that we do not get warnings @@ -475,13 +477,18 @@ unqualified_name_lookup_error (tree name) return error_mark_node; } -/* Like unqualified_name_lookup_error, but NAME is an unqualified-id - used as a function. Returns an appropriate expression for - NAME. */ +/* Like unqualified_name_lookup_error, but NAME_EXPR is an unqualified-id + NAME, encapsulated with its location in a CP_EXPR, used as a function. + Returns an appropriate expression for NAME. */ tree -unqualified_fn_lookup_error (tree name) +unqualified_fn_lookup_error (cp_expr name_expr) { + tree name = name_expr.get_value (); + location_t loc = name_expr.get_location (); + if (loc == UNKNOWN_LOCATION) + loc = input_location; + if (processing_template_decl) { /* In a template, it is invalid to write "f()" or "f(3)" if no @@ -494,7 +501,7 @@ unqualified_fn_lookup_error (tree name) Note that we have the exact wording of the following message in the manual (trouble.texi, node "Name lookup"), so they need to be kept in synch. */ - permerror (input_location, "there are no arguments to %qD that depend on a template " + permerror (loc, "there are no arguments to %qD that depend on a template " "parameter, so a declaration of %qD must be available", name, name); @@ -503,7 +510,7 @@ unqualified_fn_lookup_error (tree name) static bool hint; if (!hint) { - inform (input_location, "(if you use %<-fpermissive%>, G++ will accept your " + inform (loc, "(if you use %<-fpermissive%>, G++ will accept your " "code, but allowing the use of an undeclared name is " "deprecated)"); hint = true; @@ -512,7 +519,7 @@ unqualified_fn_lookup_error (tree name) return name; } - return unqualified_name_lookup_error (name); + return unqualified_name_lookup_error (name, loc); } /* Wrapper around build_lang_decl_loc(). Should gradually move to diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 253d31a..8e682c5 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2210,6 +2210,7 @@ perform_koenig_lookup (cp_expr fn, vec<tree, va_gc> *args, tree functions = NULL_TREE; tree tmpl_args = NULL_TREE; bool template_id = false; + location_t loc = fn.get_location (); if (TREE_CODE (fn) == TEMPLATE_ID_EXPR) { @@ -2245,7 +2246,7 @@ perform_koenig_lookup (cp_expr fn, vec<tree, va_gc> *args, { /* The unqualified name could not be resolved. */ if (complain) - fn = unqualified_fn_lookup_error (identifier); + fn = unqualified_fn_lookup_error (cp_expr (identifier, loc)); else fn = identifier; } |