libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / sarif-output / include-chain-2.c
bloba04b647d259ee09e99b417e39c23ae3c29d7afe6
1 /* { dg-require-effective-target analyzer } */
2 /* { dg-options "-fanalyzer -fdiagnostics-format=sarif-file" } */
3 /* { dg-do compile } */
5 /* Verify that SARIF output can capture chains of include files in
6 diagnostic paths within result locations.
8 Generate an analyzer warning with a path, using a chain of header files
9 both for the warning and for the events within its esxecution path.
10 In textual form, we'd expect something like:
12 In file included from PATH/include-chain-2.c:28:
13 PATH/include-chain-2.h: In function 'test':
14 PATH/include-chain-2.h:6:3: warning: double-'free' of 'ptr' [CWE-415] [-Wanalyzer-double-free]
15 6 | __builtin_free (ptr);
16 | ^~~~~~~~~~~~~~~~~~~~
17 'test': events 1-2
18 5 | __builtin_free (ptr);
19 | ^~~~~~~~~~~~~~~~~~~~
20 | |
21 | (1) first 'free' here
22 6 | __builtin_free (ptr);
23 | ~~~~~~~~~~~~~~~~~~~~
24 | |
25 | (2) second 'free' here; first 'free' was at (1)
28 #include "include-chain-2.h"
30 /* Verify that some JSON was written to a file with the expected name:
31 { dg-final { verify-sarif-file } } */
33 /* Use a Python script to verify various properties about the generated
34 .sarif file:
35 { dg-final { run-sarif-pytest include-chain-2.c "test-include-chain-2.py" } } */