Debian Codegraph @

gcc/testsuite/gcc.dg/missing-header-fixit-1a.c

raw
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-error "implicit declaration" } */
13 /* { dg-message "include '<stdio.h>' or provide a declaration of 'printf'" "" { target *-*-* } .-1 } */
14 /* { dg-warning "incompatible implicit declaration of built-in function 'printf'" "" { target *-*-* } .-2 } */
15 }
16
17 /* Verify the output from -fdiagnostics-generate-patch.
18 We expect the patch to begin with a header, containing this
19 source filename, via an absolute path.
20 Given the path, we can only capture it via regexps. */
21 /* { dg-regexp "\\-\\-\\- .*" } */
22 /* { dg-regexp "\\+\\+\\+ .*" } */
23 /* Use #if 0/#endif rather than comments, to allow the text to contain
24 a comment. */
25 #if 0
26 { dg-begin-multiline-output "" }
27 @@ -1,3 +1,4 @@
28 +#include <stdio.h>
29 /* Example of a fix-it hint that adds a #include directive,
30 adding them to the top of the file, given that there is no
31 pre-existing #include. */
32 { dg-end-multiline-output "" }
33 #endif
34
35 /* FIXME: should we attempt to skip leading comments when determining the
36 insertion location?
37 Similarly, should we attempt to be within single-inclusion guards, etc? */