From 2a13a6258b1d75537b08a0286bd7719ae0a9ae1f Mon Sep 17 00:00:00 2001 From: Gabriel Dos Reis Date: Tue, 5 Oct 2004 13:28:07 +0000 Subject: [PATCH] Convert diagnostics to use quoting flag q 4/n Convert diagnostics to use quoting flag q 4/n * parser.c (cp_parser_name_lookup_error, cp_parser_diagnose_invalid_type_name, cp_parser_primary_expression, cp_parser_unqualified_id, cp_parser_nested_name_specifier_opt, cp_parser_labeled_statement, cp_parser_jump_statement, cp_parser_simple_declaration, cp_parser_decl_specifier_seq, cp_parser_mem_initializer_id, cp_parser_type_parameter, cp_parser_template_id, cp_parser_template_name, cp_parser_direct_declarator, cp_parser_parameter_declaration_list, cp_parser_class_head, cp_parser_base_specifier, cp_parser_lookup_name, cp_parser_late_parsing_default_args, cp_parser_optional_template_keyword cp_parser_elaborated_type_specifier, cp_parser_check_class_key, cp_parser_check_access_in_redeclaration): Use quoting marks. * name-lookup.c (supplement_binding, pushdecl, check_for_out_of_scope_variable, validate_nonmember_using_decl, do_nonmember_using_decl, lookup_tag, set_decl_namespace, push_namespace, do_namespace_alias, do_using_directive, ambiguous_decl, lookup_namespace_name, add_function): Likewise. * method.c (use_thunk): Likewise. * lex.c (unqualified_name_lookup_error, unqualified_fn_lookup_error): Likewise. testsuite/ merlin[1:17]% cd build ~ merlin[1:17]% ls ~/build 3 4 4.0.0 c++0x r tree merlin[1:17]% cd 4.0.0 ~/build merlin[1:17]% cd gcc ~/build/4.0.0 merlin[1:17]% make check-g++ ~/build/4.0.0/gcc (rootme=`${PWDCMD-pwd}`; export rootme; \ srcdir=`cd /home/gdr/redhat/egcs/gcc; ${PWDCMD-pwd}` ; export srcdir ; \ cd testsuite; \ EXPECT=`if [ -f ${rootme}/../expect/expect ] ; then echo ${rootme}/../expect/expect ; else echo expect ; fi` ; export EXPECT ; \ if [ -f ${rootme}/../expect/expect ] ; then \ TCL_LIBRARY=`cd .. ; cd /home/gdr/redhat/egcs/gcc/../tcl/library ; ${PWDCMD-pwd}` ; \ export TCL_LIBRARY ; fi ; \ `if [ -f ${srcdir}/../dejagnu/runtest ] ; then echo ${srcdir}/../dejagnu/runtest ; else echo runtest; fi` --tool g++ ) Test Run By gdr on Tue Oct 5 01:18:04 2004 Native configuration is i686-pc-linux-gnu === g++ tests === Schedule of variations: unix Running target unix Using /usr/share/dejagnu/baseboards/unix.exp as board description file for target. Using /usr/share/dejagnu/config/unix.exp as generic interface file for target. Using /home/gdr/redhat/egcs/gcc/testsuite/config/default.exp as tool-and-target-specific interface file. Running /home/gdr/redhat/egcs/gcc/testsuite/g++.dg/bprob/bprob.exp ... Running /home/gdr/redhat/egcs/gcc/testsuite/g++.dg/charset/charset.exp ...Running /home/gdr/redhat/egcs/gcc/testsuite/g++.dg/compat/compat.exp ...Running /home/gdr/redhat/egcs/gcc/testsuite/g++.dg/debug/debug.exp ... Running /home/gdr/redhat/egcs/gcc/testsuite/g++.dg/dg.exp ... FAIL: g++.dg/other/classkey1.C (test for errors, line 9) FAIL: g++.dg/other/classkey1.C (test for errors, line 11) FAIL: g++.dg/other/classkey1.C (test for errors, line 14) FAIL: g++.dg/other/classkey1.C (test for errors, line 17) FAIL: g++.dg/other/classkey1.C (test for excess errors) FAIL: g++.dg/parse/error15.C (test for errors, line 13) FAIL: g++.dg/parse/error15.C (test for errors, line 14) FAIL: g++.dg/parse/error15.C (test for errors, line 15) FAIL: g++.dg/parse/error15.C (test for errors, line 21) FAIL: g++.dg/parse/error15.C (test for errors, line 22) FAIL: g++.dg/parse/error15.C (test for errors, line 23) FAIL: g++.dg/parse/error15.C (test for errors, line 31) FAIL: g++.dg/parse/error15.C (test for errors, line 32) FAIL: g++.dg/parse/error15.C (test for errors, line 33) FAIL: g++.dg/parse/error15.C (test for excess errors) XPASS: g++.dg/rtti/tinfo1.C scan-assembler _ZTIP9CTemplateIhE: XPASS: g++.dg/rtti/tinfo1.C scan-assembler-not .globl[ \t]+_ZTIP9CTemplateIhE XPASS: g++.dg/rtti/tinfo1.C scan-assembler-not .section[^\n\r]*_ZTIP9CTemplateIhE[^\n\r]*FAIL: g++.dg/template/meminit2.C (test for errors, line 10) FAIL: g++.dg/template/meminit2.C (test for errors, line 11) FAIL: g++.dg/template/meminit2.C (test for excess errors) Running /home/gdr/redhat/egcs/gcc/testsuite/g++.dg/gcov/gcov.exp ... FAIL: 102:is -:should be 1 FAIL: g++.dg/gcov/gcov-1.C gcov: 1 failures in line counts, 0 in branch percentamerlin[1:27]% make check-g++ ~/build/4.0.0/gcc (rootme=`${PWDCMD-pwd}`; export rootme; \ srcdir=`cd /home/gdr/redhat/egcs/gcc; ${PWDCMD-pwd}` ; export srcdir ; \ cd testsuite; \ EXPECT=`if [ -f ${rootme}/../expect/expect ] ; then echo ${rootme}/../expect/expect ; else echo expect ; fi` ; export EXPECT ; \ if [ -f ${rootme}/../expect/expect ] ; then \ TCL_LIBRARY=`cd .. ; cd /home/gdr/redhat/egcs/gcc/../tcl/library ; ${PWDCMD-pwd}` ; \ export TCL_LIBRARY ; fi ; \ `if [ -f ${srcdir}/../dejagnu/runtest ] ; then echo ${srcdir}/../dejagnu/runtest ; else echo runtest; fi` --tool g++ ) Test Run By gdr on Tue Oct 5 01:27:39 2004 Native configuration is i686-pc-linux-gnu === g++ tests === Schedule of variations: unix Running target unix Using /usr/share/dejagnu/baseboards/unix.exp as board description file for target. Using /usr/share/dejagnu/config/unix.exp as generic interface file for tar method.c cfns.gperf cxx-pretty-print.c method.c.~1.315.~ cfns.h cxx-pretty-print.h name-lookup.c ChangeLog decl2.c name-lookup.c.~1.85.~ ChangeLog.1 decl.c name-lookup.h ChangeLog.~1.4404.~ decl.h NEWS ChangeLog.2 dump.c operators.def ChangeLog.3 error.c optimize.c ChangeLog.egcs except.c parser.c ChangeLog.tree-ssa expr.c parser.c.~1.258.~ class.c friend.c pt.c config-lang.in g++spec.c ptree.c cp-gimplify.c init.c repo.c cp-lang.c init.c.~1.396.~ rtti.c cp-objcp-common.c lang-specs.h search.c cp-objcp-common.h lex.c semantics.c cp-tree.def lex.c.~1.349.~ tree.c cp-tree.h Make-lang.in typeck2.c CVS mangle.c typeck.c merlin[7:37]% cvs -z9 diff -p > ~/d-5.patch ~/redhat/egcs/gcc/cp Enter passphrase for RSA key '/home/gdr/.ssh/identity': cvs [diff aborted]: received interrupt signal merlin[7:37]% cvs -z9 diff -p > ~/d-5.patch ~/redhat/egcs/gcc/cp Warning: Remote host denied X11 forwarding. Warning: Remote host denied authentication agent forwarding. cvs diff: Diffing . merlin[7:38]% l ~/d-5.patch ~/redhat/egcs/gcc/cp merlin[7:39]% cvs -z9 diff -p > ~/d-5.patch ~/redhat/egcs/gcc/cp Warning: Remote host denied X11 forwarding. Warning: Remote host denied authentication agent forwarding. cvs diff: Diffing . merlin[7:40]% l ~/d-5.patch ~/redhat/egcs/gcc/cp You have new mail. merlin[8:21]% cvs -z9 commit ~/redhat/egcs/gcc/cp merlin[8:21]% cd . ~/redhat/egcs/gcc/cp merlin[8:21]% cvs -z9 commit cp testsuite ~/redhat/egcs/gcc/cp cvs commit: nothing known about `cp' cvs commit: nothing known about `testsuite' cvs [commit aborted]: correct above errors first! merlin[8:21]% cd .. ~/redhat/egcs/gcc/cp merlin[8:21]% cvs -z9 commit cp testsuite ~/redhat/egcs/gcc cvs commit: Examining cp cvs commit: Examining testsuite cvs commit: Examining testsuite/ada cvs commit: Examining testsuite/ada/acats cvs commit: Examining testsuite/ada/acats/support cvs commit: Examining testsuite/ada/acats/tests cvs commit: Examining testsuite/ada/acats/tests/a cvs commit: Examining testsuite/ada/acats/tests/c2 cvs commit: Examining testsuite/ada/acats/tests/c3 cvs commit: Examining testsuite/ada/acats/tests/c4 cvs commit: Examining testsuite/ada/acats/tests/c5 cvs commit: Examining testsuite/ada/acats/tests/c6 cvs commit: Examining testsuite/ada/acats/tests/c7 cvs commit: Examining testsuite/ada/acats/tests/c8 cvs commit: Examining testsuite/ada/acats/tests/c9 cvs commit: Examining testsuite/ada/acats/tests/ca cvs commit: Examining testsuite/ada/acats/tests/cb cvs commit: Examining testsuite/ada/acats/tests/cc cvs commit: Examining testsuite/ada/acats/tests/cd cvs commit: Examining testsuite/ada/acats/tests/ce cvs commit: Examining testsuite/ada/acats/tests/cxa cvs commit: Examining testsuite/ada/acats/tests/cxb cvs commit: Examining testsuite/ada/acats/tests/cxf cvs commit: Examining testsuite/ada/acats/tests/cxg cvs commit: Examining testsuite/ada/acats/tests/cxh cvs commit: Examining testsuite/ada/acats/tests/cz cvs commit: Examining testsuite/ada/acats/tests/d cvs commit: Examining testsuite/ada/acats/tests/e cvs commit: Examining testsuite/ada/acats/tests/gcc cvs commit: Examining testsuite/ada/acats/tests/l cvs commit: Examining testsuite/config cvs commit: Examining testsuite/consistency.vlad cvs commit: Examining testsuite/consistency.vlad/layout cvs commit: Examining testsuite/consistency.vlad/layout/i960-97r2-results cvs commit: Examining testsuite/g++.dg cvs commit: Examining testsuite/g++.dg/abi cvs commit: Examining testsuite/g++.dg/bprob cvs commit: Examining testsuite/g++.dg/charset cvs commit: Examining testsuite/g++.dg/compat cvs commit: Examining testsuite/g++.dg/compat/abi cvs commit: Examinin From-SVN: r88552 --- gcc/cp/ChangeLog | 29 ++++++ gcc/cp/lex.c | 8 +- gcc/cp/method.c | 8 +- gcc/cp/name-lookup.c | 118 +++++++++++------------ gcc/cp/parser.c | 113 +++++++++++----------- gcc/testsuite/ChangeLog | 6 ++ gcc/testsuite/g++.dg/other/classkey1.C | 8 +- gcc/testsuite/g++.dg/parse/error15.C | 18 ++-- gcc/testsuite/g++.dg/template/meminit2.C | 4 +- 9 files changed, 174 insertions(+), 138 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 449ee3c7726..dc21cf718a4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,32 @@ +2004-10-04 Gabriel Dos Reis + + Convert diagnostics to use quoting flag q 4/n + * parser.c (cp_parser_name_lookup_error, + cp_parser_diagnose_invalid_type_name, + cp_parser_primary_expression, cp_parser_unqualified_id, + cp_parser_nested_name_specifier_opt, cp_parser_labeled_statement, + cp_parser_jump_statement, cp_parser_simple_declaration, + cp_parser_decl_specifier_seq, cp_parser_mem_initializer_id, + cp_parser_type_parameter, cp_parser_template_id, + cp_parser_template_name, cp_parser_direct_declarator, + cp_parser_parameter_declaration_list, cp_parser_class_head, + cp_parser_base_specifier, cp_parser_lookup_name, + cp_parser_late_parsing_default_args, + cp_parser_optional_template_keyword + cp_parser_elaborated_type_specifier, cp_parser_check_class_key, + cp_parser_check_access_in_redeclaration): Use quoting marks. + + * name-lookup.c (supplement_binding, pushdecl, + check_for_out_of_scope_variable, validate_nonmember_using_decl, + do_nonmember_using_decl, lookup_tag, set_decl_namespace, + push_namespace, do_namespace_alias, do_using_directive, + ambiguous_decl, lookup_namespace_name, add_function): Likewise. + + * method.c (use_thunk): Likewise. + + * lex.c (unqualified_name_lookup_error, + unqualified_fn_lookup_error): Likewise. + 2004-10-04 Gabriel Dos Reis Convert diagnostics to use quoting flag q 4/n diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c index 5addca4988b..c0b79685694 100644 --- a/gcc/cp/lex.c +++ b/gcc/cp/lex.c @@ -566,11 +566,11 @@ unqualified_name_lookup_error (tree name) if (IDENTIFIER_OPNAME_P (name)) { if (name != ansi_opname (ERROR_MARK)) - error ("`%D' not defined", name); + error ("%qD not defined", name); } else { - error ("`%D' was not declared in this scope", name); + error ("%qD was not declared in this scope", name); /* Prevent repeated error messages by creating a VAR_DECL with this NAME in the innermost block scope. */ if (current_function_decl) @@ -607,8 +607,8 @@ 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. */ - pedwarn ("there are no arguments to `%D' that depend on a template " - "parameter, so a declaration of `%D' must be available", + pedwarn ("there are no arguments to %qD that depend on a template " + "parameter, so a declaration of %qD must be available", name, name); if (!flag_permissive) diff --git a/gcc/cp/method.c b/gcc/cp/method.c index b28746b6dfc..da7ace71ada 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -440,7 +440,7 @@ use_thunk (tree thunk_fndecl, bool emit_p) doesn't work for varargs. */ if (varargs_function_p (function)) - error ("generic thunk code fails for method `%#D' which uses `...'", + error ("generic thunk code fails for method %q#D which uses %<...%>", function); DECL_RESULT (thunk_fndecl) = NULL_TREE; @@ -649,12 +649,14 @@ do_build_assign_ref (tree fndecl) if (CP_TYPE_CONST_P (TREE_TYPE (field))) { - error ("non-static const member `%#D', can't use default assignment operator", field); + error ("non-static const member %q#D, can't use default " + "assignment operator", field); continue; } else if (TREE_CODE (TREE_TYPE (field)) == REFERENCE_TYPE) { - error ("non-static reference member `%#D', can't use default assignment operator", field); + error ("non-static reference member %q#D, can't use " + "default assignment operator", field); continue; } diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 5ca98a9a8ff..b7e29aa55d3 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -574,8 +574,8 @@ supplement_binding (cxx_binding *binding, tree decl) ok = false; else { - error ("declaration of `%#D'", decl); - cp_error_at ("conflicts with previous declaration `%#D'", bval); + error ("declaration of %q#D", decl); + cp_error_at ("conflicts with previous declaration %q#D", bval); ok = false; } @@ -759,8 +759,8 @@ pushdecl (tree x) else if (t == wchar_decl_node) { if (pedantic && ! DECL_IN_SYSTEM_HEADER (x)) - pedwarn ("redeclaration of `wchar_t' as `%T'", - TREE_TYPE (x)); + pedwarn ("redeclaration of % as %qT", + TREE_TYPE (x)); /* Throw away the redeclaration. */ POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, t); @@ -791,8 +791,8 @@ pushdecl (tree x) [basic.start.main] This function shall not be overloaded. */ - cp_error_at ("invalid redeclaration of `%D'", t); - error ("as `%D'", x); + cp_error_at ("invalid redeclaration of %qD", t); + error ("as %qD", x); /* We don't try to push this declaration since that causes a crash. */ POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, x); @@ -880,8 +880,8 @@ pushdecl (tree x) && TREE_CODE (decl) == TREE_CODE (x) && !same_type_p (TREE_TYPE (x), TREE_TYPE (decl))) { - pedwarn ("type mismatch with previous external decl of `%#D'", x); - cp_pedwarn_at ("previous external decl of `%#D'", decl); + pedwarn ("type mismatch with previous external decl of %q#D", x); + cp_pedwarn_at ("previous external decl of %q#D", decl); } } @@ -963,8 +963,8 @@ pushdecl (tree x) /* OK */; else { - warning ("extern declaration of `%#D' doesn't match", x); - cp_warning_at ("global declaration `%#D'", oldglobal); + warning ("extern declaration of %q#D doesn't match", x); + cp_warning_at ("global declaration %q#D", oldglobal); } } /* If we have a local external declaration, @@ -1000,14 +1000,14 @@ pushdecl (tree x) /* ARM $8.3 */ if (b->kind == sk_function_parms) { - error ("declaration of '%#D' shadows a parameter", x); + error ("declaration of %q#D shadows a parameter", x); err = true; } } if (warn_shadow && !err) { - warning ("declaration of '%#D' shadows a parameter", x); + warning ("declaration of %q#D shadows a parameter", x); warning ("%Jshadowed declaration is here", oldlocal); } } @@ -1032,20 +1032,20 @@ pushdecl (tree x) if (member && !TREE_STATIC (member)) { /* Location of previous decl is not useful in this case. */ - warning ("declaration of '%D' shadows a member of 'this'", + warning ("declaration of %qD shadows a member of 'this'", x); } else if (oldlocal != NULL_TREE && TREE_CODE (oldlocal) == VAR_DECL) { - warning ("declaration of '%D' shadows a previous local", x); + warning ("declaration of %qD shadows a previous local", x); warning ("%Jshadowed declaration is here", oldlocal); } else if (oldglobal != NULL_TREE && TREE_CODE (oldglobal) == VAR_DECL) /* XXX shadow warnings in outer-more namespaces */ { - warning ("declaration of '%D' shadows a global declaration", + warning ("declaration of %qD shadows a global declaration", x); warning ("%Jshadowed declaration is here", oldglobal); } @@ -1161,11 +1161,10 @@ check_for_out_of_scope_variable (tree decl) { if (!DECL_ERROR_REPORTED (decl)) { - warning ("name lookup of `%D' changed", - DECL_NAME (decl)); - cp_warning_at (" matches this `%D' under ISO standard rules", + warning ("name lookup of %qD changed", DECL_NAME (decl)); + cp_warning_at (" matches this %qD under ISO standard rules", shadowed); - cp_warning_at (" matches this `%D' under old rules", decl); + cp_warning_at (" matches this %qD under old rules", decl); DECL_ERROR_REPORTED (decl) = 1; } return shadowed; @@ -1183,16 +1182,17 @@ check_for_out_of_scope_variable (tree decl) if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (decl))) { - error ("name lookup of `%D' changed for new ISO `for' scoping", + error ("name lookup of %qD changed for new ISO % scoping", DECL_NAME (decl)); - cp_error_at (" cannot use obsolete binding at `%D' because it has a destructor", decl); + cp_error_at (" cannot use obsolete binding at %qD because " + "it has a destructor", decl); return error_mark_node; } else { - pedwarn ("name lookup of `%D' changed for new ISO `for' scoping", + pedwarn ("name lookup of %qD changed for new ISO % scoping", DECL_NAME (decl)); - cp_pedwarn_at (" using obsolete binding at `%D'", decl); + cp_pedwarn_at (" using obsolete binding at %qD", decl); } return decl; @@ -2023,8 +2023,8 @@ push_overloaded_decl (tree decl, int flags) && !(flags & PUSH_USING) && compparms (TYPE_ARG_TYPES (TREE_TYPE (fn)), TYPE_ARG_TYPES (TREE_TYPE (decl)))) - error ("`%#D' conflicts with previous using declaration `%#D'", - decl, fn); + error ("%q#D conflicts with previous using declaration %q#D", + decl, fn); if (duplicate_decls (decl, fn) == fn) POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, fn); @@ -2035,8 +2035,8 @@ push_overloaded_decl (tree decl, int flags) old = NULL_TREE; else { - cp_error_at ("previous non-function declaration `%#D'", old); - error ("conflicts with function declaration `%#D'", decl); + cp_error_at ("previous non-function declaration %q#D", old); + error ("conflicts with function declaration %q#D", decl); POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, decl); } } @@ -2114,7 +2114,7 @@ validate_nonmember_using_decl (tree decl, tree scope, tree name) member-declaration. */ if (TYPE_P (scope)) { - error ("`%T' is not a namespace", scope); + error ("%qT is not a namespace", scope); return NULL_TREE; } else if (scope == error_mark_node) @@ -2124,13 +2124,14 @@ validate_nonmember_using_decl (tree decl, tree scope, tree name) { /* 7.3.3/5 A using-declaration shall not name a template-id. */ - error ("a using-declaration cannot specify a template-id. Try `using %D'", name); + error ("a using-declaration cannot specify a template-id. " + "Try %", name); return NULL_TREE; } if (TREE_CODE (decl) == NAMESPACE_DECL) { - error ("namespace `%D' not allowed in using-declaration", decl); + error ("namespace %qD not allowed in using-declaration", decl); return NULL_TREE; } @@ -2138,7 +2139,7 @@ validate_nonmember_using_decl (tree decl, tree scope, tree name) { /* It's a nested name with template parameter dependent scope. This can only be using-declaration for class member. */ - error ("`%T' is not a namespace", TREE_OPERAND (decl, 0)); + error ("%qT is not a namespace", TREE_OPERAND (decl, 0)); return NULL_TREE; } @@ -2166,7 +2167,7 @@ do_nonmember_using_decl (tree scope, tree name, tree oldval, tree oldtype, if (!decls.value && !decls.type) { - error ("`%D' not declared", name); + error ("%qD not declared", name); return; } @@ -2178,7 +2179,7 @@ do_nonmember_using_decl (tree scope, tree name, tree oldval, tree oldtype, if (oldval && !is_overloaded_fn (oldval)) { if (!DECL_IMPLICIT_TYPEDEF_P (oldval)) - error ("`%D' is already declared in this scope", name); + error ("%qD is already declared in this scope", name); oldval = NULL_TREE; } @@ -2220,7 +2221,7 @@ do_nonmember_using_decl (tree scope, tree name, tree oldval, tree oldtype, { /* If the OLD_FN was really declared, the declarations don't match. */ - error ("`%D' is already declared in this scope", name); + error ("%qD is already declared in this scope", name); break; } @@ -2257,14 +2258,14 @@ do_nonmember_using_decl (tree scope, tree name, tree oldval, tree oldtype, { *newval = decls.value; if (oldval && !decls_match (*newval, oldval)) - error ("`%D' is already declared in this scope", name); + error ("%qD is already declared in this scope", name); } *newtype = decls.type; if (oldtype && *newtype && !same_type_p (oldtype, *newtype)) { - error ("using declaration `%D' introduced ambiguous type `%T'", - name, oldtype); + error ("using declaration %qD introduced ambiguous type %qT", + name, oldtype); return; } } @@ -2431,7 +2432,7 @@ lookup_tag (enum tree_code form, tree name, && (form == ENUMERAL_TYPE || TREE_CODE (old) == ENUMERAL_TYPE)) { - error ("`%#D' redeclared as %C", old, form); + error ("%q#D redeclared as %C", old, form); POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, NULL_TREE); } POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, old); @@ -2450,7 +2451,7 @@ lookup_tag (enum tree_code form, tree name, && (form == ENUMERAL_TYPE || code == ENUMERAL_TYPE)) { /* Definition isn't the kind we were looking for. */ - error ("`%#D' redeclared as %C", entry->type, form); + error ("%q#D redeclared as %C", entry->type, form); POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, NULL_TREE); } POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, entry->type); @@ -2818,7 +2819,7 @@ push_class_level_binding (tree name, tree x) tree scope = context_for_name_lookup (x); if (TYPE_P (scope) && same_type_p (scope, current_class_type)) { - error ("`%D' has the same name as the class in which it is " + error ("%qD has the same name as the class in which it is " "declared", x); POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, false); @@ -3039,8 +3040,7 @@ set_decl_namespace (tree decl, tree scope, bool friendp) else return; complain: - error ("`%D' should have been declared inside `%D'", - decl, scope); + error ("%qD should have been declared inside %qD", decl, scope); } /* Return the namespace where the current declaration is declared. */ @@ -3102,8 +3102,8 @@ push_namespace (tree name) need_new = 0; if (DECL_NAMESPACE_ALIAS (d)) { - error ("namespace alias `%D' not allowed here, assuming `%D'", - d, DECL_NAMESPACE_ALIAS (d)); + error ("namespace alias %qD not allowed here, assuming %qD", + d, DECL_NAMESPACE_ALIAS (d)); d = DECL_NAMESPACE_ALIAS (d); } } @@ -3217,7 +3217,7 @@ do_namespace_alias (tree alias, tree namespace) if (TREE_CODE (namespace) != NAMESPACE_DECL) { /* The parser did not find it, so it's not there. */ - error ("unknown namespace `%D'", namespace); + error ("unknown namespace %qD", namespace); return; } @@ -3377,13 +3377,13 @@ do_using_directive (tree namespace) { /* Lookup in lexer did not find a namespace. */ if (!processing_template_decl) - error ("namespace `%T' undeclared", namespace); + error ("namespace %qT undeclared", namespace); return; } if (TREE_CODE (namespace) != NAMESPACE_DECL) { if (!processing_template_decl) - error ("`%T' is not a namespace", namespace); + error ("%qT is not a namespace", namespace); return; } namespace = ORIGINAL_NAMESPACE (namespace); @@ -3428,7 +3428,7 @@ parse_using_directive (tree namespace, tree attribs) DECL_NAMESPACE_ASSOCIATIONS (namespace)); } else - warning ("`%D' attribute directive ignored", name); + warning ("%qD attribute directive ignored", name); } } @@ -3562,11 +3562,10 @@ ambiguous_decl (tree name, struct scope_binding *old, cxx_binding *new, repeat ourselves. */ if (old->value != error_mark_node) { - error ("use of `%D' is ambiguous", name); - cp_error_at (" first declared as `%#D' here", - old->value); + error ("use of %qD is ambiguous", name); + cp_error_at (" first declared as %q#D here", old->value); } - cp_error_at (" also declared as `%#D' here", val); + cp_error_at (" also declared as %q#D here", val); } old->value = error_mark_node; } @@ -3581,7 +3580,7 @@ ambiguous_decl (tree name, struct scope_binding *old, cxx_binding *new, { if (flags & LOOKUP_COMPLAIN) { - error ("`%D' denotes an ambiguous type",name); + error ("%qD denotes an ambiguous type",name); error ("%J first type here", TYPE_MAIN_DECL (old->type)); error ("%J other type here", TYPE_MAIN_DECL (type)); } @@ -3647,7 +3646,7 @@ lookup_namespace_name (tree namespace, tree name) { /* This happens for A::B where B is a template, and there are no template arguments. */ - error ("invalid use of `%D'", name); + error ("invalid use of %qD", name); POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, error_mark_node); } @@ -3687,8 +3686,7 @@ lookup_namespace_name (tree namespace, tree name) TREE_OPERAND (template_id, 1)); else { - error ("`%D::%D' is not a template", - namespace, name); + error ("%<%D::%D%> is not a template", namespace, name); POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, error_mark_node); } } @@ -3704,7 +3702,7 @@ lookup_namespace_name (tree namespace, tree name) POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, val); } - error ("`%D' undeclared in namespace `%D'", name, namespace); + error ("%qD undeclared in namespace %qD", name, namespace); POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, error_mark_node); } @@ -4241,9 +4239,9 @@ add_function (struct arg_lookup *k, tree fn) { fn = f1; f1 = f2; f2 = fn; } - cp_error_at ("`%D' is not a function,", f1); - cp_error_at (" conflict with `%D'", f2); - error (" in call to `%D'", k->name); + cp_error_at ("%qD is not a function,", f1); + cp_error_at (" conflict with %qD", f2); + error (" in call to %qD", k->name); return true; } diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 192855de52a..ed65334852a 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -1872,26 +1872,26 @@ cp_parser_name_lookup_error (cp_parser* parser, if (decl == error_mark_node) { if (parser->scope && parser->scope != global_namespace) - error ("`%D::%D' has not been declared", + error ("%<%D::%D%> has not been declared", parser->scope, name); else if (parser->scope == global_namespace) - error ("`::%D' has not been declared", name); + error ("%<::%D%> has not been declared", name); else if (parser->object_scope && !CLASS_TYPE_P (parser->object_scope)) - error ("request for member `%D' in non-class type `%T'", + error ("request for member %qD in non-class type %qT", name, parser->object_scope); else if (parser->object_scope) - error ("`%T::%D' has not been declared", + error ("%<%T::%D%> has not been declared", parser->object_scope, name); else error ("`%D' has not been declared", name); } else if (parser->scope && parser->scope != global_namespace) - error ("`%D::%D' %s", parser->scope, name, desired); + error ("%<%D::%D%> %s", parser->scope, name, desired); else if (parser->scope == global_namespace) - error ("`::%D' %s", name, desired); + error ("%<::%D%> %s", name, desired); else - error ("`%D' %s", name, desired); + error ("%qD %s", name, desired); } /* If we are parsing tentatively, remember that an error has occurred @@ -1962,9 +1962,9 @@ cp_parser_check_for_invalid_template_id (cp_parser* parser, if (cp_lexer_next_token_is (parser->lexer, CPP_LESS)) { if (TYPE_P (type)) - error ("`%T' is not a template", type); + error ("%qT is not a template", type); else if (TREE_CODE (type) == IDENTIFIER_NODE) - error ("`%E' is not a template", type); + error ("%qE is not a template", type); else error ("invalid template-id"); /* Remember the location of the invalid "<". */ @@ -2031,12 +2031,12 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser, tree scope, tree id) /* If the lookup found a template-name, it means that the user forgot to specify an argument list. Emit an useful error message. */ if (TREE_CODE (decl) == TEMPLATE_DECL) - error ("invalid use of template-name `%E' without an argument list", + error ("invalid use of template-name %qE without an argument list", decl); else if (!parser->scope) { /* Issue an error message. */ - error ("`%E' does not name a type", id); + error ("%qE does not name a type", id); /* If we're in a template class, it's possible that the user was referring to a type from a base class. For example: @@ -2082,11 +2082,10 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser, tree scope, tree id) else { if (TREE_CODE (parser->scope) == NAMESPACE_DECL) - error ("`%E' in namespace `%E' does not name a type", + error ("%qE in namespace %qE does not name a type", id, parser->scope); else if (TYPE_P (parser->scope)) - error ("`%E' in class `%T' does not name a type", - id, parser->scope); + error ("q%E in class %qT does not name a type", id, parser->scope); else gcc_unreachable (); } @@ -2816,7 +2815,7 @@ cp_parser_primary_expression (cp_parser *parser, cp_lexer_consume_token (parser->lexer); if (parser->local_variables_forbidden_p) { - error ("`this' may not be used in this context"); + error ("% may not be used in this context"); return error_mark_node; } /* Pointers cannot appear in constant-expressions. */ @@ -2951,7 +2950,7 @@ cp_parser_primary_expression (cp_parser *parser, decl = check_for_out_of_scope_variable (decl); if (local_variable_p (decl)) { - error ("local variable `%D' may not appear in this context", + error ("local variable %qD may not appear in this context", decl); return error_mark_node; } @@ -3316,7 +3315,7 @@ cp_parser_unqualified_id (cp_parser* parser, if (declarator_p && !DECL_IMPLICIT_TYPEDEF_P (type_decl) && !DECL_SELF_REFERENCE_P (type_decl)) - error ("typedef-name `%D' used as destructor declarator", + error ("typedef-name %qD used as destructor declarator", type_decl); return build_nt (BIT_NOT_EXPR, TREE_TYPE (type_decl)); @@ -3522,8 +3521,7 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser, decl = cp_parser_lookup_name_simple (parser, token->value); if (TREE_CODE (decl) == TEMPLATE_DECL) - error ("`%D' used without template parameters", - decl); + error ("%qD used without template parameters", decl); else cp_parser_name_lookup_error (parser, token->value, decl, @@ -5051,7 +5049,8 @@ cp_parser_direct_new_declarator (cp_parser* parser) /*complain=*/true); if (!expression) { - error ("expression in new-declarator must have integral or enumeration type"); + error ("expression in new-declarator must have integral " + "or enumeration type"); expression = error_mark_node; } } @@ -5987,7 +5986,7 @@ cp_parser_labeled_statement (cp_parser* parser, tree in_statement_expr) expr_hi = NULL_TREE; if (!parser->in_switch_statement_p) - error ("case label `%E' not within a switch statement", expr); + error ("case label %qE not within a switch statement", expr); else statement = finish_case_label (expr, expr_hi); } @@ -6493,7 +6492,7 @@ cp_parser_jump_statement (cp_parser* parser) } else statement = finish_break_stmt (); - cp_parser_require (parser, CPP_SEMICOLON, "`;'"); + cp_parser_require (parser, CPP_SEMICOLON, "%<;%>"); break; case RID_CONTINUE: @@ -6504,7 +6503,7 @@ cp_parser_jump_statement (cp_parser* parser) } else statement = finish_continue_stmt (); - cp_parser_require (parser, CPP_SEMICOLON, "`;'"); + cp_parser_require (parser, CPP_SEMICOLON, "%<;%>"); break; case RID_RETURN: @@ -6520,7 +6519,7 @@ cp_parser_jump_statement (cp_parser* parser) /* Build the return-statement. */ statement = finish_return_stmt (expr); /* Look for the final `;'. */ - cp_parser_require (parser, CPP_SEMICOLON, "`;'"); + cp_parser_require (parser, CPP_SEMICOLON, "%<;%>"); } break; @@ -6539,7 +6538,7 @@ cp_parser_jump_statement (cp_parser* parser) else finish_goto_stmt (cp_parser_identifier (parser)); /* Look for the final `;'. */ - cp_parser_require (parser, CPP_SEMICOLON, "`;'"); + cp_parser_require (parser, CPP_SEMICOLON, "%<;%>"); break; default: @@ -6997,7 +6996,7 @@ cp_parser_simple_declaration (cp_parser* parser, if (decl != error_mark_node || (cp_parser_parsing_tentatively (parser) && !cp_parser_committed_to_tentative_parse (parser))) - cp_parser_error (parser, "expected `,' or `;'"); + cp_parser_error (parser, "expected %<,%> or %<;%>"); /* Skip tokens until we reach the end of the statement. */ cp_parser_skip_to_end_of_statement (parser); /* If the next token is now a `;', consume it. */ @@ -7105,7 +7104,7 @@ cp_parser_decl_specifier_seq (cp_parser* parser, friend */ case RID_FRIEND: if (decl_specs->specs[(int) ds_friend]++) - error ("duplicate `friend'"); + error ("duplicate %"); /* Consume the token. */ cp_lexer_consume_token (parser->lexer); break; @@ -7679,7 +7678,7 @@ cp_parser_mem_initializer_id (cp_parser* parser) /* `typename' is not allowed in this context ([temp.res]). */ if (cp_lexer_next_token_is_keyword (parser->lexer, RID_TYPENAME)) { - error ("keyword `typename' not allowed in this context (a qualified " + error ("keyword % not allowed in this context (a qualified " "member initializer is implicitly a type)"); cp_lexer_consume_token (parser->lexer); } @@ -8041,7 +8040,7 @@ cp_parser_template_declaration (cp_parser* parser, bool member_p) /* Consume the `export' token. */ cp_lexer_consume_token (parser->lexer); /* Warn that we do not support `export'. */ - warning ("keyword `export' not implemented, and will be ignored"); + warning ("keyword % not implemented, and will be ignored"); } cp_parser_template_declaration_after_export (parser, member_p); @@ -8294,7 +8293,7 @@ cp_parser_type_parameter (cp_parser* parser) default: /* Anything else is an error. */ cp_parser_error (parser, - "expected `class', `typename', or `template'"); + "expected %, %, or %"); parameter = error_mark_node; } @@ -8408,21 +8407,21 @@ cp_parser_template_id (cp_parser *parser, and return simply an error. Maybe this is not a template-id after all. */ next_token_2->type = CPP_COLON; - cp_parser_error (parser, "expected `<'"); + cp_parser_error (parser, "expected %<<%>"); pop_deferring_access_checks (); return error_mark_node; } /* Otherwise, emit an error about the invalid digraph, but continue parsing because we got our argument list. */ - pedwarn ("`<::' cannot begin a template-argument list"); - inform ("`<:' is an alternate spelling for `['. Insert whitespace " - "between `<' and `::'"); + pedwarn ("%<<::%> cannot begin a template-argument list"); + inform ("%<<:%> is an alternate spelling for %<[%>. Insert whitespace " + "between %<<%> and %<::%>"); if (!flag_permissive) { static bool hint; if (!hint) { - inform ("(if you use `-fpermissive' G++ will accept your code)"); + inform ("(if you use -fpermissive G++ will accept your code)"); hint = true; } } @@ -8597,8 +8596,8 @@ cp_parser_template_name (cp_parser* parser, ptrdiff_t start; cp_token* token; /* Explain what went wrong. */ - error ("non-template `%D' used as template", identifier); - inform ("use `%T::template %D' to indicate that it is a template", + error ("non-template %qD used as template", identifier); + inform ("use %<%T::template %D%> to indicate that it is a template", parser->scope, identifier); /* If parsing tentatively, find the location of the "<" token. */ @@ -9625,7 +9624,7 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, tag_type = typename_type; /* The `typename' keyword is only allowed in templates. */ if (!processing_template_decl) - pedwarn ("using `typename' outside of template"); + pedwarn ("using % outside of template"); } /* Otherwise it must be a class-key. */ else @@ -11068,7 +11067,7 @@ cp_parser_direct_declarator (cp_parser* parser, /*only_current_p=*/false); /* If that failed, the declarator is invalid. */ if (type == error_mark_node) - error ("`%T::%D' is not a type", + error ("%<%T::%D%> is not a type", TYPE_CONTEXT (scope), TYPE_IDENTIFIER (scope)); /* Build a new DECLARATOR. */ @@ -11114,8 +11113,9 @@ cp_parser_direct_declarator (cp_parser* parser, && CLASSTYPE_USE_TEMPLATE (TREE_TYPE (unqualified_name))) { error ("invalid use of constructor as a template"); - inform ("use `%T::%D' instead of `%T::%T' to name the " - "constructor in a qualified name", class_type, + inform ("use %<%T::%D%> instead of %<%T::%T%> to name " + "the constructor in a qualified name", + class_type, DECL_NAME (TYPE_TI_TEMPLATE (class_type)), class_type, class_type); } @@ -11626,7 +11626,7 @@ cp_parser_parameter_declaration_list (cp_parser* parser, bool *is_error) } else { - cp_parser_error (parser, "expected `,' or `...'"); + cp_parser_error (parser, "expected %<,%> or %<...%>"); if (!cp_parser_parsing_tentatively (parser) || cp_parser_committed_to_tentative_parse (parser)) cp_parser_skip_to_closing_parenthesis (parser, @@ -12595,7 +12595,7 @@ cp_parser_class_head (cp_parser* parser, xref_tag, since that has irreversible side-effects. */ if (!cp_parser_next_token_starts_class_definition_p (parser)) { - cp_parser_error (parser, "expected `{' or `:'"); + cp_parser_error (parser, "expected %<{%> or %<:%>"); return error_mark_node; } @@ -12620,8 +12620,8 @@ cp_parser_class_head (cp_parser* parser, class was originally declared, the program is invalid. */ if (scope && !is_ancestor (scope, nested_name_specifier)) { - error ("declaration of `%D' in `%D' which does not " - "enclose `%D'", type, scope, nested_name_specifier); + error ("declaration of %qD in %qD which does not enclose %qD", + type, scope, nested_name_specifier); type = NULL_TREE; goto done; } @@ -12644,7 +12644,7 @@ cp_parser_class_head (cp_parser* parser, && parser->num_template_parameter_lists == 0 && template_id_p) { - error ("an explicit specialization must be preceded by 'template <>'"); + error ("an explicit specialization must be preceded by %