aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2023-12-06 12:35:44 -0500
committerDavid Malcolm <dmalcolm@redhat.com>2023-12-06 12:35:44 -0500
commit3bd8241a1f19827586cbed7832a24f44ff3e22ac (patch)
tree5d30aa8826b5c856b8fd973286f095a85d7bfd4f /gcc/testsuite/c-c++-common
parent8fc4e6c397e1ce64bec6f9fed148950821cc79e7 (diff)
downloadgcc-3bd8241a1f19827586cbed7832a24f44ff3e22ac.zip
gcc-3bd8241a1f19827586cbed7832a24f44ff3e22ac.tar.gz
gcc-3bd8241a1f19827586cbed7832a24f44ff3e22ac.tar.bz2
diagnostics: prettify JSON output formats
Previously our JSON output emitted the JSON all on one line, with no indentation to show the structure of the values. Although it's easy to reformat such output (e.g. with "python -m json.tool"), I've found it's a pain to need to do so e.g. my text editor sometimes hangs when opening a multimegabyte json file all on one line. Similarly diff-ing is easier if the json is already formatted. This patch add whitespace to json output to show the structure. It turned out to be fairly easy to implement using pretty_printer's existing indentation machinery. The patch uses this formatting for the various JSON-based diagnostic output formats. For example, with this patch, the output from fdiagnostics-format=json-stderr looks like: [{"kind": "warning", "message": "stack-based buffer overflow", "option": "-Wanalyzer-out-of-bounds", "option_url": "https://gcc.gnu.org/onlinedocs/gcc/Static-Analyzer-Options.html#index-Wanalyzer-out-of-bounds", "children": [{"kind": "note", "message": "write of 350 bytes to beyond the end of ‘buf’", "locations": [{"caret": {"file": "../../src/gcc/testsuite/gcc.dg/analyzer/out-of-bounds-diagram-19.c", "line": 20, "display-column": 3, "byte-column": 3, "column": 3}, "finish": {"file": "../../src/gcc/testsuite/gcc.dg/analyzer/out-of-bounds-diagram-19.c", "line": 20, "display-column": 27, "byte-column": 27, "column": 27}}], "escape-source": false}, {"kind": "note", "message": "valid subscripts for ‘buf’ are ‘[0]’ to ‘[99]’", "locations": [{"caret": {"file": "../../src/gcc/testsuite/gcc.dg/analyzer/out-of-bounds-diagram-19.c", "line": 20, "display-column": 3, "byte-column": 3, "column": 3}, "finish": {"file": "../../src/gcc/testsuite/gcc.dg/analyzer/out-of-bounds-diagram-19.c", "line": 20, "display-column": 27, "byte-column": 27, "column": 27}}], "escape-source": false}], "column-origin": 1, ...snip...] I was able to update almost all of our DejaGnu test cases for JSON to handle this format tweak, and IMHO it improved the readability of these test cases, but a couple were more awkward. Hence I added -fno-diagnostics-json-formatting as an option to disable this formatting. The formatting does not affect the output of -fsave-optimization-record or the JSON output from gcov (but this could be enabled if desirable). gcc/analyzer/ChangeLog: * engine.cc (dump_analyzer_json): Use flag_diagnostics_json_formatting. gcc/ChangeLog: * common.opt (fdiagnostics-json-formatting): New. * diagnostic-format-json.cc: Add "formatted" boolean to json_output_format and subclasses, and to the diagnostic_output_format_init_json_* functions. Use it when printing JSON. * diagnostic-format-sarif.cc: Likewise for sarif_builder, sarif_output_format, and the various diagnostic_output_format_init_sarif_* functions. * diagnostic.cc (diagnostic_output_format_init): Add "json_formatting" boolean and pass on to the various cases. * diagnostic.h (diagnostic_output_format_init): Add "json_formatted" param. (diagnostic_output_format_init_json_stderr): Add "formatted" param (diagnostic_output_format_init_json_file): Likewise. (diagnostic_output_format_init_sarif_stderr): Likewise. (diagnostic_output_format_init_sarif_file): Likewise. (diagnostic_output_format_init_sarif_stream): Likewise. * doc/invoke.texi (-fdiagnostics-format=json): Remove discussion about JSON output needing formatting. (-fno-diagnostics-json-formatting): Add. * gcc.cc (driver_handle_option): Use opts->x_flag_diagnostics_json_formatting. * gcov.cc (generate_results): Pass "false" for new formatting option when printing json. * json.cc (value::dump): Add new "formatted" param. (object::print): Likewise, using it to add whitespace to format the JSON output. (array::print): Likewise. (float_number::print): Add new "formatted" param. (integer_number::print): Likewise. (string::print): Likewise. (literal::print): Likewise. (selftest::assert_print_eq): Add "formatted" param. (ASSERT_PRINT_EQ): Add "FORMATTED" param. (selftest::test_writing_objects): Test both formatted and unformatted printing. (selftest::test_writing_arrays): Likewise. (selftest::test_writing_float_numbers): Update for new param of ASSERT_PRINT_EQ. (selftest::test_writing_integer_numbers): Likewise. (selftest::test_writing_strings): Likewise. (selftest::test_writing_literals): Likewise. (selftest::test_formatting): New. (selftest::json_cc_tests): Call it. * json.h (value::print): Add "formatted" param. (value::dump): Likewise. (object::print): Likewise. (array::print): Likewise. (float_number::print): Likewise. (integer_number::print): Likewise. (string::print): Likewise. (literal::print): Likewise. * optinfo-emit-json.cc (optrecord_json_writer::write): Pass "false" for new formatting option when printing json. (selftest::test_building_json_from_dump_calls): Likewise. * opts.cc (common_handle_option): Use opts->x_flag_diagnostics_json_formatting. gcc/testsuite/ChangeLog: * c-c++-common/diagnostic-format-json-1.c: Update expected JSON output to reflect whitespace. * c-c++-common/diagnostic-format-json-2.c: Likewise. * c-c++-common/diagnostic-format-json-3.c: Likewise. * c-c++-common/diagnostic-format-json-4.c: Likewise. * c-c++-common/diagnostic-format-json-5.c: Likewise. * c-c++-common/diagnostic-format-json-stderr-1.c: Likewise. * g++.dg/pr90462.C: Add -fno-diagnostics-json-formatting. * gcc.dg/analyzer/malloc-sarif-1.c: Likewise. * gcc.dg/plugin/diagnostic-test-paths-3.c: Update expected JSON output to reflect whitespace. * gfortran.dg/diagnostic-format-json-1.F90: Likewise. * gfortran.dg/diagnostic-format-json-2.F90: Likewise. * gfortran.dg/diagnostic-format-json-3.F90: Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/testsuite/c-c++-common')
-rw-r--r--gcc/testsuite/c-c++-common/diagnostic-format-json-1.c42
-rw-r--r--gcc/testsuite/c-c++-common/diagnostic-format-json-2.c48
-rw-r--r--gcc/testsuite/c-c++-common/diagnostic-format-json-3.c48
-rw-r--r--gcc/testsuite/c-c++-common/diagnostic-format-json-4.c93
-rw-r--r--gcc/testsuite/c-c++-common/diagnostic-format-json-5.c86
-rw-r--r--gcc/testsuite/c-c++-common/diagnostic-format-json-stderr-1.c42
6 files changed, 137 insertions, 222 deletions
diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-1.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-1.c
index 6bab30e..c95218c 100644
--- a/gcc/testsuite/c-c++-common/diagnostic-format-json-1.c
+++ b/gcc/testsuite/c-c++-common/diagnostic-format-json-1.c
@@ -3,28 +3,20 @@
#error message
-/* Use dg-regexp to consume the JSON output starting with
- the innermost values, and working outwards. */
-
-/* { dg-regexp "\"kind\": \"error\"" } */
-/* { dg-regexp "\"column-origin\": 1" } */
-/* { dg-regexp "\"escape-source\": false" } */
-/* { dg-regexp "\"message\": \"#error message\"" } */
-
-/* { dg-regexp "\"caret\": \{" } */
-/* { dg-regexp "\"file\": \"\[^\n\r\"\]*diagnostic-format-json-1.c\"" } */
-/* { dg-regexp "\"line\": 4" } */
-/* { dg-regexp "\"column\": 2" } */
-/* { dg-regexp "\"display-column\": 2" } */
-/* { dg-regexp "\"byte-column\": 2" } */
-
-/* { dg-regexp "\"finish\": \{" } */
-/* { dg-regexp "\"file\": \"\[^\n\r\"\]*diagnostic-format-json-1.c\"" } */
-/* { dg-regexp "\"line\": 4" } */
-/* { dg-regexp "\"column\": 6" } */
-/* { dg-regexp "\"display-column\": 6" } */
-/* { dg-regexp "\"byte-column\": 6" } */
-
-/* { dg-regexp "\"locations\": \[\[\{\}, \]*\]" } */
-/* { dg-regexp "\"children\": \[\[\]\[\]\]" } */
-/* { dg-regexp "\[\[\{\}, \]*\]" } */
+/* { dg-begin-multiline-output "" }
+[{"kind": "error",
+ "message": "#error message",
+ "children": [],
+ "column-origin": 1,
+ "locations": [{"caret": {"file":
+ "line": 4,
+ "display-column": 2,
+ "byte-column": 2,
+ "column": 2},
+ "finish": {"file":
+ "line": 4,
+ "display-column": 6,
+ "byte-column": 6,
+ "column": 6}}],
+ "escape-source": false}]
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-2.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-2.c
index 3c12103..a8828b7 100644
--- a/gcc/testsuite/c-c++-common/diagnostic-format-json-2.c
+++ b/gcc/testsuite/c-c++-common/diagnostic-format-json-2.c
@@ -3,30 +3,24 @@
#warning message
-/* Use dg-regexp to consume the JSON output starting with
- the innermost values, and working outwards. */
-
-/* { dg-regexp "\"kind\": \"warning\"" } */
-/* { dg-regexp "\"column-origin\": 1" } */
-/* { dg-regexp "\"escape-source\": false" } */
-/* { dg-regexp "\"message\": \"#warning message\"" } */
-/* { dg-regexp "\"option\": \"-Wcpp\"" } */
-/* { dg-regexp "\"option_url\": \"https:\[^\n\r\"\]*#index-Wcpp\"" } */
-
-/* { dg-regexp "\"caret\": \{" } */
-/* { dg-regexp "\"file\": \"\[^\n\r\"\]*diagnostic-format-json-2.c\"" } */
-/* { dg-regexp "\"line\": 4" } */
-/* { dg-regexp "\"column\": 2" } */
-/* { dg-regexp "\"display-column\": 2" } */
-/* { dg-regexp "\"byte-column\": 2" } */
-
-/* { dg-regexp "\"finish\": \{" } */
-/* { dg-regexp "\"file\": \"\[^\n\r\"\]*diagnostic-format-json-2.c\"" } */
-/* { dg-regexp "\"line\": 4" } */
-/* { dg-regexp "\"column\": 8" } */
-/* { dg-regexp "\"display-column\": 8" } */
-/* { dg-regexp "\"byte-column\": 8" } */
-
-/* { dg-regexp "\"locations\": \[\[\{\}, \]*\]" } */
-/* { dg-regexp "\"children\": \[\[\]\[\]\]" } */
-/* { dg-regexp "\[\[\{\}, \]*\]" } */
+/* { dg-begin-multiline-output "" }
+[{"kind": "warning",
+ "message": "#warning message",
+ "option": "-Wcpp",
+ { dg-end-multiline-output "" } */
+/* { dg-regexp " \"option_url\": \"https:\[^\n\r\"\]*#index-Wcpp\",\n" } */
+/* { dg-begin-multiline-output "" }
+ "children": [],
+ "column-origin": 1,
+ "locations": [{"caret": {"file":
+ "line": 4,
+ "display-column": 2,
+ "byte-column": 2,
+ "column": 2},
+ "finish": {"file":
+ "line": 4,
+ "display-column": 8,
+ "byte-column": 8,
+ "column": 8}}],
+ "escape-source": false}]
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-3.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-3.c
index 11d7462..178bbf9 100644
--- a/gcc/testsuite/c-c++-common/diagnostic-format-json-3.c
+++ b/gcc/testsuite/c-c++-common/diagnostic-format-json-3.c
@@ -3,30 +3,24 @@
#warning message
-/* Use dg-regexp to consume the JSON output starting with
- the innermost values, and working outwards. */
-
-/* { dg-regexp "\"kind\": \"error\"" } */
-/* { dg-regexp "\"column-origin\": 1" } */
-/* { dg-regexp "\"escape-source\": false" } */
-/* { dg-regexp "\"message\": \"#warning message\"" } */
-/* { dg-regexp "\"option\": \"-Werror=cpp\"" } */
-/* { dg-regexp "\"option_url\": \"https:\[^\n\r\"\]*#index-Wcpp\"" } */
-
-/* { dg-regexp "\"caret\": \{" } */
-/* { dg-regexp "\"file\": \"\[^\n\r\"\]*diagnostic-format-json-3.c\"" } */
-/* { dg-regexp "\"line\": 4" } */
-/* { dg-regexp "\"column\": 2" } */
-/* { dg-regexp "\"display-column\": 2" } */
-/* { dg-regexp "\"byte-column\": 2" } */
-
-/* { dg-regexp "\"finish\": \{" } */
-/* { dg-regexp "\"file\": \"\[^\n\r\"\]*diagnostic-format-json-3.c\"" } */
-/* { dg-regexp "\"line\": 4" } */
-/* { dg-regexp "\"column\": 8" } */
-/* { dg-regexp "\"display-column\": 8" } */
-/* { dg-regexp "\"byte-column\": 8" } */
-
-/* { dg-regexp "\"locations\": \[\[\{\}, \]*\]" } */
-/* { dg-regexp "\"children\": \[\[\]\[\]\]" } */
-/* { dg-regexp "\[\[\{\}, \]*\]" } */
+/* { dg-begin-multiline-output "" }
+[{"kind": "error",
+ "message": "#warning message",
+ "option": "-Werror=cpp",
+ { dg-end-multiline-output "" } */
+/* { dg-regexp " \"option_url\": \"https:\[^\n\r\"\]*#index-Wcpp\",\n" } */
+/* { dg-begin-multiline-output "" }
+ "children": [],
+ "column-origin": 1,
+ "locations": [{"caret": {"file":
+ "line": 4,
+ "display-column": 2,
+ "byte-column": 2,
+ "column": 2},
+ "finish": {"file":
+ "line": 4,
+ "display-column": 8,
+ "byte-column": 8,
+ "column": 8}}],
+ "escape-source": false}]
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-4.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-4.c
index cec1cf9..899a03f 100644
--- a/gcc/testsuite/c-c++-common/diagnostic-format-json-4.c
+++ b/gcc/testsuite/c-c++-common/diagnostic-format-json-4.c
@@ -9,63 +9,36 @@ int test (void)
return 5;
}
-/* Use dg-regexp to consume the JSON output starting with
- the innermost values, and working outwards. */
-
-/* Verify nested diagnostics. */
-
-/* The nested diagnostic. */
-
-/* { dg-regexp "\"kind\": \"note\"" } */
-/* { dg-regexp "\"message\": \"...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'\"" } */
-/* { dg-regexp "\"escape-source\": false" } */
-
-/* { dg-regexp "\"caret\": \{" } */
-/* { dg-regexp "\"file\": \"\[^\n\r\"\]*diagnostic-format-json-4.c\"" } */
-/* { dg-regexp "\"line\": 8" } */
-/* { dg-regexp "\"column\": 5" } */
-/* { dg-regexp "\"display-column\": 5" } */
-/* { dg-regexp "\"byte-column\": 5" } */
-
-/* { dg-regexp "\"finish\": \{" } */
-/* { dg-regexp "\"file\": \"\[^\n\r\"\]*diagnostic-format-json-4.c\"" } */
-/* { dg-regexp "\"line\": 8" } */
-/* { dg-regexp "\"column\": 10" } */
-/* { dg-regexp "\"display-column\": 10" } */
-/* { dg-regexp "\"byte-column\": 10" } */
-
-/* The outer diagnostic. */
-
-/* { dg-regexp "\"kind\": \"warning\"" } */
-/* { dg-regexp "\"column-origin\": 1" } */
-/* { dg-regexp "\"message\": \"this 'if' clause does not guard...\"" } */
-/* { dg-regexp "\"escape-source\": false" } */
-/* { dg-regexp "\"option\": \"-Wmisleading-indentation\"" } */
-/* { dg-regexp "\"option_url\": \"https:\[^\n\r\"\]*#index-Wmisleading-indentation\"" } */
-
-/* { dg-regexp "\"caret\": \{" } */
-/* { dg-regexp "\"file\": \"\[^\n\r\"\]*diagnostic-format-json-4.c\"" } */
-/* { dg-regexp "\"line\": 6" } */
-/* { dg-regexp "\"column\": 3" } */
-/* { dg-regexp "\"display-column\": 3" } */
-/* { dg-regexp "\"byte-column\": 3" } */
-
-/* { dg-regexp "\"finish\": \{" } */
-/* { dg-regexp "\"file\": \"\[^\n\r\"\]*diagnostic-format-json-4.c\"" } */
-/* { dg-regexp "\"line\": 6" } */
-/* { dg-regexp "\"column\": 4" } */
-/* { dg-regexp "\"display-column\": 4" } */
-/* { dg-regexp "\"byte-column\": 4" } */
-
-/* More from the nested diagnostic (we can't guarantee what order the
- "file" keys are consumed). */
-
-/* { dg-regexp "\"locations\": \[\[\{\}, \]*\]" } */
-
-/* More from the outer diagnostic. */
-
-/* { dg-regexp "\"locations\": \[\[\{\}, \]*\]" } */
-
-/* { dg-regexp "\"children\": \[\[\{\}, \]*\]" } */
-/* { dg-regexp "\[\[\{\}, \]*\]" } */
-
+/* { dg-begin-multiline-output "" }
+[{"kind": "warning",
+ "message": "this 'if' clause does not guard...",
+ "option": "-Wmisleading-indentation",
+ { dg-end-multiline-output "" } */
+/* { dg-regexp " \"option_url\": \"https:\[^\n\r\"\]*#index-Wmisleading-indentation\",\n" } */
+/* { dg-begin-multiline-output "" }
+ "children": [{"kind": "note",
+ "message": "...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'",
+ "locations": [{"caret": {"file":
+ "line": 8,
+ "display-column": 5,
+ "byte-column": 5,
+ "column": 5},
+ "finish": {"file":
+ "line": 8,
+ "display-column": 10,
+ "byte-column": 10,
+ "column": 10}}],
+ "escape-source": false}],
+ "column-origin": 1,
+ "locations": [{"caret": {"file":
+ "line": 6,
+ "display-column": 3,
+ "byte-column": 3,
+ "column": 3},
+ "finish": {"file":
+ "line": 6,
+ "display-column": 4,
+ "byte-column": 4,
+ "column": 4}}],
+ "escape-source": false}]
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-5.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-5.c
index 86f8c5f..ed3139c 100644
--- a/gcc/testsuite/c-c++-common/diagnostic-format-json-5.c
+++ b/gcc/testsuite/c-c++-common/diagnostic-format-json-5.c
@@ -8,61 +8,31 @@ int test (struct s *ptr)
return ptr->colour;
}
-/* Verify fix-it hints.
-
- Use dg-regexp to consume the JSON output from start to
- finish, relying on the ordering of the keys.
- The following uses indentation to visualize the structure
- of the JSON (although the actual output is all on one line).
-
- { dg-regexp {\[} }
- { dg-regexp {\{} }
- { dg-regexp {"kind": "error"} }
- { dg-regexp {, "message": "'struct s' has no member named 'colour'; did you mean 'color'\?"} }
- { dg-regexp {, "children": \[\]} }
- { dg-regexp {, "column-origin": 1} }
- { dg-regexp {, "locations": } }
- { dg-regexp {\[} }
- { dg-regexp {\{} }
- { dg-regexp {"caret": } }
- { dg-regexp {\{} }
- { dg-regexp {"file": "[^\n\r"]*diagnostic-format-json-5.c"} }
- { dg-regexp {, "line": 8} }
- { dg-regexp {, "display-column": 15} }
- { dg-regexp {, "byte-column": 15} }
- { dg-regexp {, "column": 15} }
- { dg-regexp {\}} }
- { dg-regexp {, "finish": } }
- { dg-regexp {\{} }
- { dg-regexp {"file": "[^\n\r"]*diagnostic-format-json-5.c"} }
- { dg-regexp {, "line": 8} }
- { dg-regexp {, "display-column": 20} }
- { dg-regexp {, "byte-column": 20} }
- { dg-regexp {, "column": 20} }
- { dg-regexp {\}} }
- { dg-regexp {\}} }
- { dg-regexp {\]} }
- { dg-regexp {, "fixits": } }
- { dg-regexp {\[} }
- { dg-regexp {\{} }
- { dg-regexp {"start": } }
- { dg-regexp {\{} }
- { dg-regexp {"file": "[^\n\r"]*diagnostic-format-json-5.c"} }
- { dg-regexp {, "line": 8} }
- { dg-regexp {, "display-column": 15} }
- { dg-regexp {, "byte-column": 15} }
- { dg-regexp {, "column": 15} }
- { dg-regexp {\}} }
- { dg-regexp {, "next": } }
- { dg-regexp {\{} }
- { dg-regexp {"file": "[^\n\r"]*diagnostic-format-json-5.c"} }
- { dg-regexp {, "line": 8} }
- { dg-regexp {, "display-column": 21} }
- { dg-regexp {, "byte-column": 21} }
- { dg-regexp {, "column": 21} }
- { dg-regexp {\}} }
- { dg-regexp {, "string": "color"} }
- { dg-regexp {\}} }
- { dg-regexp {\]} }
- { dg-regexp {, "escape-source": false\}} }
- { dg-regexp {\]} } */
+/* { dg-begin-multiline-output "" }
+[{"kind": "error",
+ "message": "'struct s' has no member named 'colour'; did you mean 'color'?",
+ "children": [],
+ "column-origin": 1,
+ "locations": [{"caret": {"file":
+ "line": 8,
+ "display-column": 15,
+ "byte-column": 15,
+ "column": 15},
+ "finish": {"file":
+ "line": 8,
+ "display-column": 20,
+ "byte-column": 20,
+ "column": 20}}],
+ "fixits": [{"start": {"file":
+ "line": 8,
+ "display-column": 15,
+ "byte-column": 15,
+ "column": 15},
+ "next": {"file":
+ "line": 8,
+ "display-column": 21,
+ "byte-column": 21,
+ "column": 21},
+ "string": "color"}],
+ "escape-source": false}]
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-stderr-1.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-stderr-1.c
index bcfa921..e798c6b 100644
--- a/gcc/testsuite/c-c++-common/diagnostic-format-json-stderr-1.c
+++ b/gcc/testsuite/c-c++-common/diagnostic-format-json-stderr-1.c
@@ -5,28 +5,20 @@
#error message
-/* Use dg-regexp to consume the JSON output starting with
- the innermost values, and working outwards. */
-
-/* { dg-regexp "\"kind\": \"error\"" } */
-/* { dg-regexp "\"column-origin\": 1" } */
-/* { dg-regexp "\"escape-source\": false" } */
-/* { dg-regexp "\"message\": \"#error message\"" } */
-
-/* { dg-regexp "\"caret\": \{" } */
-/* { dg-regexp "\"file\": \"\[^\n\r\"\]*diagnostic-format-json-stderr-1.c\"" } */
-/* { dg-regexp "\"line\": 6" } */
-/* { dg-regexp "\"column\": 2" } */
-/* { dg-regexp "\"display-column\": 2" } */
-/* { dg-regexp "\"byte-column\": 2" } */
-
-/* { dg-regexp "\"finish\": \{" } */
-/* { dg-regexp "\"file\": \"\[^\n\r\"\]*diagnostic-format-json-stderr-1.c\"" } */
-/* { dg-regexp "\"line\": 6" } */
-/* { dg-regexp "\"column\": 6" } */
-/* { dg-regexp "\"display-column\": 6" } */
-/* { dg-regexp "\"byte-column\": 6" } */
-
-/* { dg-regexp "\"locations\": \[\[\{\}, \]*\]" } */
-/* { dg-regexp "\"children\": \[\[\]\[\]\]" } */
-/* { dg-regexp "\[\[\{\}, \]*\]" } */
+/* { dg-begin-multiline-output "" }
+[{"kind": "error",
+ "message": "#error message",
+ "children": [],
+ "column-origin": 1,
+ "locations": [{"caret": {"file":
+ "line": 6,
+ "display-column": 2,
+ "byte-column": 2,
+ "column": 2},
+ "finish": {"file":
+ "line": 6,
+ "display-column": 6,
+ "byte-column": 6,
+ "column": 6}}],
+ "escape-source": false}]
+ { dg-end-multiline-output "" } */