Debian Codegraph @

gcc/testsuite/g++.dg/lookup/missing-std-include-3.C

raw
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 /* { dg-skip-if "requires hosted libstdc++ for string" { ! hostedlib } } */
7
8 void test ()
9 {
10 std::string test; // { dg-error ".string. is not a member of .std." }
11 // { dg-message ".std::string. is defined in header .<string>.; this is probably fixable by adding .#include <string>." "" { target *-*-* } .-1 }
12 }
13
14 #include <string>
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
23 /* Verify the hunks within the patch.
24 Use #if 0/#endif rather than comments, to allow the text to contain
25 a comment.
26 We expect a "#include <string>" have been added once, at the top
27 of the file. */
28 #if 0
29 { dg-begin-multiline-output "" }
30 @@ -1,3 +1,4 @@
31 +#include <string>
32 /* Example of where the error occurs before the first #include,
33 which in this case happens to be the missing header.
34 For this case, expect to insert the #include at the top of the file. */
35 { dg-end-multiline-output "" }
36 #endif