1 /* Example of where the error occurs before the first #include,
2 which in this case happens to be the missing header.
3 For this case, expect to insert the #include at the top of the file. */
4
5 /* { dg-options "-fdiagnostics-generate-patch" } */
6
test()7 void test ()
8 {
9 std::string test; // { dg-error ".string. is not a member of .std." }
10 // { dg-message ".std::string. is defined in header .<string>.; did you forget to .#include <string>.?" "" { target *-*-* } .-1 }
11 }
12
13 #include <string>
14
15 /* Verify the output from -fdiagnostics-generate-patch.
16 We expect the patch to begin with a header, containing this
17 source filename, via an absolute path.
18 Given the path, we can only capture it via regexps. */
19 /* { dg-regexp "\\-\\-\\- .*" } */
20 /* { dg-regexp "\\+\\+\\+ .*" } */
21
22 /* Verify the hunks within the patch.
23 Use #if 0/#endif rather than comments, to allow the text to contain
24 a comment.
25 We expect a "#include <string>" have been added once, at the top
26 of the file. */
27 #if 0
28 { dg-begin-multiline-output "" }
29 @@ -1,3 +1,4 @@
30 +#include <string>
31 /* Example of where the error occurs before the first #include,
32 which in this case happens to be the missing header.
33 For this case, expect to insert the #include at the top of the file. */
34 { dg-end-multiline-output "" }
35 #endif
36