]> git.ipfire.org Git - thirdparty/gcc.git/blob
c37411a
[thirdparty/gcc.git] /
1 /* Example of GCC SARIF output for a replacement fix-it hint. */
2
3 {"$schema": "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json",
4 "version": "2.1.0",
5 "runs": [{"tool": {"driver": {"name": "GNU C23",
6 "fullName": "GNU C23 (GCC) version 15.0.1 20250203 (experimental) (x86_64-pc-linux-gnu)",
7 "version": "15.0.1 20250203 (experimental)",
8 "informationUri": "https://gcc.gnu.org/gcc-15/",
9 "rules": [{"id": "-Wformat=",
10 "helpUri": "https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wformat"}]}},
11 "invocations": [{"executionSuccessful": true,
12 "toolExecutionNotifications": []}],
13 "originalUriBaseIds": {"PWD": {"uri": "file:///this/path/does/not/exist/"}},
14 "artifacts": [{"location": {"uri": "/this/path/does/not/exist/diagnostic-ranges.c",
15 "uriBaseId": "PWD"},
16 "sourceLanguage": "c",
17 "contents": {"text": "#include <stdio.h>\n\nvoid test_mismatching_types (const char *msg)\n{\n printf(\"hello %i\", msg);\n}\n"},
18 "roles": ["analysisTarget"]}],
19 "results": [{"ruleId": "-Wformat=",
20 "level": "warning",
21 "message": {"text": "format '%i' expects argument of type 'int', but argument 2 has type 'const char *'"},
22 "locations": [{"physicalLocation": {"artifactLocation": {"uri": "/this/path/does/not/exist/diagnostic-ranges.c",
23 "uriBaseId": "PWD"},
24 "region": {"startLine": 5,
25 "startColumn": 17,
26 "endColumn": 19},
27 "contextRegion": {"startLine": 5,
28 "snippet": {"text": " printf(\"hello %i\", msg);\n"}}},
29 "logicalLocations": [{"name": "test_mismatching_types",
30 "fullyQualifiedName": "test_mismatching_types",
31 "decoratedName": "test_mismatching_types",
32 "kind": "function"}],
33 "annotations": [{"startLine": 5,
34 "startColumn": 17,
35 "endColumn": 19,
36 "message": {"text": "int"}},
37 {"startLine": 5,
38 "startColumn": 22,
39 "endColumn": 25,
40 "message": {"text": "const char *"}}]}],
41 "fixes": [{"artifactChanges": [{"artifactLocation": {"uri": "/this/path/does/not/exist/diagnostic-ranges.c",
42 "uriBaseId": "PWD"},
43 "replacements": [{"deletedRegion": {"startLine": 5,
44 "startColumn": 17,
45 "endColumn": 19},
46 "insertedContent": {"text": "%s"}}]}]}]}]}]}
47
48 /* { dg-begin-multiline-output "" }
49 /this/path/does/not/exist/diagnostic-ranges.c:5:17: warning: format '%i' expects argument of type 'int', but argument 2 has type 'const char *' [-Wformat=]
50 5 | printf("hello %i", msg);
51 | ^~ ~~~
52 | | |
53 | int const char *
54 | %s
55 { dg-end-multiline-output "" } */