(root)/
gcc-13.2.0/
gcc/
testsuite/
c-c++-common/
diagnostic-format-json-4.c
       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  
      15  /* Verify nested diagnostics.  */
      16  
      17  /* The nested diagnostic.  */
      18  
      19  /* { dg-regexp "\"kind\": \"note\"" } */
      20  /* { dg-regexp "\"message\": \"...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'\"" } */
      21  /* { dg-regexp "\"escape-source\": false" } */
      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  /* { dg-regexp "\"display-column\": 5" } */
      28  /* { dg-regexp "\"byte-column\": 5" } */
      29  
      30  /* { dg-regexp "\"finish\": \{" } */
      31  /* { dg-regexp "\"file\": \"\[^\n\r\"\]*diagnostic-format-json-4.c\"" } */
      32  /* { dg-regexp "\"line\": 8" } */
      33  /* { dg-regexp "\"column\": 10" } */
      34  /* { dg-regexp "\"display-column\": 10" } */
      35  /* { dg-regexp "\"byte-column\": 10" } */
      36  
      37  /* The outer diagnostic.  */
      38  
      39  /* { dg-regexp "\"kind\": \"warning\"" } */
      40  /* { dg-regexp "\"column-origin\": 1" } */
      41  /* { dg-regexp "\"message\": \"this 'if' clause does not guard...\"" } */
      42  /* { dg-regexp "\"escape-source\": false" } */
      43  /* { dg-regexp "\"option\": \"-Wmisleading-indentation\"" } */
      44  /* { dg-regexp "\"option_url\": \"https:\[^\n\r\"\]*#index-Wmisleading-indentation\"" } */
      45  
      46  /* { dg-regexp "\"caret\": \{" } */
      47  /* { dg-regexp "\"file\": \"\[^\n\r\"\]*diagnostic-format-json-4.c\"" } */
      48  /* { dg-regexp "\"line\": 6" } */
      49  /* { dg-regexp "\"column\": 3" } */
      50  /* { dg-regexp "\"display-column\": 3" } */
      51  /* { dg-regexp "\"byte-column\": 3" } */
      52  
      53  /* { dg-regexp "\"finish\": \{" } */
      54  /* { dg-regexp "\"file\": \"\[^\n\r\"\]*diagnostic-format-json-4.c\"" } */
      55  /* { dg-regexp "\"line\": 6" } */
      56  /* { dg-regexp "\"column\": 4" } */
      57  /* { dg-regexp "\"display-column\": 4" } */
      58  /* { dg-regexp "\"byte-column\": 4" } */
      59  
      60  /* More from the nested diagnostic (we can't guarantee what order the
      61     "file" keys are consumed).  */
      62  
      63  /* { dg-regexp "\"locations\": \[\[\{\}, \]*\]" } */
      64  
      65  /* More from the outer diagnostic.  */
      66  
      67  /* { dg-regexp "\"locations\": \[\[\{\}, \]*\]" } */
      68  
      69  /* { dg-regexp "\"children\": \[\[\{\}, \]*\]" } */
      70  /* { dg-regexp "\[\[\{\}, \]*\]" } */
      71