]>
Commit | Line | Data |
---|---|---|
eea77d1f DM |
1 | /* Example of a fix-it hint that adds a #include directive, |
2 | adding them to the top of the file, given that there is no | |
3 | pre-existing #include. */ | |
4 | ||
5 | /* This is padding (to avoid the generated patch containing DejaGnu | |
6 | directives). */ | |
7 | ||
8 | /* { dg-options "-fdiagnostics-generate-patch" } */ | |
9 | ||
10 | void test (int i, int j) | |
11 | { | |
12 | printf ("%i of %i\n", i, j); /* { dg-warning "implicit declaration" } */ | |
13 | /* { dg-message "include '<stdio.h>' or provide a declaration of 'printf'" "" { target *-*-* } .-1 } */ | |
14 | } | |
15 | ||
16 | /* Verify the output from -fdiagnostics-generate-patch. | |
17 | We expect the patch to begin with a header, containing this | |
18 | source filename, via an absolute path. | |
19 | Given the path, we can only capture it via regexps. */ | |
20 | /* { dg-regexp "\\-\\-\\- .*" } */ | |
21 | /* { dg-regexp "\\+\\+\\+ .*" } */ | |
22 | /* Use #if 0/#endif rather than comments, to allow the text to contain | |
23 | a comment. */ | |
24 | #if 0 | |
25 | { dg-begin-multiline-output "" } | |
26 | @@ -1,3 +1,4 @@ | |
27 | +#include <stdio.h> | |
28 | /* Example of a fix-it hint that adds a #include directive, | |
29 | adding them to the top of the file, given that there is no | |
30 | pre-existing #include. */ | |
31 | { dg-end-multiline-output "" } | |
32 | #endif | |
33 | ||
34 | /* FIXME: should we attempt to skip leading comments when determining the | |
35 | insertion location? | |
36 | Similarly, should we attempt to be within single-inclusion guards, etc? */ |