| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-fdiagnostics-format=sarif-file" } */ |
| 3 |
/* { dg-excess-errors "The error is sent to the SARIF file, rather than stderr" } */ |
| 4 |
|
| 5 |
struct s { int color; }; |
| 6 |
|
| 7 |
int test (struct s *ptr) |
| 8 |
{ |
| 9 |
return ptr->colour; |
| 10 |
} |
| 11 |
|
| 12 |
/* |
| 13 |
{ dg-final { verify-sarif-file } } |
| 14 |
|
| 15 |
{ dg-final { scan-sarif-file "\"level\": \"error\"" } } |
| 16 |
|
| 17 |
We expect a logical location for the error (within fn "test"): |
| 18 |
{ dg-final { scan-sarif-file "\"locations\": \\\[" } } |
| 19 |
{ dg-final { scan-sarif-file "\"logicalLocations\": \\\[" } } |
| 20 |
{ dg-final { scan-sarif-file "\"kind\": \"function\"" } } |
| 21 |
{ dg-final { scan-sarif-file "\"name\": \"test\"" } } |
| 22 |
{ dg-final { scan-sarif-file "\"fullyQualifiedName\": \"test\"" } } |
| 23 |
{ dg-final { scan-sarif-file "\"decoratedName\": \"" } } |
| 24 |
|
| 25 |
We expect a "fixes" array for the fix-it hint (SARIF v2.1.0 section 3.27.30): |
| 26 |
{ dg-final { scan-sarif-file "\"fixes\": \\\[" } } |
| 27 |
{ dg-final { scan-sarif-file "\"artifactChanges\": \\\[" } } |
| 28 |
{ dg-final { scan-sarif-file "\"replacements\": \\\[" } } |
| 29 |
{ dg-final { scan-sarif-file "\"insertedContent\": " } } |
| 30 |
{ dg-final { scan-sarif-file "\"text\": \"color\"" } } |
| 31 |
{ dg-final { scan-sarif-file "\"deletedRegion\": " } } |
| 32 |
*/ |