(root)/
gcc-13.2.0/
gcc/
testsuite/
c-c++-common/
diagnostic-format-json-5.c
       1  /* { dg-do compile } */
       2  /* { dg-options "-fdiagnostics-format=json" } */
       3  
       4  struct s { int color; };
       5  
       6  int test (struct s *ptr)
       7  {
       8    return ptr->colour;
       9  }
      10  
      11  /* Verify fix-it hints.
      12  
      13     Use dg-regexp to consume the JSON output from start to
      14     finish, relying on the ordering of the keys.
      15     The following uses indentation to visualize the structure
      16     of the JSON (although the actual output is all on one line).
      17  
      18    { dg-regexp {\[} }
      19      { dg-regexp {\{} }
      20       { dg-regexp {"kind": "error"} }
      21       { dg-regexp {, "message": "'struct s' has no member named 'colour'; did you mean 'color'\?"} }
      22       { dg-regexp {, "children": \[\]} }
      23       { dg-regexp {, "column-origin": 1} }
      24       { dg-regexp {, "locations": } }
      25         { dg-regexp {\[} }
      26           { dg-regexp {\{} }
      27             { dg-regexp {"caret": } }
      28               { dg-regexp {\{} }
      29                 { dg-regexp {"file": "[^\n\r"]*diagnostic-format-json-5.c"} }
      30                 { dg-regexp {, "line": 8} }
      31                 { dg-regexp {, "display-column": 15} }
      32                 { dg-regexp {, "byte-column": 15} }
      33                 { dg-regexp {, "column": 15} }
      34               { dg-regexp {\}} }
      35             { dg-regexp {, "finish": } }
      36               { dg-regexp {\{} }
      37                 { dg-regexp {"file": "[^\n\r"]*diagnostic-format-json-5.c"} }
      38                 { dg-regexp {, "line": 8} }
      39                 { dg-regexp {, "display-column": 20} }
      40                 { dg-regexp {, "byte-column": 20} }
      41                 { dg-regexp {, "column": 20} }
      42               { dg-regexp {\}} }
      43             { dg-regexp {\}} }
      44           { dg-regexp {\]} }
      45         { dg-regexp {, "fixits": } }
      46         { dg-regexp {\[} }
      47           { dg-regexp {\{} }
      48             { dg-regexp {"start": } }
      49               { dg-regexp {\{} }
      50                 { dg-regexp {"file": "[^\n\r"]*diagnostic-format-json-5.c"} }
      51                 { dg-regexp {, "line": 8} }
      52                 { dg-regexp {, "display-column": 15} }
      53                 { dg-regexp {, "byte-column": 15} }
      54                 { dg-regexp {, "column": 15} }
      55               { dg-regexp {\}} }
      56             { dg-regexp {, "next": } }
      57               { dg-regexp {\{} }
      58                 { dg-regexp {"file": "[^\n\r"]*diagnostic-format-json-5.c"} }
      59                 { dg-regexp {, "line": 8} }
      60                 { dg-regexp {, "display-column": 21} }
      61                 { dg-regexp {, "byte-column": 21} }
      62                 { dg-regexp {, "column": 21} }
      63               { dg-regexp {\}} }
      64             { dg-regexp {, "string": "color"} }
      65           { dg-regexp {\}} }
      66         { dg-regexp {\]} }
      67       { dg-regexp {, "escape-source": false\}} }
      68     { dg-regexp {\]} }  */