1 /* Example of fix-it hints that add #include directives,
2 adding them after a pre-existing #include. */
4 /* { dg-options "-fdiagnostics-generate-patch" } */
6 /* This is padding (to avoid the generated patch containing DejaGnu
13 extern int sprintf (char *dst, const char *format, ...);
18 std::string s ("hello world"); // { dg-error ".string. is not a member of .std." }
19 // { dg-message ".std::string. is defined in header .<string>.; did you forget to .#include <string>.?" "" { target *-*-* } .-1 }
21 std::cout << 10; // { dg-error ".cout. is not a member of .std." }
22 // { dg-message ".std::cout. is defined in header .<iostream>.; did you forget to .#include <iostream>.?" "" { target *-*-* } .-1 }
25 /* Same again, to test idempotency of the added "#include" fix-it. */
29 std::string s ("hello again"); // { dg-error ".string. is not a member of .std." }
30 // { dg-message ".std::string. is defined in header .<string>.; did you forget to .#include <string>.?" "" { target *-*-* } .-1 }
32 std::cout << 10; // { dg-error ".cout. is not a member of .std." }
33 // { dg-message ".std::cout. is defined in header .<iostream>.; did you forget to .#include <iostream>.?" "" { target *-*-* } .-1 }
36 /* Verify the output from -fdiagnostics-generate-patch.
37 We expect the patch to begin with a header, containing this
38 source filename, via an absolute path.
39 Given the path, we can only capture it via regexps. */
40 /* { dg-regexp "\\-\\-\\- .*" } */
41 /* { dg-regexp "\\+\\+\\+ .*" } */
43 /* Verify the hunks within the patch.
44 Use #if 0/#endif rather than comments, to allow the text to contain
46 We expect a "#include <string>" and "#include <iostream>" to each have been
47 added once, immediately below the last #include. */
49 { dg-begin-multiline-output "" }
59 { dg-end-multiline-output "" }