From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 84500 invoked by alias); 31 Oct 2017 20:25:56 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 84473 invoked by uid 89); 31 Oct 2017 20:25:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=sk:constru, datum X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 31 Oct 2017 20:25:49 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 873DF5F723 for ; Tue, 31 Oct 2017 20:25:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 873DF5F723 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=dmalcolm@redhat.com Received: from c64.redhat.com (ovpn-112-33.phx2.redhat.com [10.3.112.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D5AE60C96; Tue, 31 Oct 2017 20:25:43 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [committed] diagnostics: get rid of *_at_rich_loc in favor of overloading Date: Tue, 31 Oct 2017 20:30:00 -0000 Message-Id: <1509481632-30121-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes X-SW-Source: 2017-10/txt/msg02371.txt.bz2 Adding a fix-it hint currently involves changing e.g.: error_at (token->location, "unknown type name %qE; did you mean %qs?", token->value, hint); to: gcc_rich_location richloc (token->location); richloc.add_fixit_replace (hint); error_at_rich_loc (&richloc, "unknown type name %qE; did you mean %qs?", token->value, hint); to make the change from taking a location_t to a rich_location *. This patch renames the "*_at_rich_loc" diagnostic entrypoints to use the same function names for rich_location * as for location_t, via overloading, to simplify the above change to just changing from: error_at (token->location, "unknown type name %qE; did you mean %qs?", token->value, hint); to: gcc_rich_location richloc (token->location); richloc.add_fixit_replace (hint); error_at (&richloc, "unknown type name %qE; did you mean %qs?", token->value, hint); thus saving space (and typing) and usually avoiding the need to reindent the "error_at" invocation. With this change, 0 is no longer acceptable as a location_t to these entrypoints, as e.g.: ../../src/gcc/auto-profile.c:855:37: error: call of overloaded 'inform(int, const char [18])' is ambiguous inform (0, "Not expected TAG."); ^ In file included from ../../src/gcc/auto-profile.c:35:0: ../../src/gcc/diagnostic-core.h:88:13: note: candidate: 'void inform(location_t, const char*, ...)' extern void inform (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3); ^~~~~~ ../../src/gcc/diagnostic-core.h:89:13: note: candidate: 'void inform(rich_location*, const char*, ...)' extern void inform (rich_location *, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3); ^~~~~~ Such locations now need to be spelled out as UNKNOWN_LOCATION, rather than 0. I considered making the API take a rich_location & rather than a rich_location *, but doing so would mean replacing diagnostic_set_info and diagnostic_set_info_translated with a constructor for diagnostic_info, which was a more invasive change. Maybe in the future. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu; successfully built everything in contrib/config-list.mk, with the exception of: i686-cygwinOPT-enable-threads=yes i686-mingw32crt x86_64-mingw32OPT-enable-sjlj-exceptions=yes x86_64-w64-mingw32 which all appear to have the same pre-existing failure in gimplify.c here: src/gcc/config/i386/i386.h:611:46: error: 'ix86_cfun_abi' was not declared in this scope #define TARGET_64BIT_MS_ABI (TARGET_64BIT && ix86_cfun_abi () == MS_ABI) ^~~~~~~~~~~~~ Committed to trunk as r254280. gcc/ChangeLog: * auto-profile.c (autofdo_source_profile::read): Use UNKNOWN_LOCATION rather than 0. * diagnostic-core.h (warning_at_rich_loc): Rename to... (warning_at): ...this overload. (warning_at_rich_loc_n): Rename to... (warning_n): ...this overload. (error_at_rich_loc): Rename to... (error_at): ...this overload. (pedwarn_at_rich_loc): Rename to... (pedwarn): ...this overload. (permerror_at_rich_loc): Rename to... (permerror): ...this overload. (inform_at_rich_loc): Rename to... (inform): ...this overload. * diagnostic.c: (diagnostic_n_impl): Delete location_t-based decl. (diagnostic_n_impl_richloc): Rename to... (diagnostic_n_impl): ...this rich_location *-based decl. (inform_at_rich_loc): Rename to... (inform): ...this, and add an assertion. (inform_n): Update for removal of location_t-based diagnostic_n_impl. (warning_at_rich_loc): Rename to... (warning_at): ...this, and add an assertion. (warning_at_rich_loc_n): Rename to... (warning_n): ...this, and add an assertion. (warning_n): Update location_t-based implementation for removal of location_t-based diagnostic_n_impl. (pedwarn_at_rich_loc): Rename to... (pedwarn): ...this, and add an assertion. (permerror_at_rich_loc): Rename to... (permerror): ...this, and add an assertion. (error_n): Update for removal of location_t-based diagnostic_n_impl. (error_at_rich_loc): Rename to... (error_at): ...this, and add an assertion. * gcc.c (do_spec_1): Use UNKNOWN_LOCATION rather than 0. (driver::do_spec_on_infiles): Likewise. * substring-locations.c (format_warning_va): Update for renaming of inform_at_rich_loc. gcc/c-family/ChangeLog: * c-common.c (binary_op_error): Update for renaming of error_at_rich_loc. (c_parse_error): Likewise. * c-warn.c (warn_logical_not_parentheses): Likewise for renaming of inform_at_rich_loc. (warn_for_restrict): Likewise for renaming of warning_at_rich_loc_n. gcc/c/ChangeLog: * c-decl.c (implicit_decl_warning): Update for renaming of pedwarn_at_rich_loc and warning_at_rich_loc. (implicitly_declare): Likewise for renaming of inform_at_rich_loc. (undeclared_variable): Likewise for renaming of error_at_rich_loc. * c-parser.c (c_parser_declaration_or_fndef): Likewise. (c_parser_struct_or_union_specifier): Likewise for renaming of pedwarn_at_rich_loc. (c_parser_parameter_declaration): Likewise for renaming of error_at_rich_loc. * c-typeck.c (build_component_ref): Likewise. (build_unary_op): Likewise for renaming of inform_at_rich_loc. (pop_init_level): Likewise for renaming of warning_at_rich_loc. (set_init_label): Likewise for renaming of error_at_rich_loc. gcc/cp/ChangeLog: * class.c (explain_non_literal_class): Use UNKNOWN_LOCATION rather than 0. * name-lookup.c (suggest_alternatives_for): Update for renaming of inform_at_rich_loc. (maybe_suggest_missing_header): Likewise. (suggest_alternative_in_explicit_scope): Likewise. * parser.c (cp_parser_diagnose_invalid_type_name): Likewise for renaming of error_at_rich_loc. (cp_parser_string_literal): Likewise. (cp_parser_nested_name_specifier_opt): Likewise. (cp_parser_cast_expression): Likewise for renaming of warning_at_rich_loc. (cp_parser_decl_specifier_seq): Likewise for renaming of error_at_rich_loc and warning_at_rich_loc. (cp_parser_elaborated_type_specifier): Likewise for renaming of pedwarn_at_rich_loc. (cp_parser_cv_qualifier_seq_opt): Likewise for renaming of error_at_rich_loc. (cp_parser_virt_specifier_seq_opt): Likewise. (cp_parser_class_specifier_1): Likewise. (cp_parser_class_head): Likewise. (cp_parser_member_declaration): Likewise for renaming of pedwarn_at_rich_loc, warning_at_rich_loc, and error_at_rich_loc. (cp_parser_enclosed_template_argument_list): Likewise for renaming of error_at_rich_loc. (set_and_check_decl_spec_loc): Likewise. * pt.c (listify): Likewise. * rtti.c (typeid_ok_p): Likewise. * semantics.c (process_outer_var_ref): Use UNKNOWN_LOCATION rather than 0. * typeck.c (access_failure_info::maybe_suggest_accessor): Update for renaming of inform_at_rich_loc. (finish_class_member_access_expr): Likewise for renaming of error_at_rich_loc. gcc/objc/ChangeLog: * objc-gnu-runtime-abi-01.c (objc_gnu_runtime_abi_01_init): Use UNKNOWN_LOCATION rather than 0. gcc/testsuite/ChangeLog: * gcc.dg/plugin/diagnostic_plugin_show_trees.c (show_tree): Update for renaming of error_at_rich_loc and inform_at_rich_loc. * gcc.dg/plugin/diagnostic_plugin_test_show_locus.c (test_show_locus): Likewise for renaming of warning_at_rich_loc. libcpp/ChangeLog: * directives.c (_cpp_handle_directive): Update for renaming of cpp_error_at_richloc to cpp_error_at. * errors.c (cpp_diagnostic_at_richloc): Rename to... (cpp_diagnostic_at): ...this, dropping the location_t-based implementation. (cpp_diagnostic): Update for removal of location_t-based cpp_diagnostic_at. (cpp_error_at): Likewise. (cpp_error_at_richloc): Rename to... (cpp_error_at): ...this, and update for renaming of cpp_diagnostic_at_richloc. * include/cpplib.h (cpp_error_at_richloc): Rename to... (cpp_error_at): ...this. --- gcc/auto-profile.c | 2 +- gcc/c-family/c-common.c | 16 ++-- gcc/c-family/c-warn.c | 18 ++--- gcc/c/c-decl.c | 34 ++++----- gcc/c/c-parser.c | 41 +++++----- gcc/c/c-typeck.c | 29 ++++---- gcc/cp/class.c | 13 ++-- gcc/cp/name-lookup.c | 14 ++-- gcc/cp/parser.c | 82 ++++++++++---------- gcc/cp/pt.c | 6 +- gcc/cp/rtti.c | 6 +- gcc/cp/semantics.c | 2 +- gcc/cp/typeck.c | 16 ++-- gcc/diagnostic-core.h | 17 ++--- gcc/diagnostic.c | 87 +++++++++++----------- gcc/gcc.c | 7 +- gcc/objc/objc-gnu-runtime-abi-01.c | 3 +- gcc/substring-locations.c | 4 +- .../gcc.dg/plugin/diagnostic_plugin_show_trees.c | 4 +- .../plugin/diagnostic_plugin_test_show_locus.c | 30 ++++---- libcpp/directives.c | 8 +- libcpp/errors.c | 36 +++------ libcpp/include/cpplib.h | 6 +- 23 files changed, 231 insertions(+), 250 deletions(-) diff --git a/gcc/auto-profile.c b/gcc/auto-profile.c index 378f480..130d8df 100644 --- a/gcc/auto-profile.c +++ b/gcc/auto-profile.c @@ -852,7 +852,7 @@ autofdo_source_profile::read () { if (gcov_read_unsigned () != GCOV_TAG_AFDO_FUNCTION) { - inform (0, "Not expected TAG."); + inform (UNKNOWN_LOCATION, "Not expected TAG."); return false; } diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 8f36c77..24077c7 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -2694,9 +2694,9 @@ binary_op_error (rich_location *richloc, enum tree_code code, default: gcc_unreachable (); } - error_at_rich_loc (richloc, - "invalid operands to binary %s (have %qT and %qT)", - opname, type0, type1); + error_at (richloc, + "invalid operands to binary %s (have %qT and %qT)", + opname, type0, type1); } /* Given an expression as a tree, return its original type. Do this @@ -5944,7 +5944,7 @@ c_parse_error (const char *gmsgid, enum cpp_ttype token_type, else message = catenate_messages (gmsgid, " before %s'\\x%x'"); - error_at_rich_loc (richloc, message, prefix, val); + error_at (richloc, message, prefix, val); free (message); message = NULL; } @@ -5972,7 +5972,7 @@ c_parse_error (const char *gmsgid, enum cpp_ttype token_type, else if (token_type == CPP_NAME) { message = catenate_messages (gmsgid, " before %qE"); - error_at_rich_loc (richloc, message, value); + error_at (richloc, message, value); free (message); message = NULL; } @@ -5985,16 +5985,16 @@ c_parse_error (const char *gmsgid, enum cpp_ttype token_type, else if (token_type < N_TTYPES) { message = catenate_messages (gmsgid, " before %qs token"); - error_at_rich_loc (richloc, message, cpp_type2name (token_type, token_flags)); + error_at (richloc, message, cpp_type2name (token_type, token_flags)); free (message); message = NULL; } else - error_at_rich_loc (richloc, gmsgid); + error_at (richloc, gmsgid); if (message) { - error_at_rich_loc (richloc, message); + error_at (richloc, message); free (message); } #undef catenate_messages diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c index 78f6ba8..09ef685 100644 --- a/gcc/c-family/c-warn.c +++ b/gcc/c-family/c-warn.c @@ -496,8 +496,8 @@ warn_logical_not_parentheses (location_t location, enum tree_code code, rich_location richloc (line_table, lhs_loc); richloc.add_fixit_insert_before (lhs_loc, "("); richloc.add_fixit_insert_after (lhs_loc, ")"); - inform_at_rich_loc (&richloc, "add parentheses around left hand side " - "expression to silence this warning"); + inform (&richloc, "add parentheses around left hand side " + "expression to silence this warning"); } } @@ -2391,13 +2391,13 @@ warn_for_restrict (unsigned param_pos, tree *argarray, unsigned nargs) richloc.add_range (EXPR_LOCATION (arg), false); } - warning_at_rich_loc_n (&richloc, OPT_Wrestrict, arg_positions.length (), - "passing argument %i to restrict-qualified parameter" - " aliases with argument %Z", - "passing argument %i to restrict-qualified parameter" - " aliases with arguments %Z", - param_pos + 1, arg_positions.address (), - arg_positions.length ()); + warning_n (&richloc, OPT_Wrestrict, arg_positions.length (), + "passing argument %i to restrict-qualified parameter" + " aliases with argument %Z", + "passing argument %i to restrict-qualified parameter" + " aliases with arguments %Z", + param_pos + 1, arg_positions.address (), + arg_positions.length ()); } /* Callback function to determine whether an expression TP or one of its diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 78405c8..d95a2b6 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -3119,10 +3119,10 @@ implicit_decl_warning (location_t loc, tree id, tree olddecl) { gcc_rich_location richloc (loc); richloc.add_fixit_replace (hint); - warned = pedwarn_at_rich_loc - (&richloc, OPT_Wimplicit_function_declaration, - "implicit declaration of function %qE; did you mean %qs?", - id, hint); + warned = pedwarn (&richloc, OPT_Wimplicit_function_declaration, + "implicit declaration of function %qE;" + " did you mean %qs?", + id, hint); } else warned = pedwarn (loc, OPT_Wimplicit_function_declaration, @@ -3132,7 +3132,7 @@ implicit_decl_warning (location_t loc, tree id, tree olddecl) { gcc_rich_location richloc (loc); richloc.add_fixit_replace (hint); - warned = warning_at_rich_loc + warned = warning_at (&richloc, OPT_Wimplicit_function_declaration, G_("implicit declaration of function %qE; did you mean %qs?"), id, hint); @@ -3401,10 +3401,9 @@ implicitly_declare (location_t loc, tree functionid) { rich_location richloc (line_table, loc); maybe_add_include_fixit (&richloc, header); - inform_at_rich_loc - (&richloc, - "include %qs or provide a declaration of %qD", - header, decl); + inform (&richloc, + "include %qs or provide a declaration of %qD", + header, decl); } newtype = TREE_TYPE (decl); } @@ -3472,10 +3471,10 @@ undeclared_variable (location_t loc, tree id) { gcc_rich_location richloc (loc); richloc.add_fixit_replace (guessed_id); - error_at_rich_loc (&richloc, - "%qE undeclared here (not in a function);" - " did you mean %qs?", - id, guessed_id); + error_at (&richloc, + "%qE undeclared here (not in a function);" + " did you mean %qs?", + id, guessed_id); } else error_at (loc, "%qE undeclared here (not in a function)", id); @@ -3490,11 +3489,10 @@ undeclared_variable (location_t loc, tree id) { gcc_rich_location richloc (loc); richloc.add_fixit_replace (guessed_id); - error_at_rich_loc - (&richloc, - "%qE undeclared (first use in this function);" - " did you mean %qs?", - id, guessed_id); + error_at (&richloc, + "%qE undeclared (first use in this function);" + " did you mean %qs?", + id, guessed_id); } else error_at (loc, "%qE undeclared (first use in this function)", id); diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 68c45fd..7bca5f1 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -1785,26 +1785,26 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, { /* This is not C++ with its implicit typedef. */ richloc.add_fixit_insert_before ("struct "); - error_at_rich_loc (&richloc, - "unknown type name %qE;" - " use % keyword to refer to the type", - name); + error_at (&richloc, + "unknown type name %qE;" + " use % keyword to refer to the type", + name); } else if (tag_exists_p (UNION_TYPE, name)) { richloc.add_fixit_insert_before ("union "); - error_at_rich_loc (&richloc, - "unknown type name %qE;" - " use % keyword to refer to the type", - name); + error_at (&richloc, + "unknown type name %qE;" + " use % keyword to refer to the type", + name); } else if (tag_exists_p (ENUMERAL_TYPE, name)) { richloc.add_fixit_insert_before ("enum "); - error_at_rich_loc (&richloc, - "unknown type name %qE;" - " use % keyword to refer to the type", - name); + error_at (&richloc, + "unknown type name %qE;" + " use % keyword to refer to the type", + name); } else { @@ -1812,9 +1812,9 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, if (hint) { richloc.add_fixit_replace (hint); - error_at_rich_loc (&richloc, - "unknown type name %qE; did you mean %qs?", - name, hint); + error_at (&richloc, + "unknown type name %qE; did you mean %qs?", + name, hint); } else error_at (here, "unknown type name %qE", name); @@ -3168,9 +3168,8 @@ c_parser_struct_or_union_specifier (c_parser *parser) = c_parser_peek_token (parser)->location; gcc_rich_location richloc (semicolon_loc); richloc.add_fixit_remove (); - pedwarn_at_rich_loc - (&richloc, OPT_Wpedantic, - "extra semicolon in struct or union specified"); + pedwarn (&richloc, OPT_Wpedantic, + "extra semicolon in struct or union specified"); c_parser_consume_token (parser); continue; } @@ -4073,9 +4072,9 @@ c_parser_parameter_declaration (c_parser *parser, tree attrs) { gcc_rich_location richloc (token->location); richloc.add_fixit_replace (hint); - error_at_rich_loc (&richloc, - "unknown type name %qE; did you mean %qs?", - token->value, hint); + error_at (&richloc, + "unknown type name %qE; did you mean %qs?", + token->value, hint); } else error_at (token->location, "unknown type name %qE", token->value); diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index cb9c589..4bdc48a 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -2406,10 +2406,9 @@ build_component_ref (location_t loc, tree datum, tree component, gcc_rich_location rich_loc (reported_loc); if (component_loc != UNKNOWN_LOCATION) rich_loc.add_fixit_misspelled_id (component_loc, guessed_id); - error_at_rich_loc - (&rich_loc, - "%qT has no member named %qE; did you mean %qE?", - type, component, guessed_id); + error_at (&rich_loc, + "%qT has no member named %qE; did you mean %qE?", + type, component, guessed_id); } else error_at (loc, "%qT has no member named %qE", type, component); @@ -2483,9 +2482,9 @@ build_component_ref (location_t loc, tree datum, tree component, rich_location richloc (line_table, loc); /* "loc" should be the "." token. */ richloc.add_fixit_replace ("->"); - error_at_rich_loc (&richloc, - "%qE is a pointer; did you mean to use %<->%>?", - datum); + error_at (&richloc, + "%qE is a pointer; did you mean to use %<->%>?", + datum); return error_mark_node; } else if (code != ERROR_MARK) @@ -4276,8 +4275,7 @@ build_unary_op (location_t location, enum tree_code code, tree xarg, { gcc_rich_location richloc (location); richloc.add_fixit_insert_before (location, "!"); - inform_at_rich_loc (&richloc, "did you mean to use logical " - "not?"); + inform (&richloc, "did you mean to use logical not?"); } if (!noconvert) arg = default_conversion (arg); @@ -8256,9 +8254,9 @@ pop_init_level (location_t loc, int implicit, && !constructor_zeroinit) { gcc_assert (initializer_stack->missing_brace_richloc); - warning_at_rich_loc (initializer_stack->missing_brace_richloc, - OPT_Wmissing_braces, - "missing braces around initializer"); + warning_at (initializer_stack->missing_brace_richloc, + OPT_Wmissing_braces, + "missing braces around initializer"); } /* Warn when some struct elements are implicitly initialized to zero. */ @@ -8580,10 +8578,9 @@ set_init_label (location_t loc, tree fieldname, location_t fieldname_loc, { gcc_rich_location rich_loc (fieldname_loc); rich_loc.add_fixit_misspelled_id (fieldname_loc, guessed_id); - error_at_rich_loc - (&rich_loc, - "%qT has no member named %qE; did you mean %qE?", - constructor_type, fieldname, guessed_id); + error_at (&rich_loc, + "%qT has no member named %qE; did you mean %qE?", + constructor_type, fieldname, guessed_id); } else error_at (fieldname_loc, "%qT has no member named %qE", diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 9ef5065..7c94a59 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -5394,18 +5394,20 @@ explain_non_literal_class (tree t) /* Already explained. */ return; - inform (0, "%q+T is not literal because:", t); + inform (UNKNOWN_LOCATION, "%q+T is not literal because:", t); if (cxx_dialect < cxx17 && LAMBDA_TYPE_P (t)) - inform (0, " %qT is a closure type, which is only literal in " + inform (UNKNOWN_LOCATION, + " %qT is a closure type, which is only literal in " "C++17 and later", t); else if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t)) - inform (0, " %q+T has a non-trivial destructor", t); + inform (UNKNOWN_LOCATION, " %q+T has a non-trivial destructor", t); else if (CLASSTYPE_NON_AGGREGATE (t) && !TYPE_HAS_TRIVIAL_DFLT (t) && !LAMBDA_TYPE_P (t) && !TYPE_HAS_CONSTEXPR_CTOR (t)) { - inform (0, " %q+T is not an aggregate, does not have a trivial " + inform (UNKNOWN_LOCATION, + " %q+T is not an aggregate, does not have a trivial " "default constructor, and has no constexpr constructor that " "is not a copy or move constructor", t); if (type_has_non_user_provided_default_constructor (t)) @@ -5437,7 +5439,8 @@ explain_non_literal_class (tree t) tree basetype = TREE_TYPE (base_binfo); if (!CLASSTYPE_LITERAL_P (basetype)) { - inform (0, " base class %qT of %q+T is non-literal", + inform (UNKNOWN_LOCATION, + " base class %qT of %q+T is non-literal", basetype, t); explain_non_literal_class (basetype); return; diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index b1b4ebb..e9d62e3 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -5377,7 +5377,7 @@ suggest_alternatives_for (location_t location, tree name, gcc_rich_location richloc (location); richloc.add_fixit_replace (fuzzy); - inform_at_rich_loc (&richloc, "suggested alternative: %qs", fuzzy); + inform (&richloc, "suggested alternative: %qs", fuzzy); } } @@ -5485,10 +5485,10 @@ maybe_suggest_missing_header (location_t location, tree name, tree scope) gcc_rich_location richloc (location); maybe_add_include_fixit (&richloc, header_hint); - inform_at_rich_loc (&richloc, - "% is defined in header %qs;" - " did you forget to %<#include %s%>?", - name_str, header_hint, header_hint); + inform (&richloc, + "% is defined in header %qs;" + " did you forget to %<#include %s%>?", + name_str, header_hint, header_hint); return true; } @@ -5518,8 +5518,8 @@ suggest_alternative_in_explicit_scope (location_t location, tree name, { gcc_rich_location richloc (location); richloc.add_fixit_replace (fuzzy_name); - inform_at_rich_loc (&richloc, "suggested alternative: %qs", - fuzzy_name); + inform (&richloc, "suggested alternative: %qs", + fuzzy_name); return true; } diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 2337be5..aa2beef 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -3294,9 +3294,9 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser, tree id, { gcc_rich_location richloc (location); richloc.add_fixit_replace (suggestion); - error_at_rich_loc (&richloc, - "%qE does not name a type; did you mean %qs?", - id, suggestion); + error_at (&richloc, + "%qE does not name a type; did you mean %qs?", + id, suggestion); } else error_at (location, "%qE does not name a type", id); @@ -4107,9 +4107,9 @@ cp_parser_string_literal (cp_parser *parser, bool translate, bool wide_ok, { rich_location rich_loc (line_table, tok->location); rich_loc.add_range (last_tok_loc, false); - error_at_rich_loc (&rich_loc, - "unsupported non-standard concatenation " - "of string literals"); + error_at (&rich_loc, + "unsupported non-standard concatenation " + "of string literals"); } } @@ -6163,9 +6163,9 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser, { gcc_rich_location richloc (token->location); richloc.add_fixit_replace ("::"); - error_at_rich_loc (&richloc, - "found %<:%> in nested-name-specifier, " - "expected %<::%>"); + error_at (&richloc, + "found %<:%> in nested-name-specifier, " + "expected %<::%>"); token->type = CPP_SCOPE; } @@ -9097,8 +9097,8 @@ cp_parser_cast_expression (cp_parser *parser, bool address_p, bool cast_p, gcc_rich_location rich_loc (input_location); maybe_add_cast_fixit (&rich_loc, open_paren_loc, close_paren_loc, expr, type); - warning_at_rich_loc (&rich_loc, OPT_Wold_style_cast, - "use of old-style cast to %q#T", type); + warning_at (&rich_loc, OPT_Wold_style_cast, + "use of old-style cast to %q#T", type); } /* Only type conversions to integral or enumeration types @@ -13550,7 +13550,7 @@ cp_parser_decl_specifier_seq (cp_parser* parser, { gcc_rich_location richloc (token->location); richloc.add_fixit_remove (); - error_at_rich_loc (&richloc, "% used outside of class"); + error_at (&richloc, "% used outside of class"); cp_lexer_purge_token (parser->lexer); } else @@ -13616,9 +13616,9 @@ cp_parser_decl_specifier_seq (cp_parser* parser, we're complaining about C++0x compatibility. */ gcc_rich_location richloc (token->location); richloc.add_fixit_remove (); - warning_at_rich_loc (&richloc, OPT_Wc__11_compat, - "% changes meaning in C++11; " - "please remove it"); + warning_at (&richloc, OPT_Wc__11_compat, + "% changes meaning in C++11; " + "please remove it"); /* Set the storage class anyway. */ cp_parser_set_storage_class (parser, decl_specs, RID_AUTO, @@ -17647,9 +17647,9 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, gcc_rich_location richloc (token->location); richloc.add_range (input_location, false); richloc.add_fixit_remove (); - pedwarn_at_rich_loc (&richloc, 0, "elaborated-type-specifier for " - "a scoped enum must not use the %qD keyword", - token->u.value); + pedwarn (&richloc, 0, "elaborated-type-specifier for " + "a scoped enum must not use the %qD keyword", + token->u.value); /* Consume the `struct' or `class' and parse it anyway. */ cp_lexer_consume_token (parser->lexer); } @@ -20645,7 +20645,7 @@ cp_parser_cv_qualifier_seq_opt (cp_parser* parser) { gcc_rich_location richloc (token->location); richloc.add_fixit_remove (); - error_at_rich_loc (&richloc, "duplicate cv-qualifier"); + error_at (&richloc, "duplicate cv-qualifier"); cp_lexer_purge_token (parser->lexer); } else @@ -20794,7 +20794,7 @@ cp_parser_virt_specifier_seq_opt (cp_parser* parser) { gcc_rich_location richloc (token->location); richloc.add_fixit_remove (); - error_at_rich_loc (&richloc, "duplicate virt-specifier"); + error_at (&richloc, "duplicate virt-specifier"); cp_lexer_purge_token (parser->lexer); } else @@ -22592,14 +22592,14 @@ cp_parser_class_specifier_1 (cp_parser* parser) richloc.add_fixit_insert_before (next_loc, ";"); if (CLASSTYPE_DECLARED_CLASS (type)) - error_at_rich_loc (&richloc, - "expected %<;%> after class definition"); + error_at (&richloc, + "expected %<;%> after class definition"); else if (TREE_CODE (type) == RECORD_TYPE) - error_at_rich_loc (&richloc, - "expected %<;%> after struct definition"); + error_at (&richloc, + "expected %<;%> after struct definition"); else if (TREE_CODE (type) == UNION_TYPE) - error_at_rich_loc (&richloc, - "expected %<;%> after union definition"); + error_at (&richloc, + "expected %<;%> after union definition"); else gcc_unreachable (); @@ -23046,9 +23046,9 @@ cp_parser_class_head (cp_parser* parser, rich_location richloc (line_table, reported_loc); richloc.add_fixit_insert_before (class_head_start_location, "template <> "); - error_at_rich_loc - (&richloc, - "an explicit specialization must be preceded by %