From patchwork Tue May 14 21:32:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 1099741 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-500693-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="DtKmXC+9"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="hX2iFuiF"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 453WCJ300cz9sNd for ; Wed, 15 May 2019 07:33:48 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=p+dSdZp1+uRaOxYi9SwpNSKw4nvqw5eD4FAxAdf/WVHBMhKmH0 Xij2+WYRlk2JlgQtbnQYUjOPujjv2KAtEyMnr206CUIc9JNQ6dt1q4P9jqw2aEqz 4UNYXLotCsWNfLvHwhXXEgisN4DVI9OGbKOVNjt3+CVhMMYZyzu0qzISM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=O2JSKkHYux1mS5REsoBfvg9Ny/k=; b=DtKmXC+9j2uap4GlY6hn YgMPZPdu+FA5raZNv3vKOvPopUEN+3jxeXaIcnHbLrmKb/2bytsI83N181wpPUOh Y9IDRwvhD0Hd8QaUzOe3AF9GBZA/bkakOvFpuz4BXchNlyhwwl6dZ8x7lga6M8Ag +JZ8svovqiyE43XTsLfnKCA= Received: (qmail 40461 invoked by alias); 14 May 2019 21:32:42 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 40383 invoked by uid 89); 14 May 2019 21:32:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.2 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=Break, specializing X-HELO: mail-qt1-f177.google.com Received: from mail-qt1-f177.google.com (HELO mail-qt1-f177.google.com) (209.85.160.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 14 May 2019 21:32:31 +0000 Received: by mail-qt1-f177.google.com with SMTP id i26so832767qtr.10 for ; Tue, 14 May 2019 14:32:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=9kV7IYcNkmtKgqAr+qGm+P9ZfV/X+6tH6NafBoeo5Lo=; b=hX2iFuiFtdLycnolsVP/9kF7Nr8ZjciOIR2moq5CoYm/5SHOFguQ7kZ1xJNm2azuQW Ur0YbidHj98bcRxzJfOcP1YLU8OGy/VZFE3PLfs8JWbxZPQPwEl0XjBIQgQ5PmYAKhL9 HCS+HohhFyyBmrqIFVhHWTktPjFqkF881iMhZB2LrPsoJud/UuDEtLqY+0OCE77zbh/N RpXSl6p5frfRP4jsalwwxThyxJiRLMSX6ZS/AsHpZzJHhAmCZW19sWC09IEyvyBCL4eq 6ufGLS/OO38uS+4D6NPdhwTt7lbZciV5eiOgOIiKTxU2TxfMjYmla4rapbrnigFad54k X97g== Received: from [192.168.0.41] (97-118-125-210.hlrn.qwest.net. [97.118.125.210]) by smtp.gmail.com with ESMTPSA id d16sm102917qtd.73.2019.05.14.14.32.28 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Tue, 14 May 2019 14:32:28 -0700 (PDT) To: gcc-patches , Jason Merrill From: Martin Sebor Subject: [PATCH 6/12] fix diagnostic quoting/spelling in C++ Message-ID: <933acc02-8ef9-bc35-eb99-72d0d4c5ef34@gmail.com> Date: Tue, 14 May 2019 15:32:27 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 X-IsSubscribed: yes The attached patch fixes quoting, spelling, and other formatting issues in diagnostics issued by the C++ front-end and pointed out by the -Wformat-diag warning. Martin gcc/cp/ChangeLog: * call.c (print_z_candidate): Wrap diagnostic text in a gettext macro. Adjust. (print_z_candidates): Same. (build_conditional_expr_1): Quote keywords, operators, and types in diagnostics. (build_op_delete_call): Same. (maybe_print_user_conv_context): Wrap diagnostic text in a gettext macro. (convert_like_real): Same. (convert_arg_to_ellipsis): Quote keywords, operators, and types in diagnostics. (build_over_call): Same. (joust): Break up an overlong line. Wrap diagnostic text in a gettext macro. * constexpr.c (cxx_eval_check_shift_p): Spell out >= in English. (cxx_eval_constant_expression): Quote keywords, operators, and types in diagnostics. (potential_constant_expression_1): Same. * cp-gimplify.c (cp_genericize_r): Same. * cp-tree.h (GCC_DIAG_STYLE): Adjust. (GCC_DIAG_RAW_STYLE): New macro. * cvt.c (maybe_warn_nodiscard): Quote keywords, operators, and types in diagnostics. (type_promotes_to): Same. * decl.c (check_previous_goto_1): Same. (check_goto): Same. (start_decl): Same. (cp_finish_decl): Avoid parenthesizing a sentence for consistency. (grok_op_properties): Quote keywords, operators, and types in diagnostics. * decl2.c (grokfield): Same. (coerce_delete_type): Same. * except.c (is_admissible_throw_operand_or_catch_parameter): Same. * friend.c (do_friend): Quote C++ tokens. * init.c (build_new_1): Quote keywords, operators, and types in diagnostics. (build_vec_delete_1): Same. (build_delete): Same. * lex.c (parse_strconst_pragma): Same. (handle_pragma_implementation): Same. (unqualified_fn_lookup_error): Same. * mangle.c (write_type): Same. * method.c (defaulted_late_check): Avoid two consecutive punctuators. * name-lookup.c (cp_binding_level_debug): Remove a trailing newline. (pop_everything): Same. * parser.c (cp_lexer_start_debugging): Quote a macro name. in a diagnostic (cp_lexer_stop_debugging): Same. (cp_parser_userdef_numeric_literal): Quote a C++ header name in a diagnostic. (cp_parser_nested_name_specifier_opt): Quote keywords, operators, and types in diagnostics. (cp_parser_question_colon_clause): Same. (cp_parser_asm_definition): Same. (cp_parser_init_declarator): Same. (cp_parser_template_declaration_after_parameters): Avoid capitalizing a sentence in a diagnostic. (cp_parser_omp_declare_reduction): Quote keywords, operators, and types in diagnostics. (cp_parser_transaction): Same. * pt.c (maybe_process_partial_specialization): Replace second call to permerror with inform for consistency with other uses. (expand_integer_pack): Quote keywords, operators, and types in diagnostics. * rtti.c (get_typeid): Quote keywords, operators, and types in diagnostics. (build_dynamic_cast_1): Same. * semantics.c (finish_asm_stmt): Same. (finish_label_decl): Same. (finish_bases): Same. (finish_offsetof): Same. (cp_check_omp_declare_reduction): Same. (finish_decltype_type): Same. * tree.c (handle_init_priority_attribute): Same. Add detail to diagnostics. (maybe_warn_zero_as_null_pointer_constant): Same. * typeck.c (cp_build_binary_op): Quote keywords, operators, and types in diagnostics. (cp_build_unary_op): Same. (check_for_casting_away_constness): Same. (build_static_cast): Same. (build_const_cast_1): Same. (maybe_warn_about_returning_address_of_local): Same. (check_return_expr): Same. * typeck2.c (abstract_virtuals_error_sfinae): Same. (digest_init_r): Replace a tab with spaces in a diagnostic. (build_functional_cast): Quote keywords, operators, and types in diagnostics. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 00cb3993471..c2f17dc3750 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -3603,7 +3603,7 @@ print_z_candidate (location_t loc, const char *msgstr, { const char *msg = (msgstr == NULL ? "" - : ACONCAT ((msgstr, " ", NULL))); + : ACONCAT ((_(msgstr), " ", NULL))); tree fn = candidate->fn; if (flag_new_inheriting_ctors) fn = strip_inheriting_ctors (fn); @@ -3613,24 +3613,27 @@ print_z_candidate (location_t loc, const char *msgstr, { cloc = loc; if (candidate->num_convs == 3) - inform (cloc, "%s%<%D(%T, %T, %T)%> ", msg, fn, + inform (cloc, "%s%<%D(%T, %T, %T)%> %s", msg, fn, candidate->convs[0]->type, candidate->convs[1]->type, - candidate->convs[2]->type); + candidate->convs[2]->type, + ""); else if (candidate->num_convs == 2) - inform (cloc, "%s%<%D(%T, %T)%> ", msg, fn, + inform (cloc, "%s%<%D(%T, %T)%> %s", msg, fn, candidate->convs[0]->type, - candidate->convs[1]->type); + candidate->convs[1]->type, + ""); else - inform (cloc, "%s%<%D(%T)%> ", msg, fn, - candidate->convs[0]->type); + inform (cloc, "%s%<%D(%T)%> %s", msg, fn, + candidate->convs[0]->type, + ""); } else if (TYPE_P (fn)) - inform (cloc, "%s%qT ", msg, fn); + inform (cloc, "%s%qT %s", msg, fn, ""); else if (candidate->viable == -1) - inform (cloc, "%s%#qD ", msg, fn); + inform (cloc, "%s%#qD %s", msg, fn, ""); else if (DECL_DELETED_FN (fn)) - inform (cloc, "%s%#qD ", msg, fn); + inform (cloc, "%s%#qD %s", msg, fn, ""); else inform (cloc, "%s%#qD", msg, fn); if (fn != candidate->fn) @@ -3763,7 +3766,7 @@ print_z_candidates (location_t loc, struct z_candidate *candidates) } for (; candidates; candidates = candidates->next) - print_z_candidate (loc, "candidate:", candidates); + print_z_candidate (loc, N_("candidate:"), candidates); } /* USER_SEQ is a user-defined conversion sequence, beginning with a @@ -5006,7 +5009,8 @@ build_conditional_expr_1 (const op_location_t &loc, { if (complain & tf_error) pedwarn (loc, OPT_Wpedantic, - "ISO C++ forbids omitting the middle term of a ?: expression"); + "ISO C++ forbids omitting the middle term of " + "a % expression"); if ((complain & tf_warning) && !truth_value_p (TREE_CODE (arg1))) warn_for_omitted_condop (loc, arg1); @@ -5279,7 +5283,8 @@ build_conditional_expr_1 (const op_location_t &loc, { if (complain & tf_error) { - error_at (loc, "operands to ?: have different types %qT and %qT", + error_at (loc, "operands to % have different types " + "%qT and %qT", arg2_type, arg3_type); if (conv2 && !conv2->bad_p && conv3 && !conv3->bad_p) inform (loc, " and each type can be converted to the other"); @@ -5395,7 +5400,7 @@ build_conditional_expr_1 (const op_location_t &loc, if (!any_viable_p) { if (complain & tf_error) - error_at (loc, "operands to ?: have different types %qT and %qT", + error_at (loc, "operands to % have different types %qT and %qT", arg2_type, arg3_type); return error_mark_node; } @@ -5542,7 +5547,7 @@ build_conditional_expr_1 (const op_location_t &loc, if (!result_type) { if (complain & tf_error) - error_at (loc, "operands to ?: have different types %qT and %qT", + error_at (loc, "operands to % have different types %qT and %qT", arg2_type, arg3_type); return error_mark_node; } @@ -6492,10 +6497,10 @@ build_op_delete_call (enum tree_code code, tree addr, tree size, { const char *const msg1 = G_("exception cleanup for this placement new selects " - "non-placement operator delete"); + "non-placement %"); const char *const msg2 = G_("%qD is a usual (non-placement) deallocation " - "function in C++14 (or with -fsized-deallocation)"); + "function in C++14 (or with %<-fsized-deallocation%>)"); /* But if the class has an operator delete (void *), then that is the usual deallocation function, so we shouldn't complain @@ -6892,7 +6897,7 @@ maybe_print_user_conv_context (conversion *convs) for (conversion *t = convs; t; t = next_conversion (t)) if (t->kind == ck_user) { - print_z_candidate (0, " after user-defined conversion:", + print_z_candidate (0, N_(" after user-defined conversion:"), t->cand); break; } @@ -7005,7 +7010,7 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, "from %qH to %qI", TREE_TYPE (expr), totype); if (complained) - print_z_candidate (loc, "candidate is:", t->cand); + print_z_candidate (loc, N_("candidate is:"), t->cand); expr = convert_like_real (t, expr, fn, argnum, /*issue_conversion_warnings=*/false, /*c_cast_p=*/false, @@ -7517,8 +7522,9 @@ convert_arg_to_ellipsis (tree arg, tsubst_flags_t complain) if (abi_version_crosses (6) && TYPE_MODE (TREE_TYPE (prom)) != TYPE_MODE (arg_type) && (complain & tf_warning)) - warning_at (loc, OPT_Wabi, "scoped enum %qT passed through ... as " - "%qT before %<-fabi-version=6%>, %qT after", arg_type, + warning_at (loc, OPT_Wabi, "scoped enum %qT passed through %<...%>" + "as %qT before %<-fabi-version=6%>, %qT after", + arg_type, TREE_TYPE (prom), ENUM_UNDERLYING_TYPE (arg_type)); if (!abi_version_at_least (6)) arg = prom; @@ -8596,8 +8602,8 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) if (is_std_init_list (type) && conv_binds_ref_to_prvalue (convs[1])) warning_at (loc, OPT_Winit_list_lifetime, - "assignment from temporary initializer_list does not " - "extend the lifetime of the underlying array"); + "assignment from temporary % does " + "not extend the lifetime of the underlying array"); arg = cp_build_fold_indirect_ref (arg); val = build2 (MODIFY_EXPR, TREE_TYPE (to), to, arg); } @@ -10745,7 +10751,8 @@ joust (struct z_candidate *cand1, struct z_candidate *cand2, bool warn, && warning (OPT_Wconversion, " for conversion from %qH to %qI", source, w->second_conv->type)) { - inform (input_location, " because conversion sequence for the argument is better"); + inform (input_location, " because conversion sequence " + "for the argument is better"); } } else @@ -11031,8 +11038,8 @@ tweak: "though the worst conversion for the first is " "better than the worst conversion for the second:")) { - print_z_candidate (input_location, _("candidate 1:"), w); - print_z_candidate (input_location, _("candidate 2:"), l); + print_z_candidate (input_location, N_("candidate 1:"), w); + print_z_candidate (input_location, N_("candidate 2:"), l); } } else diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 8ae0fd5715f..13b4da49f66 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -2020,9 +2020,9 @@ cxx_eval_check_shift_p (location_t loc, const constexpr_ctx *ctx, if (compare_tree_int (rhs, uprec) >= 0) { if (!ctx->quiet) - permerror (loc, "right operand of shift expression %q+E is >= than " - "the precision of the left operand", - build2_loc (loc, code, type, lhs, rhs)); + permerror (loc, "right operand of shift expression %q+E is greater " + "than or equal to the precision %wu of the left operand", + build2_loc (loc, code, type, lhs, rhs), uprec); return (!flag_permissive || ctx->quiet); } @@ -4420,7 +4420,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, if (!ctx->quiet) error_at (cp_expr_loc_or_loc (t, input_location), "% evaluation operation count exceeds limit of " - "%wd (use -fconstexpr-ops-limit= to increase the limit)", + "%wd (use %<-fconstexpr-ops-limit=%> to increase the limit)", constexpr_ops_limit); *ctx->constexpr_ops_count = INTTYPE_MINIMUM (HOST_WIDE_INT); *non_constant_p = true; @@ -4957,7 +4957,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, { if (!ctx->quiet) error_at (cp_expr_loc_or_loc (t, input_location), - "a reinterpret_cast is not a constant expression"); + "% is not a constant expression"); *non_constant_p = true; return t; } @@ -6116,7 +6116,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now, if (REINTERPRET_CAST_P (t)) { if (flags & tf_error) - error_at (loc, "a reinterpret_cast is not a constant expression"); + error_at (loc, "% is not a constant expression"); return false; } /* FALLTHRU */ @@ -6135,7 +6135,8 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now, && !integer_zerop (from)) { if (flags & tf_error) - error_at (loc, "reinterpret_cast from integer to pointer"); + error_at (loc, + "% from integer to pointer"); return false; } } @@ -6389,7 +6390,8 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now, /* In C++2a virtual calls can be constexpr, don't give up yet. */ return true; else if (flags & tf_error) - error_at (loc, "virtual functions cannot be constexpr before C++2a"); + error_at (loc, + "virtual functions cannot be % before C++2a"); return false; case TYPEID_EXPR: @@ -6401,7 +6403,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now, && TYPE_POLYMORPHIC_P (TREE_TYPE (e))) { if (flags & tf_error) - error_at (loc, "typeid-expression is not a constant expression " + error_at (loc, "% is not a constant expression " "because %qE is of polymorphic type", e); return false; } diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 4e63a4a6944..6edefbf9933 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -1466,10 +1466,10 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) { auto_diagnostic_group d; if (warning_at (loc, OPT_Wterminate, - "throw will always call terminate()") + "% will always call %") && cxx_dialect >= cxx11 && DECL_DESTRUCTOR_P (current_function_decl)) - inform (loc, "in C++11 destructors default to noexcept"); + inform (loc, "in C++11 destructors default to %"); } } else @@ -1481,8 +1481,8 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) && (get_defaulted_eh_spec (current_function_decl) == empty_except_spec)) warning_at (loc, OPT_Wc__11_compat, - "in C++11 this throw will terminate because " - "destructors default to noexcept"); + "in C++11 this % will call % " + "because destructors default to %"); } } break; diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 827b471aa80..90a0b4cf6b9 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -30,7 +30,10 @@ along with GCC; see the file COPYING3. If not see diagnostic-core.h, not after. We override the definition of GCC_DIAG_STYLE in c-common.h. */ #undef GCC_DIAG_STYLE -#define GCC_DIAG_STYLE __gcc_cxxdiag__ +#define GCC_DIAG_STYLE __gcc_cxxdiag__ +#undef GCC_DIAG_RAW_STYLE +#define GCC_DIAG_RAW_STYLE __gcc_cxxdiag_raw__ + #if defined(GCC_DIAGNOSTIC_CORE_H) || defined (GCC_C_COMMON_H) #error \ In order for the format checking to accept the C++ front end diagnostic \ diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 3d409279f22..3c3ee11eed1 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -1060,14 +1060,14 @@ maybe_warn_nodiscard (tree expr, impl_conv_void implicit) auto_diagnostic_group d; if (warning_at (loc, OPT_Wunused_result, "ignoring return value of %qD, " - "declared with attribute warn_unused_result", + "declared with attribute %", fn)) inform (DECL_SOURCE_LOCATION (fn), "declared here"); } else warning_at (loc, OPT_Wunused_result, "ignoring return value of function " - "declared with attribute warn_unused_result"); + "declared with attribute %"); } } @@ -1920,7 +1920,7 @@ type_promotes_to (tree type) { if (abi_version_crosses (6) && TYPE_MODE (prom) != TYPE_MODE (type)) - warning (OPT_Wabi, "scoped enum %qT passed through ... as " + warning (OPT_Wabi, "scoped enum %qT passed through %<...%> as " "%qT before %<-fabi-version=6%>, %qT after", type, prom, ENUM_UNDERLYING_TYPE (type)); if (!abi_version_at_least (6)) diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 86cfcbe0db5..edfa785ee25 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -3228,32 +3228,32 @@ check_previous_goto_1 (tree decl, cp_binding_level* level, tree names, { case sk_try: if (!saw_eh) - inf = N_("enters try block"); + inf = G_(" enters % block"); saw_eh = true; break; case sk_catch: if (!saw_eh) - inf = N_("enters catch block"); + inf = G_(" enters % block"); saw_eh = true; break; case sk_omp: if (!saw_omp) - inf = N_("enters OpenMP structured block"); + inf = G_(" enters OpenMP structured block"); saw_omp = true; break; case sk_transaction: if (!saw_tm) - inf = N_("enters synchronized or atomic statement"); + inf = G_(" enters synchronized or atomic statement"); saw_tm = true; break; case sk_block: if (!saw_cxif && level_for_constexpr_if (b->level_chain)) { - inf = N_("enters constexpr if statement"); + inf = G_(" enters % statement"); loc = EXPR_LOCATION (b->level_chain->this_entity); saw_cxif = true; } @@ -3269,7 +3269,7 @@ check_previous_goto_1 (tree decl, cp_binding_level* level, tree names, complained = identify_goto (decl, input_location, locus, DK_ERROR); identified = 2; if (complained) - inform (loc, " %s", inf); + inform (loc, inf); } } @@ -3364,7 +3364,7 @@ check_goto (tree decl) identified = 2; } if (complained) - inform (DECL_SOURCE_LOCATION (bad), " enters catch block"); + inform (DECL_SOURCE_LOCATION (bad), " enters % block"); saw_catch = true; } else if (complained) @@ -3382,13 +3382,13 @@ check_goto (tree decl) if (complained) { if (ent->in_try_scope) - inform (input_location, " enters try block"); + inform (input_location, " enters % block"); else if (ent->in_catch_scope && !saw_catch) - inform (input_location, " enters catch block"); + inform (input_location, " enters % block"); else if (ent->in_transaction_scope) inform (input_location, " enters synchronized or atomic statement"); else if (ent->in_constexpr_if) - inform (input_location, " enters % if statement"); + inform (input_location, " enters % statement"); } if (ent->in_omp_scope) @@ -5078,7 +5078,8 @@ start_decl (const cp_declarator *declarator, && TREE_CODE (decl) == TYPE_DECL) { error_at (DECL_SOURCE_LOCATION (decl), - "typedef %qD is initialized (use decltype instead)", decl); + "typedef %qD is initialized (use %qs instead)", + decl, "decltype"); return error_mark_node; } @@ -7020,8 +7021,8 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, return; if (TREE_CODE (type) == FUNCTION_TYPE) { - error ("initializer for % has function type " - "(did you forget the %<()%> ?)", decl); + error ("initializer for % has function type; " + "did you forget the %<()%>?", decl); TREE_TYPE (decl) = error_mark_node; return; } @@ -13614,7 +13615,7 @@ grok_op_properties (tree decl, bool complain) if (operator_code == COND_EXPR) { /* 13.4.0.3 */ - error_at (loc, "ISO C++ prohibits overloading operator ?:"); + error_at (loc, "ISO C++ prohibits overloading %"); return false; } diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index fb3b911fdd5..bd022ca7ae3 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -830,7 +830,8 @@ grokfield (const cp_declarator *declarator, if (TREE_CODE (value) == TYPE_DECL && init) { error_at (cp_expr_loc_or_loc (init, DECL_SOURCE_LOCATION (value)), - "typedef %qD is initialized (use decltype instead)", value); + "typedef %qD is initialized (use %qs instead)", + value, "decltype"); init = NULL_TREE; } @@ -1772,12 +1773,13 @@ coerce_delete_type (tree decl, location_t loc) else /* A destroying operator delete shall be a class member function named operator delete. */ - error_at (loc, "destroying operator delete must be a member function"); + error_at (loc, + "destroying % must be a member function"); const ovl_op_info_t *op = IDENTIFIER_OVL_OP_INFO (DECL_NAME (decl)); if (op->flags & OVL_OP_FLAG_VEC) - error_at (loc, "operator delete[] cannot be a destroying delete"); + error_at (loc, "% cannot be a destroying delete"); if (!usual_deallocation_fn_p (decl)) - error_at (loc, "destroying operator delete must be a usual " + error_at (loc, "destroying % must be a usual " "deallocation function"); } diff --git a/gcc/cp/except.c b/gcc/cp/except.c index 3b792cbc62b..892d5201da9 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -936,7 +936,7 @@ is_admissible_throw_operand_or_catch_parameter (tree t, bool is_throw) && TYPE_REF_P (type) && TYPE_REF_IS_RVALUE (type)) { - error ("cannot declare catch parameter to be of rvalue " + error ("cannot declare % parameter to be of rvalue " "reference type %qT", type); return false; } diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c index 2429cd4c497..4ea4bbc54a5 100644 --- a/gcc/cp/friend.c +++ b/gcc/cp/friend.c @@ -638,9 +638,10 @@ do_friend (tree ctype, tree declarator, tree decl, "%q#D declares a non-template function", decl); if (! explained && warned) { - inform (input_location, "(if this is not what you intended, make sure " - "the function template has already been declared " - "and add <> after the function name here) "); + inform (input_location, "(if this is not what you intended, " + "make sure the function template has already been " + "declared and add %<<>%> after the function name " + "here)"); explained = 1; } } diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 68d04ad7417..e70c89d0d46 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -3005,7 +3005,7 @@ build_new_1 (vec **placement, tree type, tree nelts, pedwarn (cp_expr_loc_or_loc (outer_nelts, input_location), OPT_Wvla, typedef_variant_p (orig_type) ? G_("non-constant array new length must be specified " - "directly, not by typedef") + "directly, not by %") : G_("non-constant array new length must be specified " "without parentheses around the type-id")); } @@ -3016,13 +3016,13 @@ build_new_1 (vec **placement, tree type, tree nelts, if (VOID_TYPE_P (elt_type)) { if (complain & tf_error) - error ("invalid type % for new"); + error ("invalid type % for %"); return error_mark_node; } if (is_std_init_list (elt_type)) warning (OPT_Winit_list_lifetime, - "% of initializer_list does not " + "% of % does not " "extend the lifetime of the underlying array"); if (abstract_virtuals_error_sfinae (ACU_NEW, elt_type, complain)) @@ -3867,11 +3867,11 @@ build_vec_delete_1 (tree base, tree maxindex, tree type, auto_diagnostic_group d; if (warning (OPT_Wdelete_incomplete, "possible problem detected in invocation of " - "delete [] operator:")) + "operator %")) { cxx_incomplete_type_diagnostic (base, type, DK_WARNING); inform (input_location, "neither the destructor nor the " - "class-specific operator delete [] will be called, " + "class-specific operator % will be called, " "even if they are declared when the class is defined"); } } @@ -4753,14 +4753,14 @@ build_delete (tree otype, tree addr, special_function_kind auto_delete, { auto_diagnostic_group d; if (warning (OPT_Wdelete_incomplete, - "possible problem detected in invocation of " - "delete operator:")) + "possible problem detected in invocation of " + "%")) { cxx_incomplete_type_diagnostic (addr, type, DK_WARNING); inform (input_location, - "neither the destructor nor the class-specific " - "operator delete will be called, even if they " - "are declared when the class is defined"); + "neither the destructor nor the class-specific " + "% will be called, even if " + "they are declared when the class is defined"); } } } diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c index 369ecc05df2..20965e49fe4 100644 --- a/gcc/cp/lex.c +++ b/gcc/cp/lex.c @@ -385,14 +385,14 @@ parse_strconst_pragma (const char* name, int opt) if (t == CPP_STRING) { if (pragma_lex (&x) != CPP_EOF) - warning (0, "junk at end of #pragma %s", name); + warning (0, "junk at end of %<#pragma %s%>", name); return result; } if (t == CPP_EOF && opt) return NULL_TREE; - error ("invalid #pragma %s", name); + error ("invalid %<#pragma %s%>", name); return error_mark_node; } @@ -400,7 +400,7 @@ static void handle_pragma_vtable (cpp_reader* /*dfile*/) { parse_strconst_pragma ("vtable", 0); - sorry ("#pragma vtable no longer supported"); + sorry ("%<#pragma vtable%> no longer supported"); } static void @@ -472,7 +472,7 @@ handle_pragma_implementation (cpp_reader* /*dfile*/) { filename = TREE_STRING_POINTER (fname); if (cpp_included_before (parse_in, filename, input_location)) - warning (0, "#pragma implementation for %qs appears after " + warning (0, "%<#pragma implementation%> for %qs appears after " "file is included", filename); } @@ -568,8 +568,8 @@ unqualified_fn_lookup_error (cp_expr name_expr) if (!hint) { inform (loc, "(if you use %<-fpermissive%>, G++ will accept your " - "code, but allowing the use of an undeclared name is " - "deprecated)"); + "code, but allowing the use of an undeclared name is " + "deprecated)"); hint = true; } } diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index c13dacbd05e..4638f347feb 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -2305,11 +2305,11 @@ write_type (tree type) break; case TYPEOF_TYPE: - sorry ("mangling typeof, use decltype instead"); + sorry ("mangling %, use % instead"); break; case UNDERLYING_TYPE: - sorry ("mangling __underlying_type"); + sorry ("mangling %<__underlying_type%>"); break; case LANG_TYPE: diff --git a/gcc/cp/method.c b/gcc/cp/method.c index 31737d1353c..1cb93fd0dc4 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -2249,7 +2249,7 @@ defaulted_late_check (tree fn) { error ("explicitly defaulted function %q+D cannot be declared " "as % because the implicit declaration is not " - "%:", fn); + "%qs:", fn, "constexpr"); explain_implicit_non_constexpr (fn); } DECL_DECLARED_CONSTEXPR_P (fn) = false; diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 89d85f6c7d7..d8d71be98ec 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -3270,10 +3270,10 @@ cp_binding_level_debug (cp_binding_level *scope, int line, const char *action) { const char *desc = cp_binding_level_descriptor (scope); if (scope->this_entity) - verbatim ("%s %<%s(%E)%> %p %d\n", action, desc, + verbatim ("%s %<%s(%E)%> %p %d", action, desc, scope->this_entity, (void *) scope, line); else - verbatim ("%s %s %p %d\n", action, desc, (void *) scope, line); + verbatim ("%s %s %p %d", action, desc, (void *) scope, line); } /* A chain of binding_level structures awaiting reuse. */ @@ -7499,7 +7499,7 @@ void pop_everything (void) { if (ENABLE_SCOPE_CHECKING) - verbatim ("XXX entering pop_everything ()\n"); + verbatim ("XXX entering %"); while (!namespace_bindings_p ()) { if (current_binding_level->kind == sk_class) @@ -7508,7 +7508,7 @@ pop_everything (void) poplevel (0, 0, 0); } if (ENABLE_SCOPE_CHECKING) - verbatim ("XXX leaving pop_everything ()\n"); + verbatim ("XXX leaving %"); } /* Emit debugging information for using declarations and directives. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index c90782eafde..89160b9f882 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -1308,7 +1308,7 @@ cp_lexer_start_debugging (cp_lexer* lexer) { if (!LEXER_DEBUGGING_ENABLED_P) fatal_error (input_location, - "LEXER_DEBUGGING_ENABLED_P is not set to true"); + "% is not set to true"); lexer->debugging_p = true; cp_lexer_debug_stream = stderr; @@ -1321,7 +1321,7 @@ cp_lexer_stop_debugging (cp_lexer* lexer) { if (!LEXER_DEBUGGING_ENABLED_P) fatal_error (input_location, - "LEXER_DEBUGGING_ENABLED_P is not set to true"); + "% is not set to true"); lexer->debugging_p = false; cp_lexer_debug_stream = NULL; @@ -4537,7 +4537,7 @@ cp_parser_userdef_numeric_literal (cp_parser *parser) else if (i14) { inform (token->location, "add % " - "(from ) to enable the C++14 user-defined literal " + "(from %<%>) to enable the C++14 user-defined literal " "suffixes"); if (ext) inform (token->location, "or use % instead of % for the " @@ -6400,7 +6400,7 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser, == CPP_SCOPE)) { token = cp_lexer_consume_token (parser->lexer); - error_at (token->location, "decltype evaluates to %qT, " + error_at (token->location, "% evaluates to %qT, " "which is not a class or enumeration type", token->u.tree_check_value->value); parser->scope = error_mark_node; @@ -9671,7 +9671,7 @@ cp_parser_question_colon_clause (cp_parser* parser, cp_expr logical_or_expr) && token->type == CPP_COLON) { pedwarn (token->location, OPT_Wpedantic, - "ISO C++ does not allow ?: with omitted middle operand"); + "ISO C++ does not allow % with omitted middle operand"); /* Implicit true clause. */ expr = NULL_TREE; c_inhibit_evaluation_warnings += @@ -14442,7 +14442,7 @@ cp_parser_static_assert(cp_parser *parser, bool member_p) { if (cxx_dialect < cxx17) pedwarn (input_location, OPT_Wpedantic, - "static_assert without a message " + "% without a message " "only available with %<-std=c++17%> or %<-std=gnu++17%>"); /* Eat the ')' */ cp_lexer_consume_token (parser->lexer); @@ -19821,14 +19821,15 @@ cp_parser_asm_definition (cp_parser* parser) case RID_VOLATILE: if (volatile_loc) { - error_at (loc, "duplicate asm qualifier %qT", token->u.value); + error_at (loc, "duplicate % qualifier %qT", + token->u.value); inform (volatile_loc, "first seen here"); } else { if (!parser->in_function_body) - warning_at (loc, 0, "asm qualifier %qT ignored outside of " - "function body", token->u.value); + warning_at (loc, 0, "% qualifier %qT ignored " + "outside of function body", token->u.value); volatile_loc = loc; } cp_lexer_consume_token (parser->lexer); @@ -19837,7 +19838,8 @@ cp_parser_asm_definition (cp_parser* parser) case RID_INLINE: if (inline_loc) { - error_at (loc, "duplicate asm qualifier %qT", token->u.value); + error_at (loc, "duplicate % qualifier %qT", + token->u.value); inform (inline_loc, "first seen here"); } else @@ -19850,7 +19852,8 @@ cp_parser_asm_definition (cp_parser* parser) case RID_GOTO: if (goto_loc) { - error_at (loc, "duplicate asm qualifier %qT", token->u.value); + error_at (loc, "duplicate % qualifier %qT", + token->u.value); inform (goto_loc, "first seen here"); } else @@ -19862,7 +19865,7 @@ cp_parser_asm_definition (cp_parser* parser) case RID_CONST: case RID_RESTRICT: - error_at (loc, "%qT is not an asm qualifier", token->u.value); + error_at (loc, "%qT is not an % qualifier", token->u.value); cp_lexer_consume_token (parser->lexer); continue; @@ -19878,7 +19881,7 @@ cp_parser_asm_definition (cp_parser* parser) if (!parser->in_function_body && (inline_p || goto_p)) { - error_at (first_loc, "asm qualifier outside of function body"); + error_at (first_loc, "% qualifier outside of function body"); inline_p = goto_p = false; } @@ -20260,7 +20263,7 @@ cp_parser_init_declarator (cp_parser* parser, on a function-definition. */ if (asm_specification) error_at (asm_spec_start_token->location, - "an asm-specification is not allowed " + "an %-specification is not allowed " "on a function-definition"); if (attributes) error_at (attributes_start_token->location, @@ -27916,12 +27919,12 @@ cp_parser_template_declaration_after_parameters (cp_parser* parser, { if (cxx_dialect > cxx17) error ("literal operator template %qD has invalid parameter list;" - " Expected non-type template parameter pack " + " expected non-type template parameter pack %<%> " "or single non-type parameter of class type", decl); else - error ("literal operator template %qD has invalid parameter list." - " Expected non-type template parameter pack ", + error ("literal operator template %qD has invalid parameter list;" + " expected non-type template parameter pack %<%>", decl); } } @@ -39637,8 +39640,8 @@ cp_parser_omp_declare_reduction (cp_parser *parser, cp_token *pragma_tok, error_at (loc, "reference type %qT in " "%<#pragma omp declare reduction%>", type); else if (TYPE_QUALS_NO_ADDR_SPACE (type)) - error_at (loc, "const, volatile or __restrict qualified type %qT in " - "%<#pragma omp declare reduction%>", type); + error_at (loc, "%, % or %<__restrict%>-qualified " + "type %qT in %<#pragma omp declare reduction%>", type); else types.safe_push (type); @@ -40489,7 +40492,7 @@ cp_parser_transaction (cp_parser *parser, cp_token *token) else if (keyword == RID_ATOMIC_CANCEL) { /* cancel-and-throw is unimplemented. */ - sorry ("atomic_cancel"); + sorry ("%"); noex = NULL_TREE; } else diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 42d128744ab..b90230f1927 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -1058,10 +1058,11 @@ maybe_process_partial_specialization (tree type) if (current_namespace != decl_namespace_context (tmpl)) { - permerror (input_location, - "specializing %q#T in different namespace", type); - permerror (DECL_SOURCE_LOCATION (tmpl), - " from definition of %q#D", tmpl); + if (permerror (input_location, + "specialization of %qD in different namespace", + type)) + inform (DECL_SOURCE_LOCATION (tmpl), + "from definition of %q#D", tmpl); } /* Check for invalid specialization after instantiation: @@ -3606,7 +3607,8 @@ expand_integer_pack (tree call, tree args, tsubst_flags_t complain, { if ((complain & tf_error) && hi != error_mark_node) - error ("argument to __integer_pack must be between 0 and %d", max); + error ("argument to %<__integer_pack%> must be between 0 and %d", + max); return error_mark_node; } diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index 26dae3c3c1a..a1fd8d958e3 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -512,7 +512,7 @@ get_typeid (tree type, tsubst_flags_t complain) || type_memfn_rqual (type) != REF_QUAL_NONE)) { if (complain & tf_error) - error ("typeid of qualified function type %qT", type); + error ("% of qualified function type %qT", type); return error_mark_node; } @@ -693,8 +693,8 @@ build_dynamic_cast_1 (tree type, tree expr, tsubst_flags_t complain) { tree expr = throw_bad_cast (); if (complain & tf_warning) - warning (0, "dynamic_cast of %q#D to %q#T can never succeed", - old_expr, type); + warning (0, "%(%#D)%> can never succeed", + type, old_expr); /* Bash it to the expected type. */ TREE_TYPE (expr) = type; return expr; @@ -708,8 +708,8 @@ build_dynamic_cast_1 (tree type, tree expr, tsubst_flags_t complain) && TREE_CODE (TREE_TYPE (op)) == RECORD_TYPE) { if (complain & tf_warning) - warning (0, "dynamic_cast of %q#D to %q#T can never succeed", - op, type); + warning (0, "%(%#D)%> can never succeed", + type, op); retval = build_int_cst (type, 0); return retval; } @@ -798,7 +798,7 @@ build_dynamic_cast_1 (tree type, tree expr, tsubst_flags_t complain) fail: if (complain & tf_error) - error ("cannot dynamic_cast %qE (of type %q#T) to type %q#T (%s)", + error ("cannot % %qE (of type %q#T) to type %q#T (%s)", old_expr, TREE_TYPE (old_expr), type, errstr); return error_mark_node; } diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 38459342384..fc5edde89c3 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1585,7 +1585,7 @@ finish_asm_stmt (int volatile_p, tree string, tree output_operands, resolve the overloading. */ if (TREE_TYPE (operand) == unknown_type_node) { - error ("type of asm operand %qE could not be determined", + error ("type of % operand %qE could not be determined", TREE_VALUE (t)); operand = error_mark_node; } @@ -1667,7 +1667,7 @@ finish_label_decl (tree name) { if (!at_function_scope_p ()) { - error ("__label__ declarations are only allowed in function scopes"); + error ("%<__label__%> declarations are only allowed in function scopes"); return; } @@ -4099,7 +4099,7 @@ finish_bases (tree type, bool direct) if (!processing_template_decl) { /* Parameter packs can only be used in templates */ - error ("Parameter pack __bases only valid in template declaration"); + error ("parameter pack %<__bases%> only valid in template declaration"); return error_mark_node; } @@ -4164,7 +4164,7 @@ finish_offsetof (tree object_ptr, tree expr, location_t loc) && CLASS_TYPE_P (TREE_TYPE (TREE_TYPE (object_ptr))) && CLASSTYPE_NON_STD_LAYOUT (TREE_TYPE (TREE_TYPE (object_ptr))) && cp_unevaluated_operand == 0) - warning_at (loc, OPT_Winvalid_offsetof, "offsetof within " + warning_at (loc, OPT_Winvalid_offsetof, "% within " "non-standard-layout type %qT is conditionally-supported", TREE_TYPE (TREE_TYPE (object_ptr))); return fold_offsetof (expr); @@ -5546,8 +5546,8 @@ cp_check_omp_declare_reduction (tree udr) } else if (TYPE_QUALS_NO_ADDR_SPACE (type)) { - error_at (loc, "const, volatile or __restrict qualified type %qT in " - "%<#pragma omp declare reduction%>", type); + error_at (loc, "%, % or %<__restrict%>-qualified " + "type %qT in %<#pragma omp declare reduction%>", type); return; } @@ -9334,7 +9334,7 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p, && TYPE_P (TREE_OPERAND (expr, 0)))) { if (complain & tf_error) - error ("argument to decltype must be an expression"); + error ("argument to % must be an expression"); return error_mark_node; } @@ -9362,7 +9362,7 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p, if (type_unknown_p (expr)) { if (complain & tf_error) - error ("decltype cannot resolve address of overloaded function"); + error ("% cannot resolve address of overloaded function"); return error_mark_node; } diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 7b8889ea7b2..e61f583b174 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -4474,7 +4474,7 @@ handle_init_priority_attribute (tree* node, if (!initp_expr || TREE_CODE (initp_expr) != INTEGER_CST) { - error ("requested init_priority is not an integer constant"); + error ("requested % is not an integer constant"); cxx_constant_value (initp_expr); *no_add_attrs = true; return NULL_TREE; @@ -4504,7 +4504,8 @@ handle_init_priority_attribute (tree* node, if (pri > MAX_INIT_PRIORITY || pri <= 0) { - error ("requested init_priority is out of range"); + error ("requested % %i is out of range [0, %i]", + pri, MAX_INIT_PRIORITY); *no_add_attrs = true; return NULL_TREE; } @@ -4514,7 +4515,8 @@ handle_init_priority_attribute (tree* node, if (pri <= MAX_RESERVED_INIT_PRIORITY) { warning - (0, "requested init_priority is reserved for internal use"); + (0, "requested % %i is reserved for internal use", + pri); } if (SUPPORTS_INIT_PRIORITY) @@ -5479,7 +5481,7 @@ maybe_warn_zero_as_null_pointer_constant (tree expr, location_t loc) void lang_check_failed (const char* file, int line, const char* function) { - internal_error ("lang_* check: failed in %s, at %s:%d", + internal_error ("% check: failed in %s, at %s:%d", function, trim_filename (file), line); } #endif /* ENABLE_TREE_CHECKING */ diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 36e6b2474f0..7289f2c49fc 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -4887,7 +4887,7 @@ cp_build_binary_op (const op_location_t &location, && c_inhibit_evaluation_warnings == 0 && (FLOAT_TYPE_P (type0) || FLOAT_TYPE_P (type1))) warning (OPT_Wfloat_equal, - "comparing floating point with == or != is unsafe"); + "comparing floating point with %<==%> or % is unsafe"); if (complain & tf_warning) { tree stripped_orig_op0 = tree_strip_any_location_wrapper (orig_op0); @@ -6274,7 +6274,7 @@ cp_build_unary_op (enum tree_code code, tree xarg, bool noconvert, if (TREE_CODE (TREE_TYPE (arg)) == BOOLEAN_TYPE && (complain & tf_warning) && warning_at (location, OPT_Wbool_operation, - "%<~%> on an expression of type bool")) + "%<~%> on an expression of type %")) inform (location, "did you mean to use logical not (%)?"); arg = cp_perform_integral_promotions (arg, complain); } @@ -6942,13 +6942,15 @@ check_for_casting_away_constness (tree src_type, tree dest_type, case STATIC_CAST_EXPR: if (complain & tf_error) - error ("static_cast from type %qT to type %qT casts away qualifiers", + error ("% from type %qT to type %qT casts away " + "qualifiers", src_type, dest_type); return true; case REINTERPRET_CAST_EXPR: if (complain & tf_error) - error ("reinterpret_cast from type %qT to type %qT casts away qualifiers", + error ("% from type %qT to type %qT casts away " + "qualifiers", src_type, dest_type); return true; @@ -7401,7 +7403,7 @@ build_static_cast (tree type, tree oexpr, tsubst_flags_t complain) if (complain & tf_error) { - error ("invalid static_cast from type %qT to type %qT", + error ("invalid % from type %qT to type %qT", TREE_TYPE (expr), type); if ((TYPE_PTR_P (type) || TYPE_REF_P (type)) && CLASS_TYPE_P (TREE_TYPE (type)) @@ -7738,7 +7740,7 @@ build_const_cast_1 (tree dst_type, tree expr, tsubst_flags_t complain, if (!INDIRECT_TYPE_P (dst_type) && !TYPE_PTRDATAMEM_P (dst_type)) { if (complain & tf_error) - error ("invalid use of const_cast with type %qT, " + error ("invalid use of % with type %qT, " "which is not a pointer, " "reference, nor a pointer-to-data-member type", dst_type); return error_mark_node; @@ -7747,8 +7749,9 @@ build_const_cast_1 (tree dst_type, tree expr, tsubst_flags_t complain, if (TREE_CODE (TREE_TYPE (dst_type)) == FUNCTION_TYPE) { if (complain & tf_error) - error ("invalid use of const_cast with type %qT, which is a pointer " - "or reference to a function type", dst_type); + error ("invalid use of % with type %qT, " + "which is a pointer or reference to a function type", + dst_type); return error_mark_node; } @@ -7788,7 +7791,8 @@ build_const_cast_1 (tree dst_type, tree expr, tsubst_flags_t complain, else { if (complain & tf_error) - error ("invalid const_cast of an rvalue of type %qT to type %qT", + error ("invalid % of an rvalue of type %qT " + "to type %qT", src_type, dst_type); return error_mark_node; } @@ -7857,7 +7861,7 @@ build_const_cast_1 (tree dst_type, tree expr, tsubst_flags_t complain, } if (complain & tf_error) - error ("invalid const_cast from type %qT to type %qT", + error ("invalid % from type %qT to type %qT", src_type, dst_type); return error_mark_node; } @@ -9260,7 +9264,7 @@ maybe_warn_about_returning_address_of_local (tree retval) "returning reference to temporary"); else if (is_std_init_list (valtype)) warning_at (loc, OPT_Winit_list_lifetime, - "returning temporary initializer_list does not extend " + "returning temporary % does not extend " "the lifetime of the underlying array"); return true; } @@ -9298,7 +9302,7 @@ maybe_warn_about_returning_address_of_local (tree retval) whats_returned); else if (is_std_init_list (valtype)) w = warning_at (loc, OPT_Winit_list_lifetime, - "returning local initializer_list variable %qD " + "returning local % variable %qD " "does not extend the lifetime of the underlying array", whats_returned); else if (TREE_CODE (whats_returned) == LABEL_DECL) @@ -9654,7 +9658,7 @@ check_return_expr (tree retval, bool *no_warning) && ! flag_check_new && retval && null_ptr_cst_p (retval)) warning (0, "% must not return NULL unless it is " - "declared % (or -fcheck-new is in effect)"); + "declared % (or %<-fcheck-new%> is in effect)"); /* Effective C++ rule 15. See also start_function. */ if (warn_ecpp diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 618eed9a96d..e9f759d4213 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -360,7 +360,7 @@ abstract_virtuals_error_sfinae (tree decl, tree type, abstract_class_use use, "be used in throw-expression", type); break; case ACU_CATCH: - error ("cannot declare catch parameter to be of abstract " + error ("cannot declare % parameter to be of abstract " "class type %qT", type); break; default: @@ -380,7 +380,7 @@ abstract_virtuals_error_sfinae (tree decl, tree type, abstract_class_use use, FOR_EACH_VEC_ELT (*pure, ix, fn) if (! DECL_CLONED_FUNCTION_P (fn) || DECL_COMPLETE_DESTRUCTOR_P (fn)) - inform (DECL_SOURCE_LOCATION (fn), "\t%#qD", fn); + inform (DECL_SOURCE_LOCATION (fn), " %#qD", fn); /* Now truncate the vector. This leaves it non-null, so we know there are pure virtuals, but empty so we don't list them out @@ -1164,8 +1164,8 @@ digest_init_r (tree type, tree init, int nested, int flags, be invalid. */ if (size < TREE_STRING_LENGTH (stripped_init)) { - permerror (loc, "initializer-string for array " - "of chars is too long"); + permerror (loc, "initializer-string for %qT is too long", + type); init = build_string (size, TREE_STRING_POINTER (stripped_init)); @@ -2215,7 +2215,7 @@ build_functional_cast (tree exp, tree parms, tsubst_flags_t complain) if (type == error_mark_node) { if (complain & tf_error) - error ("cannot deduce template arguments for %qT from ()", + error ("cannot deduce template arguments for %qT from %<()%>", anode); return error_mark_node; }