From patchwork Thu Jun 10 23:26:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 1490682 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=FyxxF9+B; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G1Kr43WyZz9sSs for ; Fri, 11 Jun 2021 09:26:59 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EF30339BC04F for ; Thu, 10 Jun 2021 23:26:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EF30339BC04F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1623367615; bh=OANez0neQXZht9Vw3nw4IgfxRswLXcEfMr8xmZ3n22M=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=FyxxF9+BJ4DQHqLkaK2E3gSGZQc3UI4l8PqCHGHtRgLv6xAPePp8eTShduL0Xetp7 Bt1hGtFB1Q+DZX0ZMXQMHQ4K7rzsqNSBTOe0vcuBSvw4/+HeYTL5pIB7vYnP6CKvrb tuCZVUnHNfAq0YBSBWo/88G1gwvkCJUn8Cf/dhYg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-oo1-xc36.google.com (mail-oo1-xc36.google.com [IPv6:2607:f8b0:4864:20::c36]) by sourceware.org (Postfix) with ESMTPS id B8FAC385742F for ; Thu, 10 Jun 2021 23:26:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B8FAC385742F Received: by mail-oo1-xc36.google.com with SMTP id k10-20020a4abd8a0000b0290249ed2f2919so288473oop.4 for ; Thu, 10 Jun 2021 16:26:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=OANez0neQXZht9Vw3nw4IgfxRswLXcEfMr8xmZ3n22M=; b=s2zV3BMDTYRwT4NruDz7yBB3MYssFgFqsiYBGd2xFXPXZR9ft/FEmJH259x9Ctxnwz 0BgV4GLJqbxXBQRKulOgC2lA9mZAPoNH/rDyvd0R25OlkYX9nIvllez7tszgOWwmNUqd Y9sPOz91sbVFJA4403Cwfj7DjPn6ObWFMyNjeLRLLzT02QAGOsQeVC8MMozo9RmaHUge km+E2vOUROowjzHPLvlFq4AWDEp+RHJo+DYRvNBaNo9i8L7iIeKCvheEFBsk8xnUyCNJ Khpl+aRmq2UxnWpwwDpiPdXAVj62cPKwHjKA/0oJyFDp/a4COPcJODjfO1EBGzWvL13r whbg== X-Gm-Message-State: AOAM530Ld3g6b86BWDAWUMZK/HTjV35ModIg9+5sMbH+MJ2cOv4ITCbm zAd29aO1lV/PS+vjeL10LExPHf3pWhg= X-Google-Smtp-Source: ABdhPJymDTcabf5ASXHkfkHdA52xkH88U/gRQC6uHGLHExWrtxbNsscINthuVYCjgRwIQ2yva9deag== X-Received: by 2002:a4a:d199:: with SMTP id j25mr720388oor.43.1623367590866; Thu, 10 Jun 2021 16:26:30 -0700 (PDT) Received: from [192.168.0.41] (97-118-122-241.hlrn.qwest.net. [97.118.122.241]) by smtp.gmail.com with ESMTPSA id e83sm834448oia.40.2021.06.10.16.26.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 10 Jun 2021 16:26:30 -0700 (PDT) Subject: [PATCH 1/4] introduce diagnostic infrastructure changes (PR 98512) To: David Malcolm , gcc-patches References: <2e49b6c6-a403-a207-c41e-58f78df96b84@gmail.com> <945093c7-de5e-0350-6030-e4e79ea41161@gmail.com> <5aff247f-dfcb-cecf-e07e-b5fca877f911@gmail.com> Message-ID: Date: Thu, 10 Jun 2021 17:26:29 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <5aff247f-dfcb-cecf-e07e-b5fca877f911@gmail.com> Content-Language: en-US X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Martin Sebor via Gcc-patches From: Martin Sebor Reply-To: Martin Sebor Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This diff introduces the diagnostic infrastructure changes to support controlling warnings at any call site in the inlining stack and printing the inlining context without the %K and %G directives. Improve warning suppression for inlined functions. Resolves: PR middle-end/98871 - Cannot silence -Wmaybe-uninitialized at declaration site PR middle-end/98512 - #pragma GCC diagnostic ignored ineffective in conjunction with alias attribute gcc/ChangeLog: * diagnostic.c (update_inlining_context): New. (update_effective_level_from_pragmas): Handle inlining context. (diagnostic_report_diagnostic): Same. * diagnostic.h (struct diagnostic_info): Add ctor. (struct diagnostic_context): Add members. * tree-diagnostic.c (get_inlining_locations): New. (set_inlining_location): New. (tree_diagnostics_defaults): Set new callback pointers. diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index d58586f2526..d1c8c655f7a 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -991,51 +991,92 @@ print_parseable_fixits (pretty_printer *pp, rich_location *richloc, pp_set_prefix (pp, saved_prefix); } -/* Update the diag_class of DIAGNOSTIC based on its location - relative to any +/* Update the inlininig context in CONTEXT for a DIAGNOSTIC. */ + +static void +update_inlining_context (diagnostic_context *context, + diagnostic_info *diagnostic) +{ + context->ictx.reset (); + + auto &ilocs = context->ictx.ilocs; + + if (context->get_locations_cb) + /* Retrieve the locations into which the expression about to be + diagnosed has been inlined, including those of all the callers + all the way down the inlining stack. */ + context->get_locations_cb (context, diagnostic); + else + { + /* When there's no metadata use just the one location provided + by the caller of the diagnostic function. */ + location_t loc = diagnostic_location (diagnostic); + ilocs.safe_push (loc); + context->ictx.allsyslocs = in_system_header_at (loc); + } +} + +/* Update the kind of DIAGNOSTIC based on its location(s), including + any of those in its inlining context, relative to any #pragma GCC diagnostic directives recorded within CONTEXT. - Return the new diag_class of DIAGNOSTIC if it was updated, or - DK_UNSPECIFIED otherwise. */ + Return the new kind of DIAGNOSTIC if it was updated, or DK_UNSPECIFIED + otherwise. */ static diagnostic_t update_effective_level_from_pragmas (diagnostic_context *context, diagnostic_info *diagnostic) { - diagnostic_t diag_class = DK_UNSPECIFIED; - - if (context->n_classification_history > 0) + if (context->ictx.allsyslocs && !context->dc_warn_system_headers) { - location_t location = diagnostic_location (diagnostic); + /* Ignore the diagnostic if all the inlined locations are + in system headers and -Wno-system-headers is in effect. */ + diagnostic->kind = DK_IGNORED; + return DK_IGNORED; + } + + if (context->n_classification_history <= 0) + return DK_UNSPECIFIED; + + auto &ilocs = context->ictx.ilocs; + /* Iterate over the locations, checking the diagnostic disposition + for the diagnostic at each. If it's explicitly set as opposed + to unspecified, update the disposition for this instance of + the diagnostic and return it. */ + for (unsigned idx = 0; idx < ilocs.length (); ++idx) + { /* FIXME: Stupid search. Optimize later. */ for (int i = context->n_classification_history - 1; i >= 0; i --) { - if (linemap_location_before_p - (line_table, - context->classification_history[i].location, - location)) + const diagnostic_classification_change_t &hist + = context->classification_history[i]; + + location_t pragloc = hist.location; + if (!linemap_location_before_p (line_table, pragloc, ilocs[idx])) + continue; + + if (hist.kind == (int) DK_POP) { - if (context->classification_history[i].kind == (int) DK_POP) - { - i = context->classification_history[i].option; - continue; - } - int option = context->classification_history[i].option; - /* The option 0 is for all the diagnostics. */ - if (option == 0 || option == diagnostic->option_index) - { - diag_class = context->classification_history[i].kind; - if (diag_class != DK_UNSPECIFIED) - diagnostic->kind = diag_class; - break; - } + /* Move on to the next region. */ + i = hist.option; + continue; + } + + int option = hist.option; + /* The option 0 is for all the diagnostics. */ + if (option == 0 || option == diagnostic->option_index) + { + diagnostic_t kind = hist.kind; + if (kind != DK_UNSPECIFIED) + diagnostic->kind = kind; + return kind; } } } - return diag_class; + return DK_UNSPECIFIED; } /* Generate a URL string describing CWE. The caller is responsible for @@ -1129,6 +1170,9 @@ static bool diagnostic_enabled (diagnostic_context *context, diagnostic_info *diagnostic) { + /* Update the inlining context for this diagnostic. */ + update_inlining_context (context, diagnostic); + /* Diagnostics with no option or -fpermissive are always enabled. */ if (!diagnostic->option_index || diagnostic->option_index == permissive_error_option (context)) @@ -1194,9 +1238,17 @@ diagnostic_report_diagnostic (diagnostic_context *context, /* Give preference to being able to inhibit warnings, before they get reclassified to something else. */ - if ((diagnostic->kind == DK_WARNING || diagnostic->kind == DK_PEDWARN) - && !diagnostic_report_warnings_p (context, location)) - return false; + bool report_warning_p = true; + if (diagnostic->kind == DK_WARNING || diagnostic->kind == DK_PEDWARN) + { + if (context->dc_inhibit_warnings) + return false; + /* Remember the result of the overall system header warning setting + but proceed to also check the inlining context. */ + report_warning_p = diagnostic_report_warnings_p (context, location); + if (!report_warning_p && diagnostic->kind == DK_PEDWARN) + return false; + } if (diagnostic->kind == DK_PEDWARN) { @@ -1204,7 +1256,7 @@ diagnostic_report_diagnostic (diagnostic_context *context, /* We do this to avoid giving the message for -pedantic-errors. */ orig_diag_kind = diagnostic->kind; } - + if (diagnostic->kind == DK_NOTE && context->inhibit_notes_p) return false; @@ -1228,9 +1280,17 @@ diagnostic_report_diagnostic (diagnostic_context *context, && diagnostic->kind == DK_WARNING) diagnostic->kind = DK_ERROR; + /* Check to see if the diagnostic is enabled at the location and + not disabled by #pragma GCC diagnostic anywhere along the inlining + stack. . */ if (!diagnostic_enabled (context, diagnostic)) return false; + if (!report_warning_p && context->ictx.allsyslocs) + /* Bail if the warning is not to be reported because all locations + in the inlining stack (if there is one) are in system headers. */ + return false; + if (diagnostic->kind != DK_NOTE && diagnostic->kind != DK_ICE) diagnostic_check_max_errors (context); @@ -1270,8 +1330,14 @@ diagnostic_report_diagnostic (diagnostic_context *context, } context->diagnostic_group_emission_count++; + /* Move X_DATA into DIAGNOSTIC->MESSAGE before setting inlining context + abstract origin and location. It uses X_DATA. */ diagnostic->message.x_data = &diagnostic->x_data; diagnostic->x_data = NULL; + + if (context->set_location_cb) + context->set_location_cb (context, diagnostic); + pp_format (context->printer, &diagnostic->message); (*diagnostic_starter (context)) (context, diagnostic); pp_output_formatted_text (context->printer); diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h index 1b9d6b1f64d..b95ee23dda0 100644 --- a/gcc/diagnostic.h +++ b/gcc/diagnostic.h @@ -87,6 +87,10 @@ enum diagnostics_extra_output_kind list in diagnostic.def. */ struct diagnostic_info { + diagnostic_info () + : message (), richloc (), metadata (), x_data (), kind (), option_index () + { } + /* Text to be formatted. */ text_info message; @@ -343,6 +347,32 @@ struct diagnostic_context /* Callback for final cleanup. */ void (*final_cb) (diagnostic_context *context); + + /* The inlining context of the diagnostic (may have just one + element if a diagnostic is not for an inlined expression). */ + struct inlining_ctx + { + void reset () + { + ilocs.release (); + loc = UNKNOWN_LOCATION; + ao = NULL; + allsyslocs = false; + } + + /* Locations along the inlining stack. */ + auto_vec ilocs; + /* The locus of the diagnostic. */ + location_t loc; + /* The abstract origin of the location. */ + void *ao; + /* Set of every ILOCS element is in a system header. */ + bool allsyslocs; + } ictx; + + /* Callbacks to get and set the inlining context. */ + void (*get_locations_cb)(diagnostic_context *, diagnostic_info *); + void (*set_location_cb)(const diagnostic_context *, diagnostic_info *); }; static inline void diff --git a/gcc/tree-diagnostic.c b/gcc/tree-diagnostic.c index 95b8ef30070..a8c5484849a 100644 --- a/gcc/tree-diagnostic.c +++ b/gcc/tree-diagnostic.c @@ -305,6 +305,84 @@ default_tree_printer (pretty_printer *pp, text_info *text, const char *spec, return true; } +/* Get the inlining stack corresponding to the DIAGNOSTIC location. */ + +static void +get_inlining_locations (diagnostic_context *context, + diagnostic_info *diagnostic) +{ + context->ictx.reset (); + + location_t loc = diagnostic_location (diagnostic); + tree block = LOCATION_BLOCK (loc); + + /* Count the number of locations in system headers. When all are, + warnings are suppressed by -Wno-system-headers. Otherwise, they + involve some user code, possibly inlined into a function in a system + header, and are not treated as coming from system headers. */ + unsigned nsyslocs = 0; + + while (block && TREE_CODE (block) == BLOCK + && BLOCK_ABSTRACT_ORIGIN (block)) + { + tree ao = BLOCK_ABSTRACT_ORIGIN (block); + if (TREE_CODE (ao) == FUNCTION_DECL) + { + if (!context->ictx.ao) + context->ictx.ao = block; + + location_t loc = BLOCK_SOURCE_LOCATION (block); + context->ictx.ilocs.safe_push (loc); + if (in_system_header_at (loc)) + ++nsyslocs; + } + else if (TREE_CODE (ao) != BLOCK) + break; + + block = BLOCK_SUPERCONTEXT (block); + } + + if (context->ictx.ilocs.length ()) + { + /* When there is an inlining context use the macro expansion + location for the original location and bump up NSYSLOCS if + it's in a system header since it's not counted above. */ + context->ictx.loc = expansion_point_location_if_in_system_header (loc); + if (context->ictx.loc != loc) + ++nsyslocs; + } + else + { + /* When there's no inlining context use the original location + and set NSYSLOCS accordingly. */ + context->ictx.loc = loc; + nsyslocs = in_system_header_at (loc) != 0; + } + + context->ictx.ilocs.safe_push (context->ictx.loc); + + /* Set if all locations are in a system header. */ + context->ictx.allsyslocs = nsyslocs == context->ictx.ilocs.length ();; +} + +/* Set the inlining location for to the DIAGNOSTIC based on the saved + inlining context. */ + +static void +set_inlining_location (const diagnostic_context *context, + diagnostic_info *diagnostic) +{ + if (!pp_ti_abstract_origin (&diagnostic->message) + || !context->ictx.ao + || context->ictx.loc == UNKNOWN_LOCATION) + /* Do nothing when there's no inlining context. */ + return; + + *pp_ti_abstract_origin (&diagnostic->message) = (tree)context->ictx.ao; + diagnostic->message.set_location (0, context->ictx.loc, + SHOW_RANGE_WITH_CARET); +} + /* Sets CONTEXT to use language independent diagnostics. */ void tree_diagnostics_defaults (diagnostic_context *context) @@ -314,4 +392,6 @@ tree_diagnostics_defaults (diagnostic_context *context) diagnostic_format_decoder (context) = default_tree_printer; context->print_path = default_tree_diagnostic_path_printer; context->make_json_for_path = default_tree_make_json_for_path; + context->get_locations_cb = get_inlining_locations; + context->set_location_cb = set_inlining_location; } From patchwork Thu Jun 10 23:27:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 1490683 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=AjLNxB3v; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G1KsJ4dmxz9sW4 for ; Fri, 11 Jun 2021 09:28:04 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5345139BC071 for ; Thu, 10 Jun 2021 23:28:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5345139BC071 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1623367682; bh=NrgfvFuOBGDlfBBEGedTVcYFUjC+GkSFwSP46tFGlPQ=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=AjLNxB3vkmLw8xgQ7anZhGQxdpwJ8q+L2MXb+gnZA6hgPC319Y3OKcVnNyk9utj7I ygMJWQgbydoNBPgrscT37Yw8NO1ZquIaU6EJS3/ohn1ooSI8n0MXuvdhKZpsDbj3dl C2uVTwVhoqeI+YaKP8OYyRJ1nXhyiEq/vvmqTlAU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) by sourceware.org (Postfix) with ESMTPS id 2B7CF39BC06B for ; Thu, 10 Jun 2021 23:27:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2B7CF39BC06B Received: by mail-ot1-x329.google.com with SMTP id i12-20020a05683033ecb02903346fa0f74dso1381346otu.10 for ; Thu, 10 Jun 2021 16:27:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=NrgfvFuOBGDlfBBEGedTVcYFUjC+GkSFwSP46tFGlPQ=; b=mFfVUNOWsELrpT0Bx+D3qIeo2Q8iUBtwE+dXf9A7bR6Zi4VnvoOhntCs2YYPSKXYE/ x0uWovp2Jbk8eLWLQ0polCZ3Gj52m+UUjGzuZyJX/HJjZDgW0efqJK7ILJkPz6XUVqte LmvBPro4MTm/071He3lB6uZo9yd1X+PByE6CybU3ETbNmGjEQE8vYXFXzAseh7Gfgxvg B0sTqIApNiiHw2rf2Po8Rse1BBa7CrnnUDhmz+R+WwYDhlpVXzITfVrBQPRZVoYjlqQz LTMNiWT1xUiKEAjDYF8ZBboQiwHgH0OvWtoJdIYOuXDglsOtX8kXmvy0nbYtlOZ84r2X gIbw== X-Gm-Message-State: AOAM532O1U5p7DtXWubPzrqhIk3/3pRJpTZJTg50Uqzzvlwu5TINsD0X 5oErS1Cny4wleff/7MdlJiQiDyJL+Z4= X-Google-Smtp-Source: ABdhPJyOwFfs+x7nucdpqYeDjOCHHsHHbLq+0Iwq2ObQ+wiqZUbM8MHviIs8N80YkDIWCXtWctvGvA== X-Received: by 2002:a9d:6081:: with SMTP id m1mr626315otj.226.1623367630530; Thu, 10 Jun 2021 16:27:10 -0700 (PDT) Received: from [192.168.0.41] (97-118-122-241.hlrn.qwest.net. [97.118.122.241]) by smtp.gmail.com with ESMTPSA id e83sm834750oia.40.2021.06.10.16.27.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 10 Jun 2021 16:27:10 -0700 (PDT) Subject: [PATCH 2/4] remove %G and %K from calls in front end and middle end (PR 98512) To: David Malcolm , gcc-patches References: <2e49b6c6-a403-a207-c41e-58f78df96b84@gmail.com> <945093c7-de5e-0350-6030-e4e79ea41161@gmail.com> <5aff247f-dfcb-cecf-e07e-b5fca877f911@gmail.com> Message-ID: <36e75bb4-2c3c-5b3a-9fe1-9cdb046666a3@gmail.com> Date: Thu, 10 Jun 2021 17:27:09 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <5aff247f-dfcb-cecf-e07e-b5fca877f911@gmail.com> Content-Language: en-US X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Martin Sebor via Gcc-patches From: Martin Sebor Reply-To: Martin Sebor Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This diff removes the uses of %G and %K from all warning_at() calls throughout GCC front end and middle end. The inlining context is included in diagnostic output whenever it's present. Improve warning suppression for inlined functions. Resolves: PR middle-end/98871 - Cannot silence -Wmaybe-uninitialized at declaration site PR middle-end/98512 - #pragma GCC diagnostic ignored ineffective in conjunction with alias attribute gcc/ChangeLog: * builtins.c (warn_string_no_nul): Remove %G. (maybe_warn_for_bound): Same. (warn_for_access): Same. (check_access): Same. (check_strncat_sizes): Same. (expand_builtin_strncat): Same. (expand_builtin_strncmp): Same. (expand_builtin): Same. (expand_builtin_object_size): Same. (warn_dealloc_offset): Same. (maybe_emit_free_warning): Same. * calls.c (maybe_warn_alloc_args_overflow): Same. (maybe_warn_nonstring_arg): Same. (maybe_warn_rdwr_sizes): Same. * expr.c (expand_expr_real_1): Remove %K. * gimple-fold.c (gimple_fold_builtin_strncpy): Remove %G. (gimple_fold_builtin_strncat): Same. * gimple-ssa-sprintf.c (format_directive): Same. (handle_printf_call): Same. * gimple-ssa-warn-alloca.c (pass_walloca::execute): Same. * gimple-ssa-warn-restrict.c (maybe_diag_overlap): Same. (maybe_diag_access_bounds): Same. Call gimple_location. (check_bounds_or_overlap): Same. * trans-mem.c (ipa_tm_scan_irr_block): Remove %K. Simplify. * tree-ssa-ccp.c (pass_post_ipa_warn::execute): Remove %G. * tree-ssa-strlen.c (maybe_warn_overflow): Same. (maybe_diag_stxncpy_trunc): Same. (handle_builtin_stxncpy_strncat): Same. (maybe_warn_pointless_strcmp): Same. * tree-ssa-uninit.c (maybe_warn_operand): Same. gcc/testsuite/ChangeLog: * gcc.dg/Wfree-nonheap-object-4.c: Tighten up. * gcc.dg/Wobjsize-1.c: Prune expected output. * gcc.dg/Warray-bounds-71.c: New test. * gcc.dg/Warray-bounds-71.h: New test. * gcc.dg/Warray-bounds-72.c: New test. * gcc.dg/Warray-bounds-73.c: New test. * gcc.dg/Warray-bounds-74.c: New test. * gcc.dg/Warray-bounds-75.c: New test. * gcc.dg/Wfree-nonheap-object-5.c: New test. * gcc.dg/pragma-diag-10.c: New test. * gcc.dg/pragma-diag-9.c: New test. * gcc.dg/uninit-suppress_3.c: New test. diff --git a/gcc/builtins.c b/gcc/builtins.c index af1fe49bb48..96997b7edc8 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -1124,30 +1124,30 @@ warn_string_no_nul (location_t loc, tree expr, const char *fname, { if (wi::ltu_p (maxsiz, bndrng[0])) warned = warning_at (loc, OPT_Wstringop_overread, - "%K%qD specified bound %s exceeds " + "%qD specified bound %s exceeds " "maximum object size %E", - expr, func, bndstr, maxobjsize); + func, bndstr, maxobjsize); else { bool maybe = wi::to_wide (size) == bndrng[0]; warned = warning_at (loc, OPT_Wstringop_overread, exact - ? G_("%K%qD specified bound %s exceeds " + ? G_("%qD specified bound %s exceeds " "the size %E of unterminated array") : (maybe - ? G_("%K%qD specified bound %s may " + ? G_("%qD specified bound %s may " "exceed the size of at most %E " "of unterminated array") - : G_("%K%qD specified bound %s exceeds " + : G_("%qD specified bound %s exceeds " "the size of at most %E " "of unterminated array")), - expr, func, bndstr, size); + func, bndstr, size); } } else warned = warning_at (loc, OPT_Wstringop_overread, - "%K%qD argument missing terminating nul", - expr, func); + "%qD argument missing terminating nul", + func); } else { @@ -3967,35 +3967,34 @@ maybe_warn_for_bound (int opt, location_t loc, tree exp, tree func, warned = (func ? warning_at (loc, opt, (maybe - ? G_("%K%qD specified bound %E may " + ? G_("%qD specified bound %E may " "exceed maximum object size %E") - : G_("%K%qD specified bound %E " + : G_("%qD specified bound %E " "exceeds maximum object size %E")), - exp, func, bndrng[0], maxobjsize) + func, bndrng[0], maxobjsize) : warning_at (loc, opt, (maybe - ? G_("%Kspecified bound %E may " + ? G_("specified bound %E may " "exceed maximum object size %E") - : G_("%Kspecified bound %E " + : G_("specified bound %E " "exceeds maximum object size %E")), - exp, bndrng[0], maxobjsize)); + bndrng[0], maxobjsize)); else warned = (func ? warning_at (loc, opt, (maybe - ? G_("%K%qD specified bound [%E, %E] may " + ? G_("%qD specified bound [%E, %E] may " "exceed maximum object size %E") - : G_("%K%qD specified bound [%E, %E] " + : G_("%qD specified bound [%E, %E] " "exceeds maximum object size %E")), - exp, func, - bndrng[0], bndrng[1], maxobjsize) + func, bndrng[0], bndrng[1], maxobjsize) : warning_at (loc, opt, (maybe - ? G_("%Kspecified bound [%E, %E] may " + ? G_("specified bound [%E, %E] may " "exceed maximum object size %E") - : G_("%Kspecified bound [%E, %E] " + : G_("specified bound [%E, %E] " "exceeds maximum object size %E")), - exp, bndrng[0], bndrng[1], maxobjsize)); + bndrng[0], bndrng[1], maxobjsize)); } else if (!size || tree_int_cst_le (bndrng[0], size)) return false; @@ -4003,34 +4002,34 @@ maybe_warn_for_bound (int opt, location_t loc, tree exp, tree func, warned = (func ? warning_at (loc, opt, (maybe - ? G_("%K%qD specified bound %E may exceed " + ? G_("%qD specified bound %E may exceed " "source size %E") - : G_("%K%qD specified bound %E exceeds " + : G_("%qD specified bound %E exceeds " "source size %E")), - exp, func, bndrng[0], size) + func, bndrng[0], size) : warning_at (loc, opt, (maybe - ? G_("%Kspecified bound %E may exceed " + ? G_("specified bound %E may exceed " "source size %E") - : G_("%Kspecified bound %E exceeds " + : G_("specified bound %E exceeds " "source size %E")), - exp, bndrng[0], size)); + bndrng[0], size)); else warned = (func ? warning_at (loc, opt, (maybe - ? G_("%K%qD specified bound [%E, %E] may " + ? G_("%qD specified bound [%E, %E] may " "exceed source size %E") - : G_("%K%qD specified bound [%E, %E] exceeds " + : G_("%qD specified bound [%E, %E] exceeds " "source size %E")), - exp, func, bndrng[0], bndrng[1], size) + func, bndrng[0], bndrng[1], size) : warning_at (loc, opt, (maybe - ? G_("%Kspecified bound [%E, %E] may exceed " + ? G_("specified bound [%E, %E] may exceed " "source size %E") - : G_("%Kspecified bound [%E, %E] exceeds " + : G_("specified bound [%E, %E] exceeds " "source size %E")), - exp, bndrng[0], bndrng[1], size)); + bndrng[0], bndrng[1], size)); if (warned) { if (pad && pad->src.ref) @@ -4055,35 +4054,34 @@ maybe_warn_for_bound (int opt, location_t loc, tree exp, tree func, warned = (func ? warning_at (loc, opt, (maybe - ? G_("%K%qD specified size %E may " + ? G_("%qD specified size %E may " "exceed maximum object size %E") - : G_("%K%qD specified size %E " + : G_("%qD specified size %E " "exceeds maximum object size %E")), - exp, func, bndrng[0], maxobjsize) + func, bndrng[0], maxobjsize) : warning_at (loc, opt, (maybe - ? G_("%Kspecified size %E may exceed " + ? G_("specified size %E may exceed " "maximum object size %E") - : G_("%Kspecified size %E exceeds " + : G_("specified size %E exceeds " "maximum object size %E")), - exp, bndrng[0], maxobjsize)); + bndrng[0], maxobjsize)); else warned = (func ? warning_at (loc, opt, (maybe - ? G_("%K%qD specified size between %E and %E " + ? G_("%qD specified size between %E and %E " "may exceed maximum object size %E") - : G_("%K%qD specified size between %E and %E " + : G_("%qD specified size between %E and %E " "exceeds maximum object size %E")), - exp, func, - bndrng[0], bndrng[1], maxobjsize) + func, bndrng[0], bndrng[1], maxobjsize) : warning_at (loc, opt, (maybe - ? G_("%Kspecified size between %E and %E " + ? G_("specified size between %E and %E " "may exceed maximum object size %E") - : G_("%Kspecified size between %E and %E " + : G_("specified size between %E and %E " "exceeds maximum object size %E")), - exp, bndrng[0], bndrng[1], maxobjsize)); + bndrng[0], bndrng[1], maxobjsize)); } else if (!size || tree_int_cst_le (bndrng[0], size)) return false; @@ -4091,34 +4089,34 @@ maybe_warn_for_bound (int opt, location_t loc, tree exp, tree func, warned = (func ? warning_at (loc, OPT_Wstringop_overflow_, (maybe - ? G_("%K%qD specified bound %E may exceed " + ? G_("%qD specified bound %E may exceed " "destination size %E") - : G_("%K%qD specified bound %E exceeds " + : G_("%qD specified bound %E exceeds " "destination size %E")), - exp, func, bndrng[0], size) + func, bndrng[0], size) : warning_at (loc, OPT_Wstringop_overflow_, (maybe - ? G_("%Kspecified bound %E may exceed " + ? G_("specified bound %E may exceed " "destination size %E") - : G_("%Kspecified bound %E exceeds " + : G_("specified bound %E exceeds " "destination size %E")), - exp, bndrng[0], size)); + bndrng[0], size)); else warned = (func ? warning_at (loc, OPT_Wstringop_overflow_, (maybe - ? G_("%K%qD specified bound [%E, %E] may exceed " + ? G_("%qD specified bound [%E, %E] may exceed " "destination size %E") - : G_("%K%qD specified bound [%E, %E] exceeds " + : G_("%qD specified bound [%E, %E] exceeds " "destination size %E")), - exp, func, bndrng[0], bndrng[1], size) + func, bndrng[0], bndrng[1], size) : warning_at (loc, OPT_Wstringop_overflow_, (maybe - ? G_("%Kspecified bound [%E, %E] exceeds " + ? G_("specified bound [%E, %E] exceeds " "destination size %E") - : G_("%Kspecified bound [%E, %E] exceeds " + : G_("specified bound [%E, %E] exceeds " "destination size %E")), - exp, bndrng[0], bndrng[1], size)); + bndrng[0], bndrng[1], size)); if (warned) { @@ -4156,65 +4154,63 @@ warn_for_access (location_t loc, tree func, tree exp, int opt, tree range[2], warned = (func ? warning_n (loc, opt, tree_to_uhwi (range[0]), (maybe - ? G_("%K%qD may access %E byte in a region " + ? G_("%qD may access %E byte in a region " "of size %E") - : G_("%K%qD accessing %E byte in a region " + : G_("%qD accessing %E byte in a region " "of size %E")), (maybe - ? G_ ("%K%qD may access %E bytes in a region " + ? G_ ("%qD may access %E bytes in a region " "of size %E") - : G_ ("%K%qD accessing %E bytes in a region " + : G_ ("%qD accessing %E bytes in a region " "of size %E")), - exp, func, range[0], size) + func, range[0], size) : warning_n (loc, opt, tree_to_uhwi (range[0]), (maybe - ? G_("%Kmay access %E byte in a region " + ? G_("may access %E byte in a region " "of size %E") - : G_("%Kaccessing %E byte in a region " + : G_("accessing %E byte in a region " "of size %E")), (maybe - ? G_("%Kmay access %E bytes in a region " + ? G_("may access %E bytes in a region " "of size %E") - : G_("%Kaccessing %E bytes in a region " + : G_("accessing %E bytes in a region " "of size %E")), - exp, range[0], size)); + range[0], size)); else if (tree_int_cst_sign_bit (range[1])) { /* Avoid printing the upper bound if it's invalid. */ warned = (func ? warning_at (loc, opt, (maybe - ? G_("%K%qD may access %E or more bytes " + ? G_("%qD may access %E or more bytes " "in a region of size %E") - : G_("%K%qD accessing %E or more bytes " + : G_("%qD accessing %E or more bytes " "in a region of size %E")), - exp, func, range[0], size) + func, range[0], size) : warning_at (loc, opt, (maybe - ? G_("%Kmay access %E or more bytes " + ? G_("may access %E or more bytes " "in a region of size %E") - : G_("%Kaccessing %E or more bytes " + : G_("accessing %E or more bytes " "in a region of size %E")), - exp, range[0], size)); + range[0], size)); } else warned = (func ? warning_at (loc, opt, (maybe - ? G_("%K%qD may access between %E and %E " + ? G_("%qD may access between %E and %E " "bytes in a region of size %E") - : G_("%K%qD accessing between %E and %E " + : G_("%qD accessing between %E and %E " "bytes in a region of size %E")), - exp, func, range[0], range[1], - size) + func, range[0], range[1], size) : warning_at (loc, opt, (maybe - ? G_("%Kmay access between %E and %E bytes " + ? G_("may access between %E and %E bytes " "in a region of size %E") - : G_("%Kaccessing between %E and %E bytes " + : G_("accessing between %E and %E bytes " "in a region of size %E")), - exp, range[0], range[1], - size)); + range[0], range[1], size)); return warned; } @@ -4224,69 +4220,67 @@ warn_for_access (location_t loc, tree func, tree exp, int opt, tree range[2], warned = (func ? warning_n (loc, opt, tree_to_uhwi (range[0]), (maybe - ? G_("%K%qD may write %E byte into a region " + ? G_("%qD may write %E byte into a region " "of size %E") - : G_("%K%qD writing %E byte into a region " + : G_("%qD writing %E byte into a region " "of size %E overflows the destination")), (maybe - ? G_("%K%qD may write %E bytes into a region " + ? G_("%qD may write %E bytes into a region " "of size %E") - : G_("%K%qD writing %E bytes into a region " + : G_("%qD writing %E bytes into a region " "of size %E overflows the destination")), - exp, func, range[0], size) + func, range[0], size) : warning_n (loc, opt, tree_to_uhwi (range[0]), (maybe - ? G_("%Kmay write %E byte into a region " + ? G_("may write %E byte into a region " "of size %E") - : G_("%Kwriting %E byte into a region " + : G_("writing %E byte into a region " "of size %E overflows the destination")), (maybe - ? G_("%Kmay write %E bytes into a region " + ? G_("may write %E bytes into a region " "of size %E") - : G_("%Kwriting %E bytes into a region " + : G_("writing %E bytes into a region " "of size %E overflows the destination")), - exp, range[0], size)); + range[0], size)); else if (tree_int_cst_sign_bit (range[1])) { /* Avoid printing the upper bound if it's invalid. */ warned = (func ? warning_at (loc, opt, (maybe - ? G_("%K%qD may write %E or more bytes " + ? G_("%qD may write %E or more bytes " "into a region of size %E") - : G_("%K%qD writing %E or more bytes " + : G_("%qD writing %E or more bytes " "into a region of size %E overflows " "the destination")), - exp, func, range[0], size) + func, range[0], size) : warning_at (loc, opt, (maybe - ? G_("%Kmay write %E or more bytes into " + ? G_("may write %E or more bytes into " "a region of size %E") - : G_("%Kwriting %E or more bytes into " + : G_("writing %E or more bytes into " "a region of size %E overflows " "the destination")), - exp, range[0], size)); + range[0], size)); } else warned = (func ? warning_at (loc, opt, (maybe - ? G_("%K%qD may write between %E and %E bytes " + ? G_("%qD may write between %E and %E bytes " "into a region of size %E") - : G_("%K%qD writing between %E and %E bytes " + : G_("%qD writing between %E and %E bytes " "into a region of size %E overflows " "the destination")), - exp, func, range[0], range[1], - size) + func, range[0], range[1], size) : warning_at (loc, opt, (maybe - ? G_("%Kmay write between %E and %E bytes " + ? G_("may write between %E and %E bytes " "into a region of size %E") - : G_("%Kwriting between %E and %E bytes " + : G_("writing between %E and %E bytes " "into a region of size %E overflows " "the destination")), - exp, range[0], range[1], - size)); + range[0], range[1], size)); return warned; } @@ -4297,64 +4291,64 @@ warn_for_access (location_t loc, tree func, tree exp, int opt, tree range[2], ? warning_n (loc, OPT_Wstringop_overread, tree_to_uhwi (range[0]), (maybe - ? G_("%K%qD may read %E byte from a region " + ? G_("%qD may read %E byte from a region " "of size %E") - : G_("%K%qD reading %E byte from a region " + : G_("%qD reading %E byte from a region " "of size %E")), (maybe - ? G_("%K%qD may read %E bytes from a region " + ? G_("%qD may read %E bytes from a region " "of size %E") - : G_("%K%qD reading %E bytes from a region " + : G_("%qD reading %E bytes from a region " "of size %E")), - exp, func, range[0], size) + func, range[0], size) : warning_n (loc, OPT_Wstringop_overread, tree_to_uhwi (range[0]), (maybe - ? G_("%Kmay read %E byte from a region " + ? G_("may read %E byte from a region " "of size %E") - : G_("%Kreading %E byte from a region " + : G_("reading %E byte from a region " "of size %E")), (maybe - ? G_("%Kmay read %E bytes from a region " + ? G_("may read %E bytes from a region " "of size %E") - : G_("%Kreading %E bytes from a region " + : G_("reading %E bytes from a region " "of size %E")), - exp, range[0], size)); + range[0], size)); else if (tree_int_cst_sign_bit (range[1])) { /* Avoid printing the upper bound if it's invalid. */ warned = (func ? warning_at (loc, OPT_Wstringop_overread, (maybe - ? G_("%K%qD may read %E or more bytes " + ? G_("%qD may read %E or more bytes " "from a region of size %E") - : G_("%K%qD reading %E or more bytes " + : G_("%qD reading %E or more bytes " "from a region of size %E")), - exp, func, range[0], size) + func, range[0], size) : warning_at (loc, OPT_Wstringop_overread, (maybe - ? G_("%Kmay read %E or more bytes " + ? G_("may read %E or more bytes " "from a region of size %E") - : G_("%Kreading %E or more bytes " + : G_("reading %E or more bytes " "from a region of size %E")), - exp, range[0], size)); + range[0], size)); } else warned = (func ? warning_at (loc, OPT_Wstringop_overread, (maybe - ? G_("%K%qD may read between %E and %E bytes " + ? G_("%qD may read between %E and %E bytes " "from a region of size %E") - : G_("%K%qD reading between %E and %E bytes " + : G_("%qD reading between %E and %E bytes " "from a region of size %E")), - exp, func, range[0], range[1], size) + func, range[0], range[1], size) : warning_at (loc, opt, (maybe - ? G_("%Kmay read between %E and %E bytes " + ? G_("may read between %E and %E bytes " "from a region of size %E") - : G_("%Kreading between %E and %E bytes " + : G_("reading between %E and %E bytes " "from a region of size %E")), - exp, range[0], range[1], size)); + range[0], range[1], size)); if (warned) TREE_NO_WARNING (exp) = true; @@ -4367,37 +4361,37 @@ warn_for_access (location_t loc, tree func, tree exp, int opt, tree range[2], warned = (func ? warning_n (loc, OPT_Wstringop_overread, tree_to_uhwi (range[0]), - "%K%qD expecting %E byte in a region of size %E", - "%K%qD expecting %E bytes in a region of size %E", - exp, func, range[0], size) + "%qD expecting %E byte in a region of size %E", + "%qD expecting %E bytes in a region of size %E", + func, range[0], size) : warning_n (loc, OPT_Wstringop_overread, tree_to_uhwi (range[0]), - "%Kexpecting %E byte in a region of size %E", - "%Kexpecting %E bytes in a region of size %E", - exp, range[0], size)); + "expecting %E byte in a region of size %E", + "expecting %E bytes in a region of size %E", + range[0], size)); else if (tree_int_cst_sign_bit (range[1])) { /* Avoid printing the upper bound if it's invalid. */ warned = (func ? warning_at (loc, OPT_Wstringop_overread, - "%K%qD expecting %E or more bytes in a region " + "%qD expecting %E or more bytes in a region " "of size %E", - exp, func, range[0], size) + func, range[0], size) : warning_at (loc, OPT_Wstringop_overread, - "%Kexpecting %E or more bytes in a region " + "expecting %E or more bytes in a region " "of size %E", - exp, range[0], size)); + range[0], size)); } else warned = (func ? warning_at (loc, OPT_Wstringop_overread, - "%K%qD expecting between %E and %E bytes in " + "%qD expecting between %E and %E bytes in " "a region of size %E", - exp, func, range[0], range[1], size) + func, range[0], range[1], size) : warning_at (loc, OPT_Wstringop_overread, - "%Kexpecting between %E and %E bytes in " + "expecting between %E and %E bytes in " "a region of size %E", - exp, range[0], range[1], size)); + range[0], range[1], size)); if (warned) TREE_NO_WARNING (exp) = true; @@ -4757,7 +4751,7 @@ check_access (tree exp, tree dstwrite, && TREE_CODE (range[0]) == INTEGER_CST && tree_int_cst_lt (maxobjsize, range[0])) { - location_t loc = tree_inlined_location (exp); + location_t loc = EXPR_LOCATION (exp); maybe_warn_for_bound (OPT_Wstringop_overflow_, loc, exp, func, range, NULL_TREE, pad); return false; @@ -4783,7 +4777,7 @@ check_access (tree exp, tree dstwrite, || (pad && pad->dst.ref && TREE_NO_WARNING (pad->dst.ref))) return false; - location_t loc = tree_inlined_location (exp); + location_t loc = EXPR_LOCATION (exp); bool warned = false; if (dstwrite == slen && at_least_one) { @@ -4792,15 +4786,15 @@ check_access (tree exp, tree dstwrite, at least one byte past the end of the destination. */ warned = (func ? warning_at (loc, OPT_Wstringop_overflow_, - "%K%qD writing %E or more bytes into " + "%qD writing %E or more bytes into " "a region of size %E overflows " "the destination", - exp, func, range[0], dstsize) + func, range[0], dstsize) : warning_at (loc, OPT_Wstringop_overflow_, - "%Kwriting %E or more bytes into " + "writing %E or more bytes into " "a region of size %E overflows " "the destination", - exp, range[0], dstsize)); + range[0], dstsize)); } else { @@ -4836,7 +4830,7 @@ check_access (tree exp, tree dstwrite, PAD is nonnull and BNDRNG is valid. */ get_size_range (maxread, range, pad ? pad->src.bndrng : NULL); - location_t loc = tree_inlined_location (exp); + location_t loc = EXPR_LOCATION (exp); tree size = dstsize; if (pad && pad->mode == access_read_only) size = wide_int_to_tree (sizetype, pad->src.sizrng[1]); @@ -4895,7 +4889,7 @@ check_access (tree exp, tree dstwrite, || (pad && pad->src.ref && TREE_NO_WARNING (pad->src.ref))) return false; - location_t loc = tree_inlined_location (exp); + location_t loc = EXPR_LOCATION (exp); const bool read = mode == access_read_only || mode == access_read_write; const bool maybe = pad && pad->dst.parmarray; @@ -6440,10 +6434,10 @@ check_strncat_sizes (tree exp, tree objsize) if (tree_fits_uhwi_p (maxread) && tree_fits_uhwi_p (objsize) && tree_int_cst_equal (objsize, maxread)) { - location_t loc = tree_inlined_location (exp); + location_t loc = EXPR_LOCATION (exp); warning_at (loc, OPT_Wstringop_overflow_, - "%K%qD specified bound %E equals destination size", - exp, get_callee_fndecl (exp), maxread); + "%qD specified bound %E equals destination size", + get_callee_fndecl (exp), maxread); return false; } @@ -6513,10 +6507,10 @@ expand_builtin_strncat (tree exp, rtx) if (tree_fits_uhwi_p (maxread) && tree_fits_uhwi_p (destsize) && tree_int_cst_equal (destsize, maxread)) { - location_t loc = tree_inlined_location (exp); + location_t loc = EXPR_LOCATION (exp); warning_at (loc, OPT_Wstringop_overflow_, - "%K%qD specified bound %E equals destination size", - exp, get_callee_fndecl (exp), maxread); + "%qD specified bound %E equals destination size", + get_callee_fndecl (exp), maxread); return NULL_RTX; } @@ -7289,7 +7283,7 @@ expand_builtin_strncmp (tree exp, ATTRIBUTE_UNUSED rtx target, || !check_nul_terminated_array (exp, arg2, arg3)) return NULL_RTX; - location_t loc = tree_inlined_location (exp); + location_t loc = EXPR_LOCATION (exp); tree len1 = c_strlen (arg1, 1); tree len2 = c_strlen (arg2, 1); @@ -9966,13 +9960,13 @@ expand_builtin (tree exp, rtx target, rtx subtarget, machine_mode mode, case BUILT_IN_VA_ARG_PACK: /* All valid uses of __builtin_va_arg_pack () are removed during inlining. */ - error ("%Kinvalid use of %<__builtin_va_arg_pack ()%>", exp); + error ("invalid use of %<__builtin_va_arg_pack ()%>"); return const0_rtx; case BUILT_IN_VA_ARG_PACK_LEN: /* All valid uses of __builtin_va_arg_pack_len () are removed during inlining. */ - error ("%Kinvalid use of %<__builtin_va_arg_pack_len ()%>", exp); + error ("invalid use of %<__builtin_va_arg_pack_len ()%>"); return const0_rtx; /* Return the address of the first anonymous stack arg. */ @@ -12921,8 +12915,8 @@ expand_builtin_object_size (tree exp) if (!validate_arglist (exp, POINTER_TYPE, INTEGER_TYPE, VOID_TYPE)) { - error ("%Kfirst argument of %qD must be a pointer, second integer constant", - exp, fndecl); + error ("first argument of %qD must be a pointer, second integer constant", + fndecl); expand_builtin_trap (); return const0_rtx; } @@ -12934,8 +12928,8 @@ expand_builtin_object_size (tree exp) || tree_int_cst_sgn (ost) < 0 || compare_tree_int (ost, 3) > 0) { - error ("%Klast argument of %qD is not integer constant between 0 and 3", - exp, fndecl); + error ("last argument of %qD is not integer constant between 0 and 3", + fndecl); expand_builtin_trap (); return const0_rtx; } @@ -13737,8 +13731,8 @@ warn_dealloc_offset (location_t loc, tree exp, const access_ref &aref) } if (!warning_at (loc, OPT_Wfree_nonheap_object, - "%K%qD called on pointer %qE with nonzero offset%s", - exp, dealloc_decl, aref.ref, offstr)) + "%qD called on pointer %qE with nonzero offset%s", + dealloc_decl, aref.ref, offstr)) return false; if (DECL_P (aref.ref)) @@ -13793,15 +13787,15 @@ maybe_emit_free_warning (tree exp) return; tree dealloc_decl = get_callee_fndecl (exp); - location_t loc = tree_inlined_location (exp); + location_t loc = EXPR_LOCATION (exp); if (DECL_P (ref) || EXPR_P (ref)) { /* Diagnose freeing a declared object. */ if (aref.ref_declared () && warning_at (loc, OPT_Wfree_nonheap_object, - "%K%qD called on unallocated object %qD", - exp, dealloc_decl, ref)) + "%qD called on unallocated object %qD", + dealloc_decl, ref)) { loc = (DECL_P (ref) ? DECL_SOURCE_LOCATION (ref) @@ -13820,8 +13814,8 @@ maybe_emit_free_warning (tree exp) else if (CONSTANT_CLASS_P (ref)) { if (warning_at (loc, OPT_Wfree_nonheap_object, - "%K%qD called on a pointer to an unallocated " - "object %qE", exp, dealloc_decl, ref)) + "%qD called on a pointer to an unallocated " + "object %qE", dealloc_decl, ref)) { if (TREE_CODE (ptr) == SSA_NAME) { @@ -13858,18 +13852,18 @@ maybe_emit_free_warning (tree exp) ? OPT_Wmismatched_new_delete : OPT_Wmismatched_dealloc); warned = warning_at (loc, opt, - "%K%qD called on pointer returned " + "%qD called on pointer returned " "from a mismatched allocation " - "function", exp, dealloc_decl); + "function", dealloc_decl); } } else if (gimple_call_builtin_p (def_stmt, BUILT_IN_ALLOCA) || gimple_call_builtin_p (def_stmt, BUILT_IN_ALLOCA_WITH_ALIGN)) warned = warning_at (loc, OPT_Wfree_nonheap_object, - "%K%qD called on pointer to " + "%qD called on pointer to " "an unallocated object", - exp, dealloc_decl); + dealloc_decl); else if (warn_dealloc_offset (loc, exp, aref)) return; diff --git a/gcc/calls.c b/gcc/calls.c index a7c78ed9c16..fd088c0b972 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -1435,8 +1435,8 @@ maybe_warn_alloc_args_overflow (tree fn, tree exp, tree args[2], int idx[2]) if (tree_int_cst_lt (args[i], integer_zero_node)) { warned = warning_at (loc, OPT_Walloc_size_larger_than_, - "%Kargument %i value %qE is negative", - exp, idx[i] + 1, args[i]); + "argument %i value %qE is negative", + idx[i] + 1, args[i]); } else if (integer_zerop (args[i])) { @@ -1452,8 +1452,8 @@ maybe_warn_alloc_args_overflow (tree fn, tree exp, tree args[2], int idx[2]) : !lookup_attribute ("returns_nonnull", TYPE_ATTRIBUTES (fntype))) warned = warning_at (loc, OPT_Walloc_zero, - "%Kargument %i value is zero", - exp, idx[i] + 1); + "argument %i value is zero", + idx[i] + 1); } else if (tree_int_cst_lt (maxobjsize, args[i])) { @@ -1470,9 +1470,9 @@ maybe_warn_alloc_args_overflow (tree fn, tree exp, tree args[2], int idx[2]) continue; warned = warning_at (loc, OPT_Walloc_size_larger_than_, - "%Kargument %i value %qE exceeds " + "argument %i value %qE exceeds " "maximum object size %E", - exp, idx[i] + 1, args[i], maxobjsize); + idx[i] + 1, args[i], maxobjsize); } } else if (TREE_CODE (args[i]) == SSA_NAME @@ -1484,16 +1484,16 @@ maybe_warn_alloc_args_overflow (tree fn, tree exp, tree args[2], int idx[2]) && tree_int_cst_le (argrange[i][1], integer_zero_node)) { warned = warning_at (loc, OPT_Walloc_size_larger_than_, - "%Kargument %i range [%E, %E] is negative", - exp, idx[i] + 1, + "argument %i range [%E, %E] is negative", + idx[i] + 1, argrange[i][0], argrange[i][1]); } else if (tree_int_cst_lt (maxobjsize, argrange[i][0])) { warned = warning_at (loc, OPT_Walloc_size_larger_than_, - "%Kargument %i range [%E, %E] exceeds " + "argument %i range [%E, %E] exceeds " "maximum object size %E", - exp, idx[i] + 1, + idx[i] + 1, argrange[i][0], argrange[i][1], maxobjsize); } @@ -1521,15 +1521,15 @@ maybe_warn_alloc_args_overflow (tree fn, tree exp, tree args[2], int idx[2]) if (vflow) warned = warning_at (loc, OPT_Walloc_size_larger_than_, - "%Kproduct %<%E * %E%> of arguments %i and %i " + "product %<%E * %E%> of arguments %i and %i " "exceeds %", - exp, argrange[0][0], argrange[1][0], + argrange[0][0], argrange[1][0], idx[0] + 1, idx[1] + 1); else if (wi::ltu_p (wi::to_wide (maxobjsize, szprec), prod)) warned = warning_at (loc, OPT_Walloc_size_larger_than_, - "%Kproduct %<%E * %E%> of arguments %i and %i " + "product %<%E * %E%> of arguments %i and %i " "exceeds maximum object size %E", - exp, argrange[0][0], argrange[1][0], + argrange[0][0], argrange[1][0], idx[0] + 1, idx[1] + 1, maxobjsize); @@ -1729,14 +1729,14 @@ maybe_warn_nonstring_arg (tree fndecl, tree exp) bool warned = false; if (tree_int_cst_equal (bndrng[0], bndrng[1])) warned = warning_at (loc, OPT_Wstringop_overread, - "%K%qD specified bound %E " + "%qD specified bound %E " "exceeds maximum object size %E", - exp, fndecl, bndrng[0], maxobjsize); + fndecl, bndrng[0], maxobjsize); else warned = warning_at (loc, OPT_Wstringop_overread, - "%K%qD specified bound [%E, %E] " + "%qD specified bound [%E, %E] " "exceeds maximum object size %E", - exp, fndecl, bndrng[0], bndrng[1], + fndecl, bndrng[0], bndrng[1], maxobjsize); if (warned) TREE_NO_WARNING (exp) = true; @@ -2068,16 +2068,16 @@ maybe_warn_rdwr_sizes (rdwr_map *rwm, tree fndecl, tree fntype, tree exp) = access.second.array_as_string (ptrtype); arg_warned = warning_at (loc, OPT_Wstringop_overflow_, - "%Kbound argument %i value %s is " + "bound argument %i value %s is " "negative for a variable length array " "argument %i of type %s", - exp, sizidx + 1, sizstr, + sizidx + 1, sizstr, ptridx + 1, argtypestr.c_str ()); } else arg_warned = warning_at (loc, OPT_Wstringop_overflow_, - "%Kargument %i value %s is negative", - exp, sizidx + 1, sizstr); + "argument %i value %s is negative", + sizidx + 1, sizstr); if (arg_warned) { @@ -2123,19 +2123,19 @@ maybe_warn_rdwr_sizes (rdwr_map *rwm, tree fndecl, tree fntype, tree exp) = access.second.array_as_string (ptrtype); arg_warned = warning_at (loc, OPT_Wnonnull, - "%Kargument %i of variable length " + "argument %i of variable length " "array %s is null but " "the corresponding bound argument " "%i value is %s", - exp, sizidx + 1, argtypestr.c_str (), + sizidx + 1, argtypestr.c_str (), ptridx + 1, sizstr); } else arg_warned = warning_at (loc, OPT_Wnonnull, - "%Kargument %i is null but " + "argument %i is null but " "the corresponding size argument " "%i value is %s", - exp, ptridx + 1, sizidx + 1, + ptridx + 1, sizidx + 1, sizstr); } else if (access_size && access.second.static_p) @@ -2143,9 +2143,9 @@ maybe_warn_rdwr_sizes (rdwr_map *rwm, tree fndecl, tree fntype, tree exp) /* Warn about null pointers for [static N] array arguments but do not warn for ordinary (i.e., nonstatic) arrays. */ arg_warned = warning_at (loc, OPT_Wnonnull, - "%Kargument %i to %<%T[static %E]%> " + "argument %i to %<%T[static %E]%> " "is null where non-null expected", - exp, ptridx + 1, argtype, + ptridx + 1, argtype, access_size); } diff --git a/gcc/expr.c b/gcc/expr.c index e4660f0e90a..c8e61d38323 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -11391,7 +11391,7 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode, /* All valid uses of __builtin_va_arg_pack () are removed during inlining. */ if (CALL_EXPR_VA_ARG_PACK (exp)) - error ("%Kinvalid use of %<__builtin_va_arg_pack ()%>", exp); + error ("invalid use of %<__builtin_va_arg_pack ()%>"); { tree fndecl = get_callee_fndecl (exp), attr; @@ -11403,7 +11403,7 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode, DECL_ATTRIBUTES (fndecl))) != NULL) { const char *ident = lang_hooks.decl_printable_name (fndecl, 1); - error ("%Kcall to %qs declared with attribute error: %s", exp, + error ("call to %qs declared with attribute error: %s", identifier_to_locale (ident), TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr)))); } @@ -11415,10 +11415,10 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode, DECL_ATTRIBUTES (fndecl))) != NULL) { const char *ident = lang_hooks.decl_printable_name (fndecl, 1); - warning_at (tree_nonartificial_location (exp), + warning_at (EXPR_LOCATION (exp), OPT_Wattribute_warning, - "%Kcall to %qs declared with attribute warning: %s", - exp, identifier_to_locale (ident), + "call to %qs declared with attribute warning: %s", + identifier_to_locale (ident), TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr)))); } diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index 1c0e930aba5..b4020ba5ba2 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -2115,13 +2115,13 @@ gimple_fold_builtin_strncpy (gimple_stmt_iterator *gsi, tree slen = get_maxval_strlen (src, SRK_STRLEN); if (slen && !integer_zerop (slen)) warning_at (loc, OPT_Wstringop_truncation, - "%G%qD destination unchanged after copying no bytes " + "%qD destination unchanged after copying no bytes " "from a string of length %E", - stmt, fndecl, slen); + fndecl, slen); else warning_at (loc, OPT_Wstringop_truncation, - "%G%qD destination unchanged after copying no bytes", - stmt, fndecl); + "%qD destination unchanged after copying no bytes", + fndecl); } replace_call_with_value (gsi, dest); @@ -2498,11 +2498,11 @@ gimple_fold_builtin_strncat (gimple_stmt_iterator *gsi) location_t loc = gimple_location (stmt); nowarn = warning_at (loc, OPT_Wstringop_overflow_, cmpdst == 0 - ? G_("%G%qD specified bound %E equals " + ? G_("%qD specified bound %E equals " "destination size") - : G_("%G%qD specified bound %E exceeds " + : G_("%qD specified bound %E exceeds " "destination size %wu"), - stmt, fndecl, len, dstsize); + fndecl, len, dstsize); if (nowarn) gimple_set_no_warning (stmt, true); } @@ -2518,8 +2518,8 @@ gimple_fold_builtin_strncat (gimple_stmt_iterator *gsi) of the destination is unknown (it's not an uncommon mistake to specify as the bound to strncpy the length of the source). */ if (warning_at (loc, OPT_Wstringop_overflow_, - "%G%qD specified bound %E equals source length", - stmt, fndecl, len)) + "%qD specified bound %E equals source length", + fndecl, len)) gimple_set_no_warning (stmt, true); } diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c index fc744669e4b..dae8cfaa8e4 100644 --- a/gcc/gimple-ssa-sprintf.c +++ b/gcc/gimple-ssa-sprintf.c @@ -3113,9 +3113,8 @@ format_directive (const call_info &info, if (fmtres.nullp) { fmtwarn (dirloc, argloc, NULL, info.warnopt (), - "%G%<%.*s%> directive argument is null", - info.callstmt, dirlen, - target_to_host (hostdir, sizeof hostdir, dir.beg)); + "%<%.*s%> directive argument is null", + dirlen, target_to_host (hostdir, sizeof hostdir, dir.beg)); /* Don't bother processing the rest of the format string. */ res->warned = true; @@ -4618,8 +4617,7 @@ handle_printf_call (gimple_stmt_iterator *gsi, pointer_query &ptr_qry) is not constant. */ location_t loc = gimple_location (info.callstmt); warning_at (EXPR_LOC_OR_LOC (dstptr, loc), - info.warnopt (), "%Gnull destination pointer", - info.callstmt); + info.warnopt (), "null destination pointer"); return false; } @@ -4648,8 +4646,7 @@ handle_printf_call (gimple_stmt_iterator *gsi, pointer_query &ptr_qry) { location_t loc = gimple_location (info.callstmt); warning_at (EXPR_LOC_OR_LOC (info.format, loc), - info.warnopt (), "%Gnull format string", - info.callstmt); + info.warnopt (), "null format string"); return false; } diff --git a/gcc/gimple-ssa-warn-alloca.c b/gcc/gimple-ssa-warn-alloca.c index 72480f1d8cb..4fc7125d378 100644 --- a/gcc/gimple-ssa-warn-alloca.c +++ b/gcc/gimple-ssa-warn-alloca.c @@ -283,7 +283,7 @@ pass_walloca::execute (function *fun) } else if (warn_alloca) { - warning_at (loc, OPT_Walloca, "%Guse of %", stmt); + warning_at (loc, OPT_Walloca, "use of %"); continue; } else if (warn_alloca_limit < 0) @@ -322,11 +322,10 @@ pass_walloca::execute (function *fun) auto_diagnostic_group d; if (warning_at (loc, wcode, (is_vla - ? G_("%Gargument to variable-length " + ? G_("argument to variable-length " "array may be too large") - : G_("%Gargument to % may be too " - "large")), - stmt) + : G_("argument to % may be too " + "large"))) && t.limit != 0) { print_decu (t.limit, buff); @@ -342,10 +341,9 @@ pass_walloca::execute (function *fun) auto_diagnostic_group d; if (warning_at (loc, wcode, (is_vla - ? G_("%Gargument to variable-length" + ? G_("argument to variable-length" " array is too large") - : G_("%Gargument to % is too large")), - stmt) + : G_("argument to % is too large"))) && t.limit != 0) { print_decu (t.limit, buff); @@ -361,22 +359,20 @@ pass_walloca::execute (function *fun) warning_at (loc, wcode, (is_vla - ? G_("%Gunbounded use of variable-length array") - : G_("%Gunbounded use of %")), - stmt); + ? G_("unbounded use of variable-length array") + : G_("unbounded use of %"))); break; case ALLOCA_IN_LOOP: gcc_assert (!is_vla); warning_at (loc, wcode, - "%Guse of % within a loop", stmt); + "use of % within a loop"); break; case ALLOCA_ARG_IS_ZERO: warning_at (loc, wcode, (is_vla - ? G_("%Gargument to variable-length array " + ? G_("argument to variable-length array " "is zero") - : G_("%Gargument to % is zero")), - stmt); + : G_("argument to % is zero"))); break; default: gcc_unreachable (); diff --git a/gcc/gimple-ssa-warn-restrict.c b/gcc/gimple-ssa-warn-restrict.c index c8c9f9581a8..87b0ae04111 100644 --- a/gcc/gimple-ssa-warn-restrict.c +++ b/gcc/gimple-ssa-warn-restrict.c @@ -1494,36 +1494,36 @@ maybe_diag_overlap (location_t loc, gimple *call, builtin_access &acs) warning_at (loc, OPT_Wrestrict, sizrange[0] == 1 ? (ovlsiz[0] == 1 - ? G_("%G%qD accessing %wu byte at offsets %s " + ? G_("%qD accessing %wu byte at offsets %s " "and %s overlaps %wu byte at offset %s") - : G_("%G%qD accessing %wu byte at offsets %s " + : G_("%qD accessing %wu byte at offsets %s " "and %s overlaps %wu bytes at offset " "%s")) : (ovlsiz[0] == 1 - ? G_("%G%qD accessing %wu bytes at offsets %s " + ? G_("%qD accessing %wu bytes at offsets %s " "and %s overlaps %wu byte at offset %s") - : G_("%G%qD accessing %wu bytes at offsets %s " + : G_("%qD accessing %wu bytes at offsets %s " "and %s overlaps %wu bytes at offset " "%s")), - call, func, sizrange[0], + func, sizrange[0], offstr[0], offstr[1], ovlsiz[0], offstr[2]); else if (ovlsiz[1] >= 0 && ovlsiz[1] < maxobjsize.to_shwi ()) warning_n (loc, OPT_Wrestrict, sizrange[0], - "%G%qD accessing %wu byte at offsets %s " + "%qD accessing %wu byte at offsets %s " "and %s overlaps between %wu and %wu bytes " "at offset %s", - "%G%qD accessing %wu bytes at offsets %s " + "%qD accessing %wu bytes at offsets %s " "and %s overlaps between %wu and %wu bytes " "at offset %s", - call, func, sizrange[0], offstr[0], offstr[1], + func, sizrange[0], offstr[0], offstr[1], ovlsiz[0], ovlsiz[1], offstr[2]); else warning_n (loc, OPT_Wrestrict, sizrange[0], - "%G%qD accessing %wu byte at offsets %s and " + "%qD accessing %wu byte at offsets %s and " "%s overlaps %wu or more bytes at offset %s", - "%G%qD accessing %wu bytes at offsets %s and " + "%qD accessing %wu bytes at offsets %s and " "%s overlaps %wu or more bytes at offset %s", - call, func, sizrange[0], + func, sizrange[0], offstr[0], offstr[1], ovlsiz[0], offstr[2]); return true; } @@ -1532,28 +1532,28 @@ maybe_diag_overlap (location_t loc, gimple *call, builtin_access &acs) { if (ovlsiz[0] == ovlsiz[1]) warning_n (loc, OPT_Wrestrict, ovlsiz[0], - "%G%qD accessing between %wu and %wu bytes " + "%qD accessing between %wu and %wu bytes " "at offsets %s and %s overlaps %wu byte at " "offset %s", - "%G%qD accessing between %wu and %wu bytes " + "%qD accessing between %wu and %wu bytes " "at offsets %s and %s overlaps %wu bytes " "at offset %s", - call, func, sizrange[0], sizrange[1], + func, sizrange[0], sizrange[1], offstr[0], offstr[1], ovlsiz[0], offstr[2]); else if (ovlsiz[1] >= 0 && ovlsiz[1] < maxobjsize.to_shwi ()) warning_at (loc, OPT_Wrestrict, - "%G%qD accessing between %wu and %wu bytes at " + "%qD accessing between %wu and %wu bytes at " "offsets %s and %s overlaps between %wu and %wu " "bytes at offset %s", - call, func, sizrange[0], sizrange[1], + func, sizrange[0], sizrange[1], offstr[0], offstr[1], ovlsiz[0], ovlsiz[1], offstr[2]); else warning_at (loc, OPT_Wrestrict, - "%G%qD accessing between %wu and %wu bytes at " + "%qD accessing between %wu and %wu bytes at " "offsets %s and %s overlaps %wu or more bytes " "at offset %s", - call, func, sizrange[0], sizrange[1], + func, sizrange[0], sizrange[1], offstr[0], offstr[1], ovlsiz[0], offstr[2]); return true; } @@ -1563,24 +1563,24 @@ maybe_diag_overlap (location_t loc, gimple *call, builtin_access &acs) if (ovlsiz[0] == ovlsiz[1]) warning_n (loc, OPT_Wrestrict, ovlsiz[0], - "%G%qD accessing %wu or more bytes at offsets " + "%qD accessing %wu or more bytes at offsets " "%s and %s overlaps %wu byte at offset %s", - "%G%qD accessing %wu or more bytes at offsets " + "%qD accessing %wu or more bytes at offsets " "%s and %s overlaps %wu bytes at offset %s", - call, func, sizrange[0], offstr[0], offstr[1], + func, sizrange[0], offstr[0], offstr[1], ovlsiz[0], offstr[2]); else if (ovlsiz[1] >= 0 && ovlsiz[1] < maxobjsize.to_shwi ()) warning_at (loc, OPT_Wrestrict, - "%G%qD accessing %wu or more bytes at offsets %s " + "%qD accessing %wu or more bytes at offsets %s " "and %s overlaps between %wu and %wu bytes " "at offset %s", - call, func, sizrange[0], offstr[0], offstr[1], + func, sizrange[0], offstr[0], offstr[1], ovlsiz[0], ovlsiz[1], offstr[2]); else warning_at (loc, OPT_Wrestrict, - "%G%qD accessing %wu or more bytes at offsets %s " + "%qD accessing %wu or more bytes at offsets %s " "and %s overlaps %wu or more bytes at offset %s", - call, func, sizrange[0], offstr[0], offstr[1], + func, sizrange[0], offstr[0], offstr[1], ovlsiz[0], offstr[2]); return true; } @@ -1606,36 +1606,36 @@ maybe_diag_overlap (location_t loc, gimple *call, builtin_access &acs) { if (open_range) warning_n (loc, OPT_Wrestrict, sizrange[1], - "%G%qD accessing %wu byte may overlap " + "%qD accessing %wu byte may overlap " "%wu byte", - "%G%qD accessing %wu bytes may overlap " + "%qD accessing %wu bytes may overlap " "%wu byte", - call, func, sizrange[1], ovlsiz[1]); + func, sizrange[1], ovlsiz[1]); else warning_n (loc, OPT_Wrestrict, sizrange[1], - "%G%qD accessing %wu byte at offsets %s " + "%qD accessing %wu byte at offsets %s " "and %s may overlap %wu byte at offset %s", - "%G%qD accessing %wu bytes at offsets %s " + "%qD accessing %wu bytes at offsets %s " "and %s may overlap %wu byte at offset %s", - call, func, sizrange[1], offstr[0], offstr[1], + func, sizrange[1], offstr[0], offstr[1], ovlsiz[1], offstr[2]); return true; } if (open_range) warning_n (loc, OPT_Wrestrict, sizrange[1], - "%G%qD accessing %wu byte may overlap " + "%qD accessing %wu byte may overlap " "up to %wu bytes", - "%G%qD accessing %wu bytes may overlap " + "%qD accessing %wu bytes may overlap " "up to %wu bytes", - call, func, sizrange[1], ovlsiz[1]); + func, sizrange[1], ovlsiz[1]); else warning_n (loc, OPT_Wrestrict, sizrange[1], - "%G%qD accessing %wu byte at offsets %s and " + "%qD accessing %wu byte at offsets %s and " "%s may overlap up to %wu bytes at offset %s", - "%G%qD accessing %wu bytes at offsets %s and " + "%qD accessing %wu bytes at offsets %s and " "%s may overlap up to %wu bytes at offset %s", - call, func, sizrange[1], offstr[0], offstr[1], + func, sizrange[1], offstr[0], offstr[1], ovlsiz[1], offstr[2]); return true; } @@ -1644,30 +1644,30 @@ maybe_diag_overlap (location_t loc, gimple *call, builtin_access &acs) { if (open_range) warning_n (loc, OPT_Wrestrict, ovlsiz[1], - "%G%qD accessing between %wu and %wu bytes " + "%qD accessing between %wu and %wu bytes " "may overlap %wu byte", - "%G%qD accessing between %wu and %wu bytes " + "%qD accessing between %wu and %wu bytes " "may overlap up to %wu bytes", - call, func, sizrange[0], sizrange[1], ovlsiz[1]); + func, sizrange[0], sizrange[1], ovlsiz[1]); else warning_n (loc, OPT_Wrestrict, ovlsiz[1], - "%G%qD accessing between %wu and %wu bytes " + "%qD accessing between %wu and %wu bytes " "at offsets %s and %s may overlap %wu byte " "at offset %s", - "%G%qD accessing between %wu and %wu bytes " + "%qD accessing between %wu and %wu bytes " "at offsets %s and %s may overlap up to %wu " "bytes at offset %s", - call, func, sizrange[0], sizrange[1], + func, sizrange[0], sizrange[1], offstr[0], offstr[1], ovlsiz[1], offstr[2]); return true; } warning_n (loc, OPT_Wrestrict, ovlsiz[1], - "%G%qD accessing %wu or more bytes at offsets %s " + "%qD accessing %wu or more bytes at offsets %s " "and %s may overlap %wu byte at offset %s", - "%G%qD accessing %wu or more bytes at offsets %s " + "%qD accessing %wu or more bytes at offsets %s " "and %s may overlap up to %wu bytes at offset %s", - call, func, sizrange[0], offstr[0], offstr[1], + func, sizrange[0], offstr[0], offstr[1], ovlsiz[1], offstr[2]); return true; @@ -1688,7 +1688,7 @@ maybe_diag_access_bounds (gimple *call, tree func, int strict, const builtin_memref &ref, offset_int wroff, bool do_warn) { - location_t loc = gimple_or_expr_nonartificial_location (call, ref.ptr); + location_t loc = gimple_location (call); const offset_int maxobjsize = ref.maxobjsize; /* Check for excessive size first and regardless of warning options @@ -1706,15 +1706,15 @@ maybe_diag_access_bounds (gimple *call, tree func, int strict, { if (ref.sizrange[0] == ref.sizrange[1]) return warning_at (loc, OPT_Wstringop_overflow_, - "%G%qD specified bound %wu " + "%qD specified bound %wu " "exceeds maximum object size %wu", - call, func, ref.sizrange[0].to_uhwi (), + func, ref.sizrange[0].to_uhwi (), maxobjsize.to_uhwi ()); return warning_at (loc, OPT_Wstringop_overflow_, - "%G%qD specified bound between %wu and %wu " + "%qD specified bound between %wu and %wu " "exceeds maximum object size %wu", - call, func, ref.sizrange[0].to_uhwi (), + func, ref.sizrange[0].to_uhwi (), ref.sizrange[1].to_uhwi (), maxobjsize.to_uhwi ()); } @@ -1771,9 +1771,9 @@ maybe_diag_access_bounds (gimple *call, tree func, int strict, { auto_diagnostic_group d; if (warning_at (loc, OPT_Warray_bounds, - "%G%qD pointer overflow between offset %s " + "%qD pointer overflow between offset %s " "and size %s accessing array %qD with type %qT", - call, func, rangestr[0], rangestr[1], ref.base, type)) + func, rangestr[0], rangestr[1], ref.base, type)) { inform (DECL_SOURCE_LOCATION (ref.base), "array %qD declared here", ref.base); @@ -1781,15 +1781,15 @@ maybe_diag_access_bounds (gimple *call, tree func, int strict, } else warned = warning_at (loc, OPT_Warray_bounds, - "%G%qD pointer overflow between offset %s " + "%qD pointer overflow between offset %s " "and size %s", - call, func, rangestr[0], rangestr[1]); + func, rangestr[0], rangestr[1]); } else warned = warning_at (loc, OPT_Warray_bounds, - "%G%qD pointer overflow between offset %s " + "%qD pointer overflow between offset %s " "and size %s", - call, func, rangestr[0], rangestr[1]); + func, rangestr[0], rangestr[1]); } else if (oobref == ref.base) { @@ -1804,20 +1804,20 @@ maybe_diag_access_bounds (gimple *call, tree func, int strict, if ((ref.basesize < maxobjsize && warning_at (loc, OPT_Warray_bounds, form - ? G_("%G%qD forming offset %s is out of " + ? G_("%qD forming offset %s is out of " "the bounds [0, %wu] of object %qD with " "type %qT") - : G_("%G%qD offset %s is out of the bounds " + : G_("%qD offset %s is out of the bounds " "[0, %wu] of object %qD with type %qT"), - call, func, rangestr[0], ref.basesize.to_uhwi (), + func, rangestr[0], ref.basesize.to_uhwi (), ref.base, TREE_TYPE (ref.base))) || warning_at (loc, OPT_Warray_bounds, form - ? G_("%G%qD forming offset %s is out of " + ? G_("%qD forming offset %s is out of " "the bounds of object %qD with type %qT") - : G_("%G%qD offset %s is out of the bounds " + : G_("%qD offset %s is out of the bounds " "of object %qD with type %qT"), - call, func, rangestr[0], + func, rangestr[0], ref.base, TREE_TYPE (ref.base))) { inform (DECL_SOURCE_LOCATION (ref.base), @@ -1828,17 +1828,17 @@ maybe_diag_access_bounds (gimple *call, tree func, int strict, else if (ref.basesize < maxobjsize) warned = warning_at (loc, OPT_Warray_bounds, form - ? G_("%G%qD forming offset %s is out " + ? G_("%qD forming offset %s is out " "of the bounds [0, %wu]") - : G_("%G%qD offset %s is out " + : G_("%qD offset %s is out " "of the bounds [0, %wu]"), - call, func, rangestr[0], ref.basesize.to_uhwi ()); + func, rangestr[0], ref.basesize.to_uhwi ()); else warned = warning_at (loc, OPT_Warray_bounds, form - ? G_("%G%qD forming offset %s is out of bounds") - : G_("%G%qD offset %s is out of bounds"), - call, func, rangestr[0]); + ? G_("%qD forming offset %s is out of bounds") + : G_("%qD offset %s is out of bounds"), + func, rangestr[0]); } else if (TREE_CODE (ref.ref) == MEM_REF) { @@ -1849,9 +1849,9 @@ maybe_diag_access_bounds (gimple *call, tree func, int strict, type = TYPE_MAIN_VARIANT (type); if (warning_at (loc, OPT_Warray_bounds, - "%G%qD offset %s from the object at %qE is out " + "%qD offset %s from the object at %qE is out " "of the bounds of %qT", - call, func, rangestr[0], ref.base, type)) + func, rangestr[0], ref.base, type)) { if (TREE_CODE (ref.ref) == COMPONENT_REF) refop = TREE_OPERAND (ref.ref, 1); @@ -1867,10 +1867,10 @@ maybe_diag_access_bounds (gimple *call, tree func, int strict, tree type = TYPE_MAIN_VARIANT (TREE_TYPE (ref.ref)); if (warning_at (loc, OPT_Warray_bounds, - "%G%qD offset %s from the object at %qE is out " + "%qD offset %s from the object at %qE is out " "of the bounds of referenced subobject %qD with " "type %qT at offset %wi", - call, func, rangestr[0], ref.base, + func, rangestr[0], ref.base, TREE_OPERAND (ref.ref, 1), type, ref.refoff.to_shwi ())) { @@ -2057,7 +2057,7 @@ check_bounds_or_overlap (range_query *query, } } - location_t loc = gimple_or_expr_nonartificial_location (call, dst); + location_t loc = gimple_location (call); if (operand_equal_p (dst, src, 0)) { /* Issue -Wrestrict unless the pointers are null (those do @@ -2067,8 +2067,8 @@ check_bounds_or_overlap (range_query *query, if (!integer_zerop (dst) && !gimple_no_warning_p (call)) { warning_at (loc, OPT_Wrestrict, - "%G%qD source argument is the same as destination", - call, func); + "%qD source argument is the same as destination", + func); gimple_set_no_warning (call, true); return OPT_Wrestrict; } diff --git a/gcc/testsuite/g++.dg/warn/Wdtor1.s b/gcc/testsuite/g++.dg/warn/Wdtor1.s new file mode 100644 index 00000000000..e69de29bb2d diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-71.c b/gcc/testsuite/gcc.dg/Warray-bounds-71.c new file mode 100644 index 00000000000..425bb122909 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Warray-bounds-71.c @@ -0,0 +1,7 @@ +/* Verify that -Warray-bounds suppression via #pragma GCC diagnostic + works at any call site in an inlining stack + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +#define IGNORE '1' +#include "Warray-bounds-71.h" diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-71.h b/gcc/testsuite/gcc.dg/Warray-bounds-71.h new file mode 100644 index 00000000000..89d1068a266 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Warray-bounds-71.h @@ -0,0 +1,46 @@ +/* Verify that -Warray-bounds suppression via #pragma GCC diagnostic + works at any call site in an inlining stack + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +int a[4]; + +void f1 (int *p, int i) +{ +#pragma GCC diagnostic push +#if IGNORE == '1' +# pragma GCC diagnostic ignored "-Warray-bounds" +#endif + p[i + 1] = 0; +#pragma GCC diagnostic pop +} + +void f2 (int *p, int i) +{ +#pragma GCC diagnostic push +#if IGNORE == '2' +# pragma GCC diagnostic ignored "-Warray-bounds" +#endif + f1 (p + 1, i + 1); +#pragma GCC diagnostic pop +} + +void f3 (int *p, int i) +{ +#pragma GCC diagnostic push +#if IGNORE == '3' +# pragma GCC diagnostic ignored "-Warray-bounds" +#endif + f2 (p + 1, i + 1); +#pragma GCC diagnostic pop +} + +void f4 (void) +{ +#pragma GCC diagnostic push +#if IGNORE == '4' +# pragma GCC diagnostic ignored "-Warray-bounds" +#endif + f3 (a, 1); +#pragma GCC diagnostic pop +} diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-72.c b/gcc/testsuite/gcc.dg/Warray-bounds-72.c new file mode 100644 index 00000000000..eb3f664c0c8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Warray-bounds-72.c @@ -0,0 +1,7 @@ +/* Verify that -Warray-bounds suppression via #pragma GCC diagnostic + works at any call site in an inlining stack + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +#define IGNORE '2' +#include "Warray-bounds-71.h" diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-73.c b/gcc/testsuite/gcc.dg/Warray-bounds-73.c new file mode 100644 index 00000000000..50e20835293 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Warray-bounds-73.c @@ -0,0 +1,7 @@ +/* Verify that -Warray-bounds suppression via #pragma GCC diagnostic + works at any call site in an inlining stack + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +#define IGNORE '3' +#include "Warray-bounds-71.h" diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-74.c b/gcc/testsuite/gcc.dg/Warray-bounds-74.c new file mode 100644 index 00000000000..c59a876e073 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Warray-bounds-74.c @@ -0,0 +1,7 @@ +/* Verify that -Warray-bounds suppression via #pragma GCC diagnostic + works at any call site in an inlining stack + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +#define IGNORE '4' +#include "Warray-bounds-71.h" diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-75.c b/gcc/testsuite/gcc.dg/Warray-bounds-75.c new file mode 100644 index 00000000000..306b1768b0e --- /dev/null +++ b/gcc/testsuite/gcc.dg/Warray-bounds-75.c @@ -0,0 +1,12 @@ +/* Sanity test for Warray-bounds-7[1-4].c. Also verify the expected + inlining stack. + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +#include "Warray-bounds-71.h" + +// { dg-regexp "In function 'f1'," "In function f1" { target *-*-* } 0 } +// { dg-regexp "inlined from 'f2' at \[^\\n\\r\]+\[\\n\\r\]" "inlined from f2" { target *-*-* } 0 } +// { dg-regexp "inlined from 'f3' at \[^\\n\\r\]+\[\\n\\r\]" "inlined from f3" { target *-*-* } 0 } +// { dg-regexp "inlined from 'f4' at \[^\\n\\r\]+\[\\n\\r\]" "inlined from f4" { target *-*-* } 0 } +// { dg-message "Warray-bounds-71.h:\\d+:\\d+: warning: array subscript 6 is outside array bounds of 'int\\\[4]'" "warning" { target *-*-* } 0 } diff --git a/gcc/testsuite/gcc.dg/Wfree-nonheap-object-4.c b/gcc/testsuite/gcc.dg/Wfree-nonheap-object-4.c index a7d921248c4..fdef9e6b3ea 100644 --- a/gcc/testsuite/gcc.dg/Wfree-nonheap-object-4.c +++ b/gcc/testsuite/gcc.dg/Wfree-nonheap-object-4.c @@ -26,7 +26,7 @@ void g2 (struct A *p) { g1 (p); } #define NOIPA __attribute__ ((noipa)) -extern int array[]; +extern int array[]; // { dg-message "declared here" "note on line 29" } /* Verify the warning is issued even for calls in a system header inlined into a function outside the header. */ @@ -39,7 +39,7 @@ NOIPA void warn_g0 (struct A *p) g0 (p); } -// { dg-message "inlined from 'warn_g0'" "" { target *-*-* } 0 } +// { dg-message "inlined from 'warn_g0'" "note on line 42" { target *-*-* } 0 } /* Also verify the warning can be suppressed. */ @@ -65,8 +65,8 @@ NOIPA void warn_g1 (struct A *p) g1 (p); } -// { dg-message "inlined from 'g1'" "" { target *-*-* } 0 } -// { dg-message "inlined from 'warn_g1'" "" { target *-*-* } 0 } +// { dg-message "inlined from 'g1'" "note on line 68" { target *-*-* } 0 } +// { dg-message "inlined from 'warn_g1'" "note on line 69" { target *-*-* } 0 } NOIPA void nowarn_g1 (struct A *p) @@ -90,8 +90,8 @@ NOIPA void warn_g2 (struct A *p) g2 (p); } -// { dg-message "inlined from 'g2'" "" { target *-*-* } 0 } -// { dg-message "inlined from 'warn_g2'" "" { target *-*-* } 0 } +// { dg-message "inlined from 'g2'" "note on line 93" { target *-*-* } 0 } +// { dg-message "inlined from 'warn_g2'" "note on line 94" { target *-*-* } 0 } NOIPA void nowarn_g2 (struct A *p) diff --git a/gcc/testsuite/gcc.dg/Wfree-nonheap-object-5.c b/gcc/testsuite/gcc.dg/Wfree-nonheap-object-5.c new file mode 100644 index 00000000000..979e1e3d78f --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wfree-nonheap-object-5.c @@ -0,0 +1,45 @@ +/* Similar to Wfree-nonheap-object-4.c but without system headers: + verify that warnings for the same call site from distinct callers + include the correct function names in the inlining stack. + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +struct A +{ + void *p; +}; + +void f0 (struct A *p) +{ + __builtin_free (p->p); // { dg-warning "\\\[-Wfree-nonheap-object" } +} + +// Expect two instances of the text below: +// { dg-regexp "In function 'f0'," "f0 prefix" { target *-*-* } 0 } +// { dg-regexp "In function 'f0'," "f0 prefix" { target *-*-* } 0 } + +void f1 (struct A *p) { f0 (p); } +void f2 (struct A *p) { f1 (p); } + +extern int array[]; +// Also expect two instances of the note: +// { dg-regexp "declared here" "note on line 24" { target *-*-* } .-2 } +// { dg-regexp "declared here" "note on line 24" { target *-*-* } .-3 } + +void foo (struct A *p) +{ + p->p = array + 1; + f0 (p); +} + +// { dg-message "inlined from 'foo'" "note on line 35" { target *-*-* } 0 } + + +void bar (struct A *p) +{ + p->p = array + 2; + f1 (p); +} + +// { dg-message "inlined from 'f1'" "note on line 44" { target *-*-* } 0 } +// { dg-message "inlined from 'bar'" "note on line 45" { target *-*-* } 0 } diff --git a/gcc/testsuite/gcc.dg/Wobjsize-1.c b/gcc/testsuite/gcc.dg/Wobjsize-1.c index e80c8add3bb..2bd2f93897b 100644 --- a/gcc/testsuite/gcc.dg/Wobjsize-1.c +++ b/gcc/testsuite/gcc.dg/Wobjsize-1.c @@ -4,13 +4,17 @@ #include "Wobjsize-1.h" char buf[6]; -/* { dg-warning "writing" "" { target *-*-* } .-1 } */ int main(int argc, char **argv) { - strcpy (buf,"hello "); + strcpy (buf,"hello "); /* { dg-warning "\\\[-Wstringop-overflow" } */ return 0; } -/* { dg-message "file included" "included" { target *-*-* } 0 } */ -/* { dg-message "inlined from" "inlined" { target *-*-* } 0 } */ +/* { dg-message "file included" "included" { target *-*-* } 0 } + { dg-message "inlined from" "inlined" { target *-*-* } 0 } + + The test might emit two warnings, one for the strcpy call and + another for the inlined call to __builtin___strcpy_chk() called + from strcpy(). + { dg-prune-output "writing 7 bytes into a region of size 6" } */ diff --git a/gcc/testsuite/gcc.dg/pragma-diag-10.c b/gcc/testsuite/gcc.dg/pragma-diag-10.c new file mode 100644 index 00000000000..127b299939a --- /dev/null +++ b/gcc/testsuite/gcc.dg/pragma-diag-10.c @@ -0,0 +1,20 @@ +/* PR middle-end/98512 - #pragma GCC diagnostic ignored ineffective + in conjunction with alias attribute + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +void * +__rawmemchr_ppc (const void *s, int c) +{ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#pragma GCC diagnostic ignored "-Wstringop-overread" + if (c != 0) + return __builtin_memchr (s, c, (unsigned long)-1); // { dg-bogus "specified bound \\d+ exceeds maximum object size" } +#pragma GCC diagnostic pop + + return (char *)s + __builtin_strlen (s); +} + +extern __typeof (__rawmemchr_ppc) __EI___rawmemchr_ppc + __attribute__((alias ("__rawmemchr_ppc"))); diff --git a/gcc/testsuite/gcc.dg/pragma-diag-9.c b/gcc/testsuite/gcc.dg/pragma-diag-9.c new file mode 100644 index 00000000000..d7eac558128 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pragma-diag-9.c @@ -0,0 +1,134 @@ +/* Verify that #pragma GCC diagnostic down the inlining stack suppresses + a warning that would otherwise be issued for inlined calls higher up + the inlining stack. + { dg-do compile } + { dg-options "-O2 -Wall -Wno-array-bounds" } */ + +extern void* memset (void*, int, __SIZE_TYPE__); + +static void warn0 (int *p) +{ + memset (p, __LINE__, 3); // { dg-warning "\\\[-Wstringop-overflow" } +} + +static void warn1 (int *p) +{ + warn0 (p + 1); +} + +static void warn2 (int *p) +{ + warn1 (p + 1); +} + +int a2[2]; // { dg-message "at offset 12 into destination object 'a2' of size 8" } + +void warn3 (void) +{ + warn2 (a2 + 1); +} + + +static void ignore0 (int *p) +{ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" + memset (p, __LINE__, 3); +#pragma GCC diagnostic pop +} + +static void nowarn1_ignore0 (int *p) +{ + ignore0 (p + 1); +} + +static void nowarn2_ignore0 (int *p) +{ + nowarn1_ignore0 (p + 1); +} + +int b2[2]; + +void nowarn3_ignore0 (void) +{ + nowarn2_ignore0 (b2 + 1); +} + + +static void nowarn0_ignore1 (int *p) +{ + memset (p, __LINE__, 3); +} + +static void ignore1 (int *p) +{ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" + nowarn0_ignore1 (p + 1); +#pragma GCC diagnostic pop +} + +void nowarn2_ignore1 (int *p) +{ + ignore1 (p + 1); +} + +int c2[2]; + +void nowarn3_ignore1 (void) +{ + nowarn2_ignore1 (c2 + 1); +} + + +static void nowarn0_ignore2 (int *p) +{ + memset (p, __LINE__, 3); +} + +static void nowarn1_ignore2 (int *p) +{ + nowarn0_ignore2 (p + 1); +} + +static void ignore2 (int *p) +{ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" + nowarn1_ignore2 (p + 1); +#pragma GCC diagnostic pop +} + +int d2[2]; + +void nowarn3_ignore2 (void) +{ + ignore2 (c2 + 1); +} + + + +static void nowarn0_ignore3 (int *p) +{ + memset (p, __LINE__, 3); +} + +static void nowarn1_ignore3 (int *p) +{ + nowarn0_ignore3 (p + 1); +} + +static void nowarn2_ignore3 (int *p) +{ + nowarn1_ignore3 (p + 1); +} + +int e2[2]; + +void ignore3 (void) +{ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" + nowarn2_ignore3 (e2 + 1); +#pragma GCC diagnostic pop +} diff --git a/gcc/testsuite/gcc.dg/uninit-suppress_3.c b/gcc/testsuite/gcc.dg/uninit-suppress_3.c new file mode 100644 index 00000000000..7bbe9edc605 --- /dev/null +++ b/gcc/testsuite/gcc.dg/uninit-suppress_3.c @@ -0,0 +1,98 @@ +/* PR middle-end/98871 - Cannot silence -Wmaybe-uninitialized at declaration + site + { dg-do compile } + { dg-options "-O1 -Wall" } */ + +struct A +{ + int x; +}; + +// Verify that suppression works at every inlining level. + +static int f0 (int *x) +{ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" + + return ++*x; + +#pragma GCC diagnostic pop +} + +static int f1 (int *p, int n) +{ + struct A a; + for (int i = 0; i < n; ++i) { + if (p[i] > 1) { + a = (struct A){p[i]}; + } + } + + return f0 (&a.x); +} + +int f2 (void) +{ + int a[] = { 1, 2, 3, 4 }; + return f1 (a, 4); +} + + +static int g0 (int *x) +{ + return ++*x; +} + +static int g1 (int *p, int n) +{ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" + + struct A a; + for (int i = 0; i < n; ++i) { + if (p[i] > 1) { + a = (struct A){p[i]}; + } + } + + return g0 (&a.x); + +#pragma GCC diagnostic pop +} + +int g2 (void) +{ + int a[] = { 1, 2, 3, 4, 5 }; + return g1 (a, 5); +} + + +static int h0 (int *x) +{ + return ++*x; +} + +static int h1 (int *p, int n) +{ + struct A a; + for (int i = 0; i < n; ++i) { + if (p[i] > 1) { + a = (struct A){p[i]}; + } + } + + return h0 (&a.x); +} + +int h2 (void) +{ + int a[] = { 1, 2, 3, 4, 5, 6 }; + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" + + return h1 (a, 6); + +#pragma GCC diagnostic pop +} diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c index e74bd1f5ec0..c270d039b15 100644 --- a/gcc/trans-mem.c +++ b/gcc/trans-mem.c @@ -4413,12 +4413,8 @@ ipa_tm_scan_irr_block (basic_block bb) is to wrap it in a __tm_waiver block. This is not yet implemented, so we can't check for it. */ if (is_tm_safe (current_function_decl)) - { - tree t = build1 (NOP_EXPR, void_type_node, size_zero_node); - SET_EXPR_LOCATION (t, gimple_location (stmt)); - error ("%K% not allowed in % function", - t); - } + error_at (gimple_location (stmt), + "% not allowed in % function"); return true; default: diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 3834212b867..a7003c55aea 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -3563,7 +3563,7 @@ pass_post_ipa_warn::execute (function *fun) if (argno == 0) { if (warning_at (loc, OPT_Wnonnull, - "%G%qs pointer is null", stmt, "this") + "%qs pointer is null", "this") && fndecl) inform (DECL_SOURCE_LOCATION (fndecl), "in a call to non-static member function %qD", @@ -3572,8 +3572,8 @@ pass_post_ipa_warn::execute (function *fun) } if (!warning_at (loc, OPT_Wnonnull, - "%Gargument %u null where non-null " - "expected", stmt, argno)) + "argument %u null where non-null " + "expected", argno)) continue; tree fndecl = gimple_call_fndecl (stmt); diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c index 423075b2bd1..d22bc40afe8 100644 --- a/gcc/tree-ssa-strlen.c +++ b/gcc/tree-ssa-strlen.c @@ -2019,13 +2019,12 @@ maybe_warn_overflow (gimple *stmt, tree len, pointer_query &ptr_qry, warned = (writefn ? warning_at (loc, OPT_Wstringop_overflow_, - "%G%qD writing one too many bytes into a region " + "%qD writing one too many bytes into a region " "of a size that depends on %", - stmt, writefn) + writefn) : warning_at (loc, OPT_Wstringop_overflow_, - "%Gwriting one too many bytes into a region " - "of a size that depends on %", - stmt)); + "writing one too many bytes into a region " + "of a size that depends on %")); } else if (lenrng[0] == lenrng[1]) { @@ -2033,65 +2032,65 @@ maybe_warn_overflow (gimple *stmt, tree len, pointer_query &ptr_qry, warned = (writefn ? warning_n (loc, OPT_Wstringop_overflow_, lenrng[0].to_uhwi (), - "%G%qD writing %wu byte into a region " + "%qD writing %wu byte into a region " "of size %wu", - "%G%qD writing %wu bytes into a region " + "%qD writing %wu bytes into a region " "of size %wu", - stmt, writefn, lenrng[0].to_uhwi (), + writefn, lenrng[0].to_uhwi (), spcrng[0].to_uhwi ()) : warning_n (loc, OPT_Wstringop_overflow_, lenrng[0].to_uhwi (), - "%Gwriting %wu byte into a region " + "writing %wu byte into a region " "of size %wu", - "%Gwriting %wu bytes into a region " + "writing %wu bytes into a region " "of size %wu", - stmt, lenrng[0].to_uhwi (), + lenrng[0].to_uhwi (), spcrng[0].to_uhwi ())); else warned = (writefn ? warning_n (loc, OPT_Wstringop_overflow_, lenrng[0].to_uhwi (), - "%G%qD writing %wu byte into a region " + "%qD writing %wu byte into a region " "of size between %wu and %wu", - "%G%qD writing %wu bytes into a region " + "%qD writing %wu bytes into a region " "of size between %wu and %wu", - stmt, writefn, lenrng[0].to_uhwi (), + writefn, lenrng[0].to_uhwi (), spcrng[0].to_uhwi (), spcrng[1].to_uhwi ()) : warning_n (loc, OPT_Wstringop_overflow_, lenrng[0].to_uhwi (), - "%Gwriting %wu byte into a region " + "writing %wu byte into a region " "of size between %wu and %wu", - "%Gwriting %wu bytes into a region " + "writing %wu bytes into a region " "of size between %wu and %wu", - stmt, lenrng[0].to_uhwi (), + lenrng[0].to_uhwi (), spcrng[0].to_uhwi (), spcrng[1].to_uhwi ())); } else if (spcrng[0] == spcrng[1]) warned = (writefn ? warning_at (loc, OPT_Wstringop_overflow_, - "%G%qD writing between %wu and %wu bytes " + "%qD writing between %wu and %wu bytes " "into a region of size %wu", - stmt, writefn, lenrng[0].to_uhwi (), + writefn, lenrng[0].to_uhwi (), lenrng[1].to_uhwi (), spcrng[0].to_uhwi ()) : warning_at (loc, OPT_Wstringop_overflow_, - "%Gwriting between %wu and %wu bytes " + "writing between %wu and %wu bytes " "into a region of size %wu", - stmt, lenrng[0].to_uhwi (), + lenrng[0].to_uhwi (), lenrng[1].to_uhwi (), spcrng[0].to_uhwi ())); else warned = (writefn ? warning_at (loc, OPT_Wstringop_overflow_, - "%G%qD writing between %wu and %wu bytes " + "%qD writing between %wu and %wu bytes " "into a region of size between %wu and %wu", - stmt, writefn, lenrng[0].to_uhwi (), + writefn, lenrng[0].to_uhwi (), lenrng[1].to_uhwi (), spcrng[0].to_uhwi (), spcrng[1].to_uhwi ()) : warning_at (loc, OPT_Wstringop_overflow_, - "%Gwriting between %wu and %wu bytes " + "writing between %wu and %wu bytes " "into a region of size between %wu and %wu", - stmt, lenrng[0].to_uhwi (), + lenrng[0].to_uhwi (), lenrng[1].to_uhwi (), spcrng[0].to_uhwi (), spcrng[1].to_uhwi ())); @@ -2982,13 +2981,13 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt, if (lenrange[0] == cntrange[1] && cntrange[0] == cntrange[1]) return warning_n (callloc, OPT_Wstringop_truncation, cntrange[0].to_uhwi (), - "%G%qD output truncated before terminating " + "%qD output truncated before terminating " "nul copying %E byte from a string of the " "same length", - "%G%qD output truncated before terminating nul " + "%qD output truncated before terminating nul " "copying %E bytes from a string of the same " "length", - stmt, func, cnt); + func, cnt); else if (!cat_dstlen_bounded) { if (wi::geu_p (lenrange[0], cntrange[1])) @@ -2998,16 +2997,16 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt, if (cntrange[0] == cntrange[1]) return warning_n (callloc, OPT_Wstringop_truncation, cntrange[0].to_uhwi (), - "%G%qD output truncated copying %E byte " + "%qD output truncated copying %E byte " "from a string of length %wu", - "%G%qD output truncated copying %E bytes " + "%qD output truncated copying %E bytes " "from a string of length %wu", - stmt, func, cnt, lenrange[0].to_uhwi ()); + func, cnt, lenrange[0].to_uhwi ()); return warning_at (callloc, OPT_Wstringop_truncation, - "%G%qD output truncated copying between %wu " + "%qD output truncated copying between %wu " "and %wu bytes from a string of length %wu", - stmt, func, cntrange[0].to_uhwi (), + func, cntrange[0].to_uhwi (), cntrange[1].to_uhwi (), lenrange[0].to_uhwi ()); } else if (wi::geu_p (lenrange[1], cntrange[1])) @@ -3017,16 +3016,16 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt, if (cntrange[0] == cntrange[1]) return warning_n (callloc, OPT_Wstringop_truncation, cntrange[0].to_uhwi (), - "%G%qD output may be truncated copying %E " + "%qD output may be truncated copying %E " "byte from a string of length %wu", - "%G%qD output may be truncated copying %E " + "%qD output may be truncated copying %E " "bytes from a string of length %wu", - stmt, func, cnt, lenrange[1].to_uhwi ()); + func, cnt, lenrange[1].to_uhwi ()); return warning_at (callloc, OPT_Wstringop_truncation, - "%G%qD output may be truncated copying between " + "%qD output may be truncated copying between " "%wu and %wu bytes from a string of length %wu", - stmt, func, cntrange[0].to_uhwi (), + func, cntrange[0].to_uhwi (), cntrange[1].to_uhwi (), lenrange[1].to_uhwi ()); } } @@ -3040,9 +3039,9 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt, the lower bound of the specified count but shorter than the upper bound the copy may (but need not) be truncated. */ return warning_at (callloc, OPT_Wstringop_truncation, - "%G%qD output may be truncated copying between " + "%qD output may be truncated copying between " "%wu and %wu bytes from a string of length %wu", - stmt, func, cntrange[0].to_uhwi (), + func, cntrange[0].to_uhwi (), cntrange[1].to_uhwi (), lenrange[0].to_uhwi ()); } } @@ -3069,8 +3068,8 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt, if (cntrange[0] == cntrange[1]) return warning_at (callloc, OPT_Wstringop_truncation, - "%G%qD specified bound %E equals destination size", - stmt, func, cnt); + "%qD specified bound %E equals destination size", + func, cnt); } return false; @@ -3193,9 +3192,9 @@ handle_builtin_stxncpy_strncat (bool append_p, gimple_stmt_iterator *gsi) && sisrc == silen && is_strlen_related_p (src, len) && warning_at (callloc, OPT_Wstringop_truncation, - "%G%qD output truncated before terminating nul " + "%qD output truncated before terminating nul " "copying as many bytes from a string as its length", - stmt, func)) + func)) warned = true; else if ((append_p || !dstsize || len == dstlenp1) && silen && is_strlen_related_p (src, silen->ptr)) @@ -3206,9 +3205,9 @@ handle_builtin_stxncpy_strncat (bool append_p, gimple_stmt_iterator *gsi) int opt = (append_p || dstsize ? OPT_Wstringop_overflow_ : OPT_Wstringop_truncation); warned = warning_at (callloc, opt, - "%G%qD specified bound depends on the length " + "%qD specified bound depends on the length " "of the source argument", - stmt, func); + func); } if (warned) { @@ -4140,24 +4139,24 @@ maybe_warn_pointless_strcmp (gimple *stmt, HOST_WIDE_INT bound, if (siz <= minlen && bound == -1) warned = warning_at (stmt_loc, OPT_Wstring_compare, (at_least - ? G_("%G%qD of a string of length %wu or more and " + ? G_("%qD of a string of length %wu or more and " "an array of size %wu evaluates to nonzero") - : G_("%G%qD of a string of length %wu and an array " + : G_("%qD of a string of length %wu and an array " "of size %wu evaluates to nonzero")), - stmt, callee, minlen, siz); + callee, minlen, siz); else if (!at_least && siz <= HOST_WIDE_INT_MAX) { if (len[0] != HOST_WIDE_INT_MAX && len[1] != HOST_WIDE_INT_MAX) warned = warning_at (stmt_loc, OPT_Wstring_compare, - "%G%qD of strings of length %wu and %wu " + "%qD of strings of length %wu and %wu " "and bound of %wu evaluates to nonzero", - stmt, callee, len[0], len[1], bound); + callee, len[0], len[1], bound); else warned = warning_at (stmt_loc, OPT_Wstring_compare, - "%G%qD of a string of length %wu, an array " + "%qD of a string of length %wu, an array " "of size %wu and bound of %wu evaluates to " "nonzero", - stmt, callee, minlen, siz, bound); + callee, minlen, siz, bound); } if (!warned) diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c index 7c002f8ed87..6c8fe12fd39 100644 --- a/gcc/tree-ssa-uninit.c +++ b/gcc/tree-ssa-uninit.c @@ -428,7 +428,7 @@ maybe_warn_operand (ao_ref &ref, gimple *stmt, tree lhs, tree rhs, if (wlims.always_executed) { if (warning_at (location, OPT_Wuninitialized, - "%G%qE is used uninitialized", stmt, rhs)) + "%qE is used uninitialized", rhs)) { /* ??? This is only effective for decls as in gcc.dg/uninit-B-O0.c. Avoid doing this for maybe-uninit @@ -441,7 +441,7 @@ maybe_warn_operand (ao_ref &ref, gimple *stmt, tree lhs, tree rhs, } else if (wlims.wmaybe_uninit) warned = warning_at (location, OPT_Wmaybe_uninitialized, - "%G%qE may be used uninitialized", stmt, rhs); + "%qE may be used uninitialized", rhs); return warned ? base : NULL_TREE; } From patchwork Thu Jun 10 23:28:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 1490686 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=ZDO1UMv2; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G1Kv66tTfz9sWF for ; Fri, 11 Jun 2021 09:29:38 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2D44739BD42C for ; Thu, 10 Jun 2021 23:29:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2D44739BD42C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1623367776; bh=WvByezBfQK+Wd2OxVNTyU78Oq8V+WZbgKz22rcCACvU=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=ZDO1UMv2zqrSUdcM6MEkTM0oXp8LrJG1qIYbhFeXY5boSyq3XDfn9zyw6OjuQ4IaV VjKa1OApvDfYkuxYgmmO/ycIZmjZkwFaLC8pZRPLsFx4s76maQHFwZbyuy6g+o7UHS nVRlfHaAm4iWzQ8J2580cF1huy8FPmWjuRiBGaZM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) by sourceware.org (Postfix) with ESMTPS id 3451839BDC0E for ; Thu, 10 Jun 2021 23:28:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3451839BDC0E Received: by mail-ot1-x32c.google.com with SMTP id j11-20020a9d738b0000b02903ea3c02ded8so1409430otk.5 for ; Thu, 10 Jun 2021 16:28:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=WvByezBfQK+Wd2OxVNTyU78Oq8V+WZbgKz22rcCACvU=; b=ZCWjHvt4+OjFEZHakHXdHP7wJldZ37XbNadO5r0FroTF4muoTKi6nqjWb9X08Zj7P+ vfM9Nhz5SuIWwOGj50XJFQ6QmaJA9W1lcTuV47NReionW9Q51rkaPlGewGUpFjLgpmyl QEkbQb7OAdLGYTR/T95MZqX5GcVZUlTHbs/7bkLiJioz08b6vc4XzfXZup4YMjnagZN+ 7SWQXXK/52ik5fG+VWmi9erINVYzOnUUrZgvXy5OsnrLqYdE+erPocjUdC0WkZEEkUL0 yJclwPlvGdw5UIpM2TJq+wPiofKmDZ2CtUDrGjI1Dum03Z0H7euQijotoVMdwHlV1FdX K1lQ== X-Gm-Message-State: AOAM531sos57UEat8AKZ1/bwDl1135Efoil8IRwcv+CnkzroruFAC2uP 9LUPxJgQ6kVInngjFKO7nnPw1tnZR5c= X-Google-Smtp-Source: ABdhPJy16p7wjU23ljn5lW0NtrSuDl7am2Ad0mdhnp9bj0GmvOlicElItuKMHN0Yszmx4z7MlU9mJA== X-Received: by 2002:a05:6830:99:: with SMTP id a25mr649742oto.72.1623367726566; Thu, 10 Jun 2021 16:28:46 -0700 (PDT) Received: from [192.168.0.41] (97-118-122-241.hlrn.qwest.net. [97.118.122.241]) by smtp.gmail.com with ESMTPSA id q22sm871399otl.11.2021.06.10.16.28.45 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 10 Jun 2021 16:28:46 -0700 (PDT) Subject: [PATCH 3/4] remove %K from error() calls in the aarch64/arm back ends (PR 98512) To: gcc-patches References: <2e49b6c6-a403-a207-c41e-58f78df96b84@gmail.com> <945093c7-de5e-0350-6030-e4e79ea41161@gmail.com> <5aff247f-dfcb-cecf-e07e-b5fca877f911@gmail.com> Message-ID: <24e1d1ea-33a0-bab8-3182-1dbb90ff7e3c@gmail.com> Date: Thu, 10 Jun 2021 17:28:45 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <5aff247f-dfcb-cecf-e07e-b5fca877f911@gmail.com> Content-Language: en-US X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Martin Sebor via Gcc-patches From: Martin Sebor Reply-To: Martin Sebor Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This patch removes the uses of %K from error() calls in the aarch64 and arm back ends. I tested this change only by building a cross- compiler but I can't easily run the tests so I'd appreciate some help validating it. The fallout from the change should be limited to changes to error messages so in the worst case it could be addressed after committing the patch. gcc/ChangeLog: * config/aarch64/aarch64-builtins.c (aarch64_simd_expand_builtin): Remove %K and use error_at. (aarch64_expand_fcmla_builtin): Same. (aarch64_expand_builtin_tme): Same. (aarch64_expand_builtin_memtag): Same. * config/arm/arm-builtins.c (arm_expand_acle_builtin): Same. (arm_expand_builtin): Same. * config/arm/arm.c (bounds_check): Same. diff --git a/gcc/config/aarch64/aarch64-builtins.c b/gcc/config/aarch64/aarch64-builtins.c index 3cab3ec992c..9ed4b72d005 100644 --- a/gcc/config/aarch64/aarch64-builtins.c +++ b/gcc/config/aarch64/aarch64-builtins.c @@ -1598,8 +1598,9 @@ constant_arg: if (!(*insn_data[icode].operand[opc].predicate) (op[opc], mode)) { - error ("%Kargument %d must be a constant immediate", - exp, opc + 1 - have_retval); + error_at (EXPR_LOCATION (exp), + "argument %d must be a constant immediate", + opc + 1 - have_retval); return const0_rtx; } break; @@ -1669,10 +1670,13 @@ aarch64_simd_expand_builtin (int fcode, tree exp, rtx target) / UINTVAL (elementsize), exp); else - error ("%Klane index must be a constant immediate", exp); + error_at (EXPR_LOCATION (exp), + "lane index must be a constant immediate"); } else - error ("%Ktotal size and element size must be a non-zero constant immediate", exp); + error_at (EXPR_LOCATION (exp), + "total size and element size must be a non-zero " + "constant immediate"); /* Don't generate any RTL. */ return const0_rtx; } @@ -1828,7 +1832,8 @@ aarch64_expand_fcmla_builtin (tree exp, rtx target, int fcode) /* Validate that the lane index is a constant. */ if (!CONST_INT_P (lane_idx)) { - error ("%Kargument %d must be a constant immediate", exp, 4); + error_at (EXPR_LOCATION (exp), + "argument %d must be a constant immediate", 4); return const0_rtx; } @@ -1917,7 +1922,8 @@ aarch64_expand_builtin_tme (int fcode, tree exp, rtx target) emit_insn (GEN_FCN (CODE_FOR_tcancel) (op0)); else { - error ("%Kargument must be a 16-bit constant immediate", exp); + error_at (EXPR_LOCATION (exp), + "argument must be a 16-bit constant immediate"); return const0_rtx; } } @@ -2006,8 +2012,9 @@ aarch64_expand_builtin_memtag (int fcode, tree exp, rtx target) pat = GEN_FCN (icode) (target, op0, const0_rtx, op1); break; } - error ("%Kargument %d must be a constant immediate " - "in range [0,15]", exp, 2); + error_at (EXPR_LOCATION (exp), + "argument %d must be a constant immediate " + "in range [0,15]", 2); return const0_rtx; } else diff --git a/gcc/config/arm/arm-builtins.c b/gcc/config/arm/arm-builtins.c index fa0fb0b16ab..3a9ff8f26b8 100644 --- a/gcc/config/arm/arm-builtins.c +++ b/gcc/config/arm/arm-builtins.c @@ -3092,26 +3092,30 @@ constant_arg: unsigned int cp_bit = (CONST_INT_P (op[argc]) ? UINTVAL (op[argc]) : -1); if (IN_RANGE (cp_bit, 0, ARM_CDE_CONST_COPROC)) - error ("%Kcoprocessor %d is not enabled " - "with +cdecp%d", exp, cp_bit, cp_bit); + error_at (EXPR_LOCATION (exp), + "coprocessor %d is not enabled " + "with +cdecp%d", cp_bit, cp_bit); else - error ("%Kcoproc must be a constant immediate in " - "range [0-%d] enabled with +cdecp", exp, - ARM_CDE_CONST_COPROC); + error_at (EXPR_LOCATION (exp), + "coproc must be a constant immediate in " + "range [0-%d] enabled with +cdecp", + ARM_CDE_CONST_COPROC); } else /* Here we mention the builtin name to follow the same format that the C/C++ frontends use for referencing a given argument index. */ - error ("%Kargument %d to %qE must be a constant immediate " - "in range [0-%d]", exp, argc + 1, + error_at (EXPR_LOCATION (exp), + "argument %d to %qE must be a constant " + "immediate in range [0-%d]", argc + 1, arm_builtin_decls[fcode], cde_builtin_data[fcode - ARM_BUILTIN_CDE_PATTERN_START].imm_max); } else - error ("%Kargument %d must be a constant immediate", - exp, argc + 1); + error_at (EXPR_LOCATION (exp), + "argument %d must be a constant immediate", + argc + 1); /* We have failed to expand the pattern, and are safely in to invalid code. But the mid-end will still try to build an assignment for this node while it expands, @@ -3328,11 +3332,13 @@ arm_expand_acle_builtin (int fcode, tree exp, rtx target) if (CONST_INT_P (sat_imm)) { if (!IN_RANGE (sat_imm, min_sat, max_sat)) - error ("%Ksaturation bit range must be in the range [%wd, %wd]", - exp, UINTVAL (min_sat), UINTVAL (max_sat)); + error_at (EXPR_LOCATION (exp), + "saturation bit range must be in the range [%wd, %wd]", + UINTVAL (min_sat), UINTVAL (max_sat)); } else - error ("%Ksaturation bit range must be a constant immediate", exp); + error_at (EXPR_LOCATION (exp), + "saturation bit range must be a constant immediate"); /* Don't generate any RTL. */ return const0_rtx; } @@ -3455,7 +3461,8 @@ arm_expand_builtin (tree exp, if (CONST_INT_P (lane_idx)) neon_lane_bounds (lane_idx, 0, TREE_INT_CST_LOW (nlanes), exp); else - error ("%Klane index must be a constant immediate", exp); + error_at (EXPR_LOCATION (exp), + "lane index must be a constant immediate"); /* Don't generate any RTL. */ return const0_rtx; } diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 7b37e1b602c..7cdc824730c 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -13242,13 +13242,8 @@ bounds_check (rtx operand, HOST_WIDE_INT low, HOST_WIDE_INT high, lane = INTVAL (operand); if (lane < low || lane >= high) - { - if (exp) - error ("%K%s %wd out of range %wd - %wd", - exp, desc, lane, low, high - 1); - else - error ("%s %wd out of range %wd - %wd", desc, lane, low, high - 1); - } + error_at (EXPR_LOCATION (exp), + "%s %wd out of range %wd - %wd", desc, lane, low, high - 1); } /* Bounds-check lanes. */ From patchwork Thu Jun 10 23:30:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 1490688 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=Cgnyk1t9; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G1KwH2QzBz9s1l for ; Fri, 11 Jun 2021 09:30:38 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 461BA39BDC0E for ; Thu, 10 Jun 2021 23:30:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 461BA39BDC0E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1623367836; bh=wdbp0Dgk/4RSjJpEEPqgkBdpqNGO0WJFqhEiINDzsOE=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Cgnyk1t9aAYDHMShq+r5yWC+pEsTqpia2ycArM3EB+AZzDy/Vb2VjzgycIZN5Cm4W NNYJVUZoijSy4hD6Y/RslkOSWboYG2hxFWqjPOZwDJzArnHc5Xo1xZucXNZWC9Zaaw VQ5F1SB3Aak1M7iuSDsulCf/l6ZByK0ucA3j3iXU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) by sourceware.org (Postfix) with ESMTPS id 5ED0B39BD410 for ; Thu, 10 Jun 2021 23:30:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5ED0B39BD410 Received: by mail-ot1-x32c.google.com with SMTP id v27-20020a056830091bb02903cd67d40070so1431683ott.1 for ; Thu, 10 Jun 2021 16:30:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=wdbp0Dgk/4RSjJpEEPqgkBdpqNGO0WJFqhEiINDzsOE=; b=ASc2ykkkb1bsrXzrfuHOGaSGSq/Mns+1GKdXU/5VdHdzrnjmUP93Q+mmUdci8/zqat D3MeIATWh0whG0g8hz2KZ730OXYalVVeUDcszjgXAc8gZQm9hxHkW1dH2ldgvx+Ad/bv A//DyYowOKVutnNcfSvj9oaRbUGmlUInd6S9aUHH3syqf+7Sgnwe7+1B9n6h+7aMIAHM KGUE7FsuK/A40je3OBy4uWxh14EGlewbuCpRsPcXhhcAHaDbcrCM0edismsdrTV60emX v9kJtOiOi3QgDHdDyuytBQEx/0vh+qN2ep/vnEX01c85wNCbzdqWtPN3RFDcTjM1m6Tg 0D0Q== X-Gm-Message-State: AOAM532xtzUOFCXeCccpDtI630QVVkEDTsDu0XxIFdvvnJ0fg4bSHa4V 5d97hnS4xOBW0lUGwkHg0OGz3RuJZi8= X-Google-Smtp-Source: ABdhPJwZcCuDIf0vEVNAMHQNilaTjAEEppaNg9sQYmYISItOFNaxjcVJL991WH5PdlNDonbu5TYM8w== X-Received: by 2002:a9d:7096:: with SMTP id l22mr630987otj.79.1623367801715; Thu, 10 Jun 2021 16:30:01 -0700 (PDT) Received: from [192.168.0.41] (97-118-122-241.hlrn.qwest.net. [97.118.122.241]) by smtp.gmail.com with ESMTPSA id z14sm904567oti.29.2021.06.10.16.30.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 10 Jun 2021 16:30:01 -0700 (PDT) Subject: [PATCH 4/4] remove %G and %K support from pretty printer and -Wformat (PR 98512) To: David Malcolm , gcc-patches References: <2e49b6c6-a403-a207-c41e-58f78df96b84@gmail.com> <945093c7-de5e-0350-6030-e4e79ea41161@gmail.com> <5aff247f-dfcb-cecf-e07e-b5fca877f911@gmail.com> Message-ID: Date: Thu, 10 Jun 2021 17:30:00 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <5aff247f-dfcb-cecf-e07e-b5fca877f911@gmail.com> Content-Language: en-US X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Martin Sebor via Gcc-patches From: Martin Sebor Reply-To: Martin Sebor Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This final diff removes the handlers for %G and %K from the pretty printer and the support for the directives from c-format.c so that using them will be diagnosed. gcc/c-family/ChangeLog: * c-format.c (gcc_tdiag_char_table): Remove support for %G and %K. (gcc_cdiag_char_table): Same. (gcc_cxxdiag_char_table): Same. gcc/c/ChangeLog: * c-objc-common.c (c_tree_printer): Remove support for %G and %K. gcc/cp/ChangeLog: * error.c (cp_printer): Remove support for %G and %K. gcc/ChangeLog: * gimple-pretty-print.c (percent_G_format): Remove. * tree-diagnostic.c (default_tree_printer): Remove calls. * tree-pretty-print.c (percent_K_format): Remove. * tree-pretty-print.h (percent_K_format): Remove. gcc/testsuite/ChangeLog: * gcc.dg/format/gcc_diag-10.c: Update expected warnings. diff --git a/gcc/c-family/c-format.c b/gcc/c-family/c-format.c index bda3b18fcd0..6fd0bb33d21 100644 --- a/gcc/c-family/c-format.c +++ b/gcc/c-family/c-format.c @@ -781,10 +781,6 @@ static const format_char_info gcc_tdiag_char_table[] = /* These will require a "tree" at runtime. */ { "DFTV", 1, STD_C89, { T89_T, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q+", "'", NULL }, { "E", 1, STD_C89, { T89_T, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q+", "", NULL }, - { "K", 1, STD_C89, { T89_T, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "\"", NULL }, - - /* G requires a "gimple*" argument at runtime. */ - { "G", 1, STD_C89, { T89_G, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "\"", NULL }, { NULL, 0, STD_C89, NOLENGTHS, NULL, NULL, NULL } }; @@ -799,10 +795,6 @@ static const format_char_info gcc_cdiag_char_table[] = /* These will require a "tree" at runtime. */ { "DFTV", 1, STD_C89, { T89_T, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q+", "'", NULL }, { "E", 1, STD_C89, { T89_T, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q+", "", NULL }, - { "K", 1, STD_C89, { T89_T, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "\"", NULL }, - - /* G requires a "gimple*" argument at runtime. */ - { "G", 1, STD_C89, { T89_G, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "\"", NULL }, { "v", 0, STD_C89, { T89_I, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q#", "", NULL }, @@ -819,10 +811,6 @@ static const format_char_info gcc_cxxdiag_char_table[] = /* These will require a "tree" at runtime. */ { "ADFHISTVX",1,STD_C89,{ T89_T, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q+#", "'", NULL }, { "E", 1,STD_C89,{ T89_T, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q+#", "", NULL }, - { "K", 1, STD_C89,{ T89_T, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "\"", NULL }, - - /* G requires a "gimple*" argument at runtime. */ - { "G", 1, STD_C89,{ T89_G, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "\"", NULL }, /* These accept either an 'int' or an 'enum tree_code' (which is handled as an 'int'.) */ { "CLOPQ",0,STD_C89, { T89_I, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q", "", NULL }, diff --git a/gcc/c/c-objc-common.c b/gcc/c/c-objc-common.c index b945de15ab8..cdb2242758e 100644 --- a/gcc/c/c-objc-common.c +++ b/gcc/c/c-objc-common.c @@ -247,8 +247,6 @@ print_type (c_pretty_printer *cpp, tree t, bool *quoted) %D: a general decl, %E: an identifier or expression, %F: a function declaration, - %G: a Gimple statement, - %K: a CALL_EXPR, %T: a type. %V: a list of type qualifiers from a tree. %v: an explicit list of type qualifiers @@ -269,19 +267,6 @@ c_tree_printer (pretty_printer *pp, text_info *text, const char *spec, if (precision != 0 || wide) return false; - if (*spec == 'G') - { - percent_G_format (text); - return true; - } - - if (*spec == 'K') - { - t = va_arg (*text->args_ptr, tree); - percent_K_format (text, EXPR_LOCATION (t), TREE_BLOCK (t)); - return true; - } - if (*spec != 'v') { t = va_arg (*text->args_ptr, tree); diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 4a89b348829..012a4ecddf4 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -4338,10 +4338,8 @@ defer_phase_2_of_type_diff (deferred_printed_type *deferred, %D declaration. %E expression. %F function declaration. - %G gcall * %H type difference (from). %I type difference (to). - %K tree %L language as used in extern "lang". %O binary operator. %P function parameter whose position is indicated by an integer. @@ -4391,9 +4389,6 @@ cp_printer (pretty_printer *pp, text_info *text, const char *spec, break; case 'E': result = expr_to_string (next_tree); break; case 'F': result = fndecl_to_string (next_tree, verbose); break; - case 'G': - percent_G_format (text); - return true; case 'H': defer_phase_2_of_type_diff (&postprocessor->m_type_a, next_tree, buffer_ptr, verbose, *quoted); @@ -4402,10 +4397,6 @@ cp_printer (pretty_printer *pp, text_info *text, const char *spec, defer_phase_2_of_type_diff (&postprocessor->m_type_b, next_tree, buffer_ptr, verbose, *quoted); return true; - case 'K': - t = va_arg (*text->args_ptr, tree); - percent_K_format (text, EXPR_LOCATION (t), TREE_BLOCK (t)); - return true; case 'L': result = language_to_string (next_lang); break; case 'O': result = op_to_string (false, next_tcode); break; case 'P': result = parm_to_string (next_int); break; diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c index c9c0a66ee30..474f3b6953e 100644 --- a/gcc/gimple-pretty-print.c +++ b/gcc/gimple-pretty-print.c @@ -3056,23 +3056,6 @@ gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb) pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true); } - -/* Handle the %G format for TEXT. Same as %K in handle_K_format in - tree-pretty-print.c but with a Gimple statement as an argument. */ - -void -percent_G_format (text_info *text) -{ - gimple *stmt = va_arg (*text->args_ptr, gimple*); - - /* Fall back on the rich location if the statement doesn't have one. */ - location_t loc = gimple_location (stmt); - if (loc == UNKNOWN_LOCATION) - loc = text->m_richloc->get_loc (); - tree block = gimple_block (stmt); - percent_K_format (text, loc, block); -} - #if __GNUC__ >= 10 # pragma GCC diagnostic pop #endif diff --git a/gcc/testsuite/gcc.dg/format/gcc_diag-10.c b/gcc/testsuite/gcc.dg/format/gcc_diag-10.c index a2f99feefc9..3bce538e9fe 100644 --- a/gcc/testsuite/gcc.dg/format/gcc_diag-10.c +++ b/gcc/testsuite/gcc.dg/format/gcc_diag-10.c @@ -64,8 +64,8 @@ void test_cdiag (tree t, gimple *gc) cdiag ("%D", t); /* { dg-warning ".D. conversion used unquoted" } */ cdiag ("%E", t); cdiag ("%F", t); /* { dg-warning ".F. conversion used unquoted" } */ - cdiag ("%G", gc); - cdiag ("%K", t); + cdiag ("%G", gc); /* { dg-warning "format" } */ + cdiag ("%K", t); /* { dg-warning "format" } */ cdiag ("%R"); /* { dg-warning "unmatched color reset directive" } */ cdiag ("%r", ""); /* { dg-warning "unterminated color directive" } */ @@ -80,8 +80,8 @@ void test_cdiag (tree t, gimple *gc) cdiag ("%<%D%>", t); cdiag ("%<%E%>", t); cdiag ("%<%F%>", t); - cdiag ("%<%G%>", gc); /* { dg-warning ".G. conversion used within a quoted sequence" } */ - cdiag ("%<%K%>", t); /* { dg-warning ".K. conversion used within a quoted sequence" } */ + cdiag ("%<%G%>", gc); /* { dg-warning "format" } */ + cdiag ("%<%K%>", t); /* { dg-warning "format" } */ cdiag ("%<%R%>"); /* { dg-warning "unmatched color reset directive" } */ cdiag ("%<%r%>", ""); /* { dg-warning "unterminated color directive" } */ @@ -103,8 +103,8 @@ void test_tdiag (tree t, gimple *gc) tdiag ("%D", t); /* { dg-warning ".D. conversion used unquoted" } */ tdiag ("%E", t); - tdiag ("%G", gc); - tdiag ("%K", t); + tdiag ("%G", gc); /* { dg-warning "format" } */ + tdiag ("%K", t); /* { dg-warning "format" } */ tdiag ("%R"); /* { dg-warning "unmatched color reset directive" } */ tdiag ("%r", ""); /* { dg-warning "unterminated color directive" } */ @@ -118,8 +118,8 @@ void test_tdiag (tree t, gimple *gc) tdiag ("%<%D%>", t); tdiag ("%<%E%>", t); - tdiag ("%<%G%>", gc); /* { dg-warning ".G. conversion used within a quoted sequence" } */ - tdiag ("%<%K%>", t); /* { dg-warning ".K. conversion used within a quoted sequence" } */ + tdiag ("%<%G%>", gc); /* { dg-warning "format" } */ + tdiag ("%<%K%>", t); /* { dg-warning "format" } */ tdiag ("%<%R%>"); /* { dg-warning "unmatched color reset directive" } */ tdiag ("%<%r%>", ""); /* { dg-warning "unterminated color directive" } */ @@ -138,8 +138,8 @@ void test_cxxdiag (tree t, gimple *gc) cxxdiag ("%D", t); /* { dg-warning ".D. conversion used unquoted" } */ cxxdiag ("%E", t); cxxdiag ("%F", t); /* { dg-warning ".F. conversion used unquoted" } */ - cxxdiag ("%G", gc); - cxxdiag ("%K", t); + cxxdiag ("%G", gc); /* { dg-warning "format" } */ + cxxdiag ("%K", t); /* { dg-warning "format" } */ cxxdiag ("%R"); /* { dg-warning "unmatched color reset directive" } */ cxxdiag ("%r", ""); /* { dg-warning "unterminated color directive" } */ @@ -185,7 +185,7 @@ void test_dump (tree t, gimple *stmt, cgraph_node *node) dump ("%E", stmt); dump ("%T", t); - dump ("%G", stmt); + dump ("%G", stmt); /* { dg-warning "format" } */ dump ("%C", node); dump ("%f", 1.0); dump ("%4.2f", 1.0); /* { dg-warning "format" } */ diff --git a/gcc/tree-diagnostic.c b/gcc/tree-diagnostic.c index a8c5484849a..614e654e2b2 100644 --- a/gcc/tree-diagnostic.c +++ b/gcc/tree-diagnostic.c @@ -276,15 +276,6 @@ default_tree_printer (pretty_printer *pp, text_info *text, const char *spec, t = va_arg (*text->args_ptr, tree); break; - case 'G': - percent_G_format (text); - return true; - - case 'K': - t = va_arg (*text->args_ptr, tree); - percent_K_format (text, EXPR_LOCATION (t), TREE_BLOCK (t)); - return true; - default: return false; } diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c index d8a4f55b2ae..df9828cec7b 100644 --- a/gcc/tree-pretty-print.c +++ b/gcc/tree-pretty-print.c @@ -4430,32 +4430,6 @@ newline_and_indent (pretty_printer *pp, int spc) INDENT (spc); } -/* Handle the %K format for TEXT. Separate from default_tree_printer - so it can also be used in front ends. - The location LOC and BLOCK are expected to be extracted by the caller - from the %K argument arg via EXPR_LOCATION(arg) and TREE_BLOCK(arg). */ - -void -percent_K_format (text_info *text, location_t loc, tree block) -{ - text->set_location (0, loc, SHOW_RANGE_WITH_CARET); - gcc_assert (pp_ti_abstract_origin (text) != NULL); - *pp_ti_abstract_origin (text) = NULL; - - while (block - && TREE_CODE (block) == BLOCK - && BLOCK_ABSTRACT_ORIGIN (block)) - { - tree ao = BLOCK_ABSTRACT_ORIGIN (block); - if (TREE_CODE (ao) == FUNCTION_DECL) - { - *pp_ti_abstract_origin (text) = block; - break; - } - block = BLOCK_SUPERCONTEXT (block); - } -} - /* Print the identifier ID to PRETTY-PRINTER. */ void diff --git a/gcc/tree-pretty-print.h b/gcc/tree-pretty-print.h index 92eb4123e79..1ada5983d5d 100644 --- a/gcc/tree-pretty-print.h +++ b/gcc/tree-pretty-print.h @@ -51,7 +51,6 @@ extern int op_prio (const_tree); extern const char *op_symbol_code (enum tree_code); extern void pretty_print_string (pretty_printer *, const char *, size_t); extern void print_call_name (pretty_printer *, tree, dump_flags_t); -extern void percent_K_format (text_info *, location_t, tree); extern void pp_tree_identifier (pretty_printer *, tree); extern void dump_function_header (FILE *, tree, dump_flags_t); extern void pp_double_int (pretty_printer *pp, double_int d, bool uns);