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);