Add -fdiagnostics-path-format=separate-events to -fdiagnostics-plain-output
authorDavid Malcolm <dmalcolm@redhat.com>
Tue, 6 Oct 2020 20:58:00 +0000 (16:58 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Wed, 7 Oct 2020 13:37:11 +0000 (09:37 -0400)
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.

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
gcc/opts-common.c
gcc/testsuite/g++.dg/analyzer/analyzer.exp
gcc/testsuite/gcc.dg/analyzer/analyzer.exp
gcc/testsuite/gcc.dg/plugin/diagnostic-path-format-default.c [deleted file]
gcc/testsuite/gcc.dg/plugin/diagnostic-path-format-plain.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/plugin/diagnostic-test-paths-2.c
gcc/testsuite/gcc.dg/plugin/plugin.exp
gcc/testsuite/gfortran.dg/analyzer/analyzer.exp

index 7c81d7f41bd534cb80ee6d54cf6b998fc391a6d8..c177496907940b312b192187205f9150faf0611e 100644 (file)
@@ -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.
 
index 237e4ce454e69c16994741278503bccc704ed9e4..8ec8c1ec1a8a1c14f998c057f36eac84a1734ec1 100644 (file)
@@ -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;
index 60262f678eed00473a53a711c50555ad76d5524a..78edff2d11b536ddbd5f4e95dcc41db010953716 100644 (file)
@@ -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
index ac9c49511aa0ab014f46c60ade2b3ae3c442809e..d72fef37ede012a0476fac993f4285f6693132c1 100644 (file)
@@ -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 (file)
index 5712dbd..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-/* { dg-do compile } */
-/* { dg-options "-fdiagnostics-show-caret" } */
-
-#include <stdlib.h>
-
-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 (file)
index 0000000..75acd25
--- /dev/null
@@ -0,0 +1,42 @@
+/* { dg-do compile } */
+
+#include <stdlib.h>
+
+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);
+}
index 946a234dd236cbfd1be1aa843b235c20d9835b92..b2b269a12b51276ae7a90520d8d2e872c70cbb18 100644 (file)
@@ -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 <stddef.h>
 #include <stdlib.h>
@@ -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);
     |      |     ~~~~~~~~~~~~~~~~~~~~~~~~~
index c02b008271528262600bff74dbd08d3db74dfb08..5dd102ae05c535c8b2e2396d50a579e25e961a02 100644 (file)
@@ -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 \
index 00edfa54dce02eb1113802fd3ed68980e48e0a05..462395c935cbc6a866b075f534f94a5ff14846d9 100644 (file)
@@ -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