| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-fdiagnostics-format=sarif-file" } */ |
| 3 |
|
| 4 |
/* Verify that SARIF output can capture chains of include files in |
| 5 |
result locations. |
| 6 |
|
| 7 |
Generate two warning/note pairs, using a chain of header files. |
| 8 |
In textual form, we'd expect something like: |
| 9 |
|
| 10 |
In file included from PATH/include-chain-1.h:5, |
| 11 |
from PATH/include-chain-1.c:9: |
| 12 |
PATH/include-chain-1-2.h:1:6: error: conflicting types for 'p'; have 'char' |
| 13 |
1 | char p; |
| 14 |
| ^ |
| 15 |
In file included from PATH/include-chain-1.h:2: |
| 16 |
PATH/include-chain-1-1.h:1:5: note: previous declaration of 'p' with type 'int' |
| 17 |
1 | int p; |
| 18 |
| ^ |
| 19 |
PATH/include-chain-1-2.h:2:6: error: conflicting types for 'q'; have 'char' |
| 20 |
2 | char q; |
| 21 |
| ^ |
| 22 |
PATH/include-chain-1-1.h:2:5: note: previous declaration of 'q' with type 'int' |
| 23 |
2 | int q; |
| 24 |
| ^ |
| 25 |
|
| 26 |
We should have two result objects (for each of 'p' and 'q'), each with |
| 27 |
a related location for its note, and additional related locations describing |
| 28 |
the include chains. */ |
| 29 |
|
| 30 |
#include "include-chain-1.h" |
| 31 |
|
| 32 |
/* We expect a failing compile due to the errors, but the use of |
| 33 |
-fdiagnostics-format=sarif-file means there should be no output to stderr. |
| 34 |
DejaGnu injects this message; ignore it: |
| 35 |
{ dg-prune-output "exit status is 1" } */ |
| 36 |
|
| 37 |
/* Verify that some JSON was written to a file with the expected name: |
| 38 |
{ dg-final { verify-sarif-file } } */ |
| 39 |
|
| 40 |
/* Use a Python script to verify various properties about the generated |
| 41 |
.sarif file: |
| 42 |
{ dg-final { run-sarif-pytest include-chain-1.c "include-chain-1.py" } } */ |