aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/missing-header-fixit-3.c
blob: 7c72b1decc8eceeca42aceb4ba9f34d2cbd6f702 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* Example of a fix-it hint that adds a #include directive,
   adding them to the top of the file, given that there is no
   pre-existing #include.  */

/* { dg-options "-fdiagnostics-show-caret -fdiagnostics-show-line-numbers" } */

void test (int i, int j)
{
  printf ("%i of %i\n", i, j); /* { dg-warning "implicit declaration" } */
  /* { dg-message "include '<stdio.h>' or provide a declaration of 'printf'" "" { target *-*-* } .-1 } */
#if 0
/* { dg-begin-multiline-output "" }
9 |   printf ("%i of %i\n", i, j);
  |   ^~~~~~
   { dg-end-multiline-output "" } */
/* { dg-begin-multiline-output "" }
+++ |+#include <stdio.h>
  1 | /* Example of a fix-it hint that adds a #include directive,
....
  9 |   printf ("%i of %i\n", i, j);
    |   ^~~~~~
   { dg-end-multiline-output "" } */
#endif
}