From patchwork Wed Oct 7 13:45:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 1378013 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@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gcc.gnu.org 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=TwdC8BXx; 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 4C5wZx1kNDz9sTR for ; Thu, 8 Oct 2020 00:45:43 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3165C385783F; Wed, 7 Oct 2020 13:45:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3165C385783F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1602078340; bh=iupiuBkzpc1xkTE2lRgNYX8AuiaVBjUhptgVlkZQPOw=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=TwdC8BXx/636kaXlEOXNj3nVffGVSTDdVcv/LyacA8N337e2IWxplLdeEmPmmslgR /72PlEadw+nylrzlhBkqTrRiApz0FZQmmRtRf0oprVhsvA2rcm2gPxECKGOQcQ0RQt FDuEWDC+irEANn5LnciR4xrqYxW3xpDzFa7/Cm5w= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id 165283857C40 for ; Wed, 7 Oct 2020 13:45:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 165283857C40 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-582-EzftBbVUMdu4jBk2ic8Ckw-1; Wed, 07 Oct 2020 09:45:36 -0400 X-MC-Unique: EzftBbVUMdu4jBk2ic8Ckw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 300FF57055 for ; Wed, 7 Oct 2020 13:45:35 +0000 (UTC) Received: from t470.redhat.com (ovpn-112-135.phx2.redhat.com [10.3.112.135]) by smtp.corp.redhat.com (Postfix) with ESMTP id B7F5519C59; Wed, 7 Oct 2020 13:45:34 +0000 (UTC) To: gcc-patches@gcc.gnu.org Subject: [committed] Add -fdiagnostics-path-format=separate-events to -fdiagnostics-plain-output Date: Wed, 7 Oct 2020 09:45:33 -0400 Message-Id: <20201007134533.278106-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, 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: David Malcolm via Gcc-patches From: David Malcolm Reply-To: David Malcolm Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" The path-printing default of -fdiagnostics-path-format=inline-events interacted poorly with -fdiagnostics-plain-output, so it makes most sense to add -fdiagnostics-path-format=separate-events to -fdiagnostics-plain-output. Seen when adding an experimental analyzer plugin to gcc.dg/plugin.exp. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to master as 7345c89ecb1a31ce96c6789bffc7183268a040b3. gcc/ChangeLog: * doc/invoke.texi (-fdiagnostics-plain-output): Add -fdiagnostics-path-format=separate-events to list of options injected by -fdiagnostics-plain-output. * opts-common.c (decode_cmdline_options_to_array): Likewise. gcc/testsuite/ChangeLog: * g++.dg/analyzer/analyzer.exp (DEFAULT_CXXFLAGS): Remove -fdiagnostics-path-format=separate-events. * gcc.dg/analyzer/analyzer.exp (DEFAULT_CFLAGS): Likewise. * gcc.dg/plugin/diagnostic-path-format-default.c: Rename to... * gcc.dg/plugin/diagnostic-path-format-plain.c: ...this. Remove dg-options directive. Copy remainder of test from diagnostic-path-format-separate-events.c. * gcc.dg/plugin/diagnostic-test-paths-2.c: Add -fdiagnostics-path-format=inline-events to options. Fix expected output for location of conditional within "for" loop. * gcc.dg/plugin/plugin.exp (plugin_test_list): Update for renaming. * gfortran.dg/analyzer/analyzer.exp (DEFAULT_FFLAGS): Remove -fdiagnostics-path-format=separate-events. --- gcc/doc/invoke.texi | 3 +- gcc/opts-common.c | 1 + gcc/testsuite/g++.dg/analyzer/analyzer.exp | 2 +- gcc/testsuite/gcc.dg/analyzer/analyzer.exp | 2 +- .../plugin/diagnostic-path-format-default.c | 142 ------------------ .../plugin/diagnostic-path-format-plain.c | 42 ++++++ .../gcc.dg/plugin/diagnostic-test-paths-2.c | 8 +- gcc/testsuite/gcc.dg/plugin/plugin.exp | 2 +- .../gfortran.dg/analyzer/analyzer.exp | 2 +- 9 files changed, 53 insertions(+), 151 deletions(-) delete mode 100644 gcc/testsuite/gcc.dg/plugin/diagnostic-path-format-default.c create mode 100644 gcc/testsuite/gcc.dg/plugin/diagnostic-path-format-plain.c diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index f623467b763..d8bc4cc3267 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -4345,7 +4345,8 @@ options: @gccoptlist{-fno-diagnostics-show-caret @gol -fno-diagnostics-show-line-numbers @gol -fdiagnostics-color=never @gol --fdiagnostics-urls=never} +-fdiagnostics-urls=never @gol +-fdiagnostics-path-format=separate-events} In the future, if GCC changes the default appearance of its diagnostics, the corresponding option to disable the new behavior will be added to this list. diff --git a/gcc/opts-common.c b/gcc/opts-common.c index 237e4ce454e..8ec8c1ec1a8 100644 --- a/gcc/opts-common.c +++ b/gcc/opts-common.c @@ -1000,6 +1000,7 @@ decode_cmdline_options_to_array (unsigned int argc, const char **argv, "-fno-diagnostics-show-line-numbers", "-fdiagnostics-color=never", "-fdiagnostics-urls=never", + "-fdiagnostics-path-format=separate-events", }; const int num_expanded = ARRAY_SIZE (expanded_args); opt_array_len += num_expanded - 1; diff --git a/gcc/testsuite/g++.dg/analyzer/analyzer.exp b/gcc/testsuite/g++.dg/analyzer/analyzer.exp index 60262f678ee..78edff2d11b 100644 --- a/gcc/testsuite/g++.dg/analyzer/analyzer.exp +++ b/gcc/testsuite/g++.dg/analyzer/analyzer.exp @@ -29,7 +29,7 @@ if [info exists DEFAULT_CXXFLAGS] then { } # If a testcase doesn't have special options, use these. -set DEFAULT_CXXFLAGS " -fanalyzer -fdiagnostics-path-format=separate-events -Wanalyzer-too-complex -fanalyzer-call-summaries" +set DEFAULT_CXXFLAGS " -fanalyzer -Wanalyzer-too-complex -fanalyzer-call-summaries" # Initialize `dg'. dg-init diff --git a/gcc/testsuite/gcc.dg/analyzer/analyzer.exp b/gcc/testsuite/gcc.dg/analyzer/analyzer.exp index ac9c49511aa..d72fef37ede 100644 --- a/gcc/testsuite/gcc.dg/analyzer/analyzer.exp +++ b/gcc/testsuite/gcc.dg/analyzer/analyzer.exp @@ -30,7 +30,7 @@ if [info exists DEFAULT_CFLAGS] then { } # If a testcase doesn't have special options, use these. -set DEFAULT_CFLAGS "-fanalyzer -fdiagnostics-path-format=separate-events -Wanalyzer-too-complex -fanalyzer-call-summaries" +set DEFAULT_CFLAGS "-fanalyzer -Wanalyzer-too-complex -fanalyzer-call-summaries" # Initialize `dg'. dg-init diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-path-format-default.c b/gcc/testsuite/gcc.dg/plugin/diagnostic-path-format-default.c deleted file mode 100644 index 5712dbd6472..00000000000 --- a/gcc/testsuite/gcc.dg/plugin/diagnostic-path-format-default.c +++ /dev/null @@ -1,142 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-fdiagnostics-show-caret" } */ - -#include - -void *wrapped_malloc (size_t size) -{ - return malloc (size); -} - -void wrapped_free (void *ptr) -{ - free (ptr); /* { dg-warning "double-free of 'ptr' \\\[CWE-415\\]" } */ - /* { dg-begin-multiline-output "" } - free (ptr); - ^~~~~~~~~~ - 'test': events 1-2 - | - | { - | ^ - | | - | (1) entering 'test' - | boxed_int *obj = make_boxed_int (i); - | ~~~~~~~~~~~~~~~~~~ - | | - | (2) calling 'make_boxed_int' - | - +--> 'make_boxed_int': events 3-4 - | - | { - | ^ - | | - | (3) entering 'make_boxed_int' - | boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int)); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - | | - | (4) calling 'wrapped_malloc' - | - +--> 'wrapped_malloc': events 5-6 - | - | { - | ^ - | | - | (5) entering 'wrapped_malloc' - | return malloc (size); - | ~~~~~~~~~~~~~ - | | - | (6) calling 'malloc' - | - <-------------+ - | - 'test': event 7 - | - | free_boxed_int (obj); - | ^~~~~~~~~~~~~~~~~~~~ - | | - | (7) calling 'free_boxed_int' - | - +--> 'free_boxed_int': events 8-9 - | - | { - | ^ - | | - | (8) entering 'free_boxed_int' - | wrapped_free (bi); - | ~~~~~~~~~~~~~~~~~ - | | - | (9) calling 'wrapped_free' - | - +--> 'wrapped_free': events 10-11 - | - | { - | ^ - | | - | (10) entering 'wrapped_free' - | free (ptr); - | ~~~~~~~~~~ - | | - | (11) calling 'free' - | - <-------------+ - | - 'test': event 12 - | - | free_boxed_int (obj); - | ^~~~~~~~~~~~~~~~~~~~ - | | - | (12) calling 'free_boxed_int' - | - +--> 'free_boxed_int': events 13-14 - | - | { - | ^ - | | - | (13) entering 'free_boxed_int' - | wrapped_free (bi); - | ~~~~~~~~~~~~~~~~~ - | | - | (14) calling 'wrapped_free' - | - +--> 'wrapped_free': events 15-16 - | - | { - | ^ - | | - | (15) entering 'wrapped_free' - | free (ptr); - | ~~~~~~~~~~ - | | - | (16) calling 'free' - | - { dg-end-multiline-output "" } */ -} - -typedef struct boxed_int -{ - int i; -} boxed_int; - -boxed_int * -make_boxed_int (int i) -{ - boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int)); - result->i = i; - return result; -} - -void -free_boxed_int (boxed_int *bi) -{ - wrapped_free (bi); -} - -void test (int i) -{ - boxed_int *obj = make_boxed_int (i); - - free_boxed_int (obj); - - free_boxed_int (obj); -} - diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-path-format-plain.c b/gcc/testsuite/gcc.dg/plugin/diagnostic-path-format-plain.c new file mode 100644 index 00000000000..75acd258c3b --- /dev/null +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-path-format-plain.c @@ -0,0 +1,42 @@ +/* { dg-do compile } */ + +#include + +void *wrapped_malloc (size_t size) +{ + return malloc (size); +} + +void wrapped_free (void *ptr) +{ + free (ptr); /* { dg-warning "double-free of 'ptr' \\\[CWE-415\\]" } */ +} + +typedef struct boxed_int +{ + int i; +} boxed_int; + +boxed_int * +make_boxed_int (int i) +{ + boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int)); + result->i = i; + return result; +} + +void +free_boxed_int (boxed_int *bi) +{ + wrapped_free (bi); +} + +void test (int i) +{ /* { dg-message "\\(1\\) entering 'test'" } */ + boxed_int *obj = make_boxed_int (i); /* { dg-message "\\(2\\) calling 'make_boxed_int'" } */ + /* etc */ + + free_boxed_int (obj); + + free_boxed_int (obj); +} diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-paths-2.c b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-paths-2.c index 946a234dd23..b2b269a12b5 100644 --- a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-paths-2.c +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-paths-2.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-fdiagnostics-show-caret -fdiagnostics-show-line-numbers" } */ +/* { dg-options "-fdiagnostics-show-caret -fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events" } */ #include #include @@ -43,9 +43,9 @@ make_a_list_of_random_ints_badly(PyObject *self, | | (1) when 'PyList_New' fails, returning NULL | 26 | | 27 | for (i = 0; i < count; i++) { - | | ~~~ - | | | - | | (2) when 'i < count' + | | ~~~~~~~~~ + | | | + | | (2) when 'i < count' | 28 | item = PyLong_FromLong(random()); | 29 | PyList_Append(list, item); | | ~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/gcc/testsuite/gcc.dg/plugin/plugin.exp b/gcc/testsuite/gcc.dg/plugin/plugin.exp index c02b0082715..5dd102ae05c 100644 --- a/gcc/testsuite/gcc.dg/plugin/plugin.exp +++ b/gcc/testsuite/gcc.dg/plugin/plugin.exp @@ -100,7 +100,7 @@ set plugin_test_list [list \ diagnostic-test-paths-2.c \ diagnostic-test-paths-3.c \ diagnostic-test-paths-4.c \ - diagnostic-path-format-default.c \ + diagnostic-path-format-plain.c \ diagnostic-path-format-none.c \ diagnostic-path-format-separate-events.c \ diagnostic-path-format-inline-events-1.c \ diff --git a/gcc/testsuite/gfortran.dg/analyzer/analyzer.exp b/gcc/testsuite/gfortran.dg/analyzer/analyzer.exp index 00edfa54dce..462395c935c 100644 --- a/gcc/testsuite/gfortran.dg/analyzer/analyzer.exp +++ b/gcc/testsuite/gfortran.dg/analyzer/analyzer.exp @@ -33,7 +33,7 @@ if [info exists DEFAULT_FFLAGS] then { } # If a testcase doesn't have special options, use these. -set DEFAULT_FFLAGS "-fanalyzer -fdiagnostics-path-format=separate-events -Wanalyzer-too-complex -fanalyzer-call-summaries" +set DEFAULT_FFLAGS "-fanalyzer -Wanalyzer-too-complex -fanalyzer-call-summaries" # Initialize `dg'. dg-init