comparison gcc/testsuite/c-c++-common/diagnostic-format-json-4.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 /* { dg-do compile } */
2 /* { dg-options "-fdiagnostics-format=json -Wmisleading-indentation" } */
3
4 int test (void)
5 {
6 if (1)
7 return 3;
8 return 4;
9 return 5;
10 }
11
12 /* Use dg-regexp to consume the JSON output starting with
13 the innermost values, and working outwards.
14 We can't rely on any ordering of the keys. */
15
16 /* Verify nested diagnostics. */
17
18 /* The nested diagnostic. */
19
20 /* { dg-regexp "\"kind\": \"note\"" } */
21 /* { dg-regexp "\"message\": \"...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'\"" } */
22
23 /* { dg-regexp "\"caret\": \{" } */
24 /* { dg-regexp "\"file\": \"\[^\n\r\"\]*diagnostic-format-json-4.c\"" } */
25 /* { dg-regexp "\"line\": 8" } */
26 /* { dg-regexp "\"column\": 5" } */
27
28 /* { dg-regexp "\"finish\": \{" } */
29 /* { dg-regexp "\"file\": \"\[^\n\r\"\]*diagnostic-format-json-4.c\"" } */
30 /* { dg-regexp "\"line\": 8" } */
31 /* { dg-regexp "\"column\": 10" } */
32
33 /* The outer diagnostic. */
34
35 /* { dg-regexp "\"kind\": \"warning\"" } */
36 /* { dg-regexp "\"message\": \"this 'if' clause does not guard...\"" } */
37 /* { dg-regexp "\"option\": \"-Wmisleading-indentation\"" } */
38 /* { dg-regexp "\"option_url\": \"https:\[^\n\r\"\]*#index-Wmisleading-indentation\"" } */
39
40 /* { dg-regexp "\"caret\": \{" } */
41 /* { dg-regexp "\"file\": \"\[^\n\r\"\]*diagnostic-format-json-4.c\"" } */
42 /* { dg-regexp "\"line\": 6" } */
43 /* { dg-regexp "\"column\": 3" } */
44
45 /* { dg-regexp "\"finish\": \{" } */
46 /* { dg-regexp "\"file\": \"\[^\n\r\"\]*diagnostic-format-json-4.c\"" } */
47 /* { dg-regexp "\"line\": 6" } */
48 /* { dg-regexp "\"column\": 4" } */
49
50 /* More from the nested diagnostic (we can't guarantee what order the
51 "file" keys are consumed). */
52
53 /* { dg-regexp "\"locations\": \[\[\{\}, \]*\]" } */
54
55 /* More from the outer diagnostic. */
56
57 /* { dg-regexp "\"locations\": \[\[\{\}, \]*\]" } */
58
59 /* { dg-regexp "\"children\": \[\[\{\}, \]*\]" } */
60 /* { dg-regexp "\[\[\{\}, \]*\]" } */
61