Debian Codegraph @

gcc/testsuite/g++.dg/warn/Wvexing-parse4.C

raw
1 // PR c++/25814
2 // { dg-do compile { target c++98_only } }
3 // { dg-additional-options "-fdiagnostics-show-caret" }
4 // Test -Wvexing-parse's fix-it hints in C++98.
5
6 struct X { };
7
8 struct T {
9 T(X);
10 int m;
11 };
12
13 struct U {
14 U();
15 int m;
16 };
17
18 int
19 main ()
20 {
21 T t(X()); // { dg-warning "6:parentheses were disambiguated as a function declaration" }
22 /* { dg-begin-multiline-output "" }
23 T t(X());
24 ^~~~~
25 { dg-end-multiline-output "" } */
26 // { dg-message "6:add parentheses to declare a variable" "" { target *-*-* } 21 }
27 /* { dg-begin-multiline-output "" }
28 T t(X());
29 ^~~~~
30 ( )
31 { dg-end-multiline-output "" } */
32
33 int n( ); // { dg-warning "8:empty parentheses were disambiguated as a function declaration" }
34 /* { dg-begin-multiline-output "" }
35 int n( );
36 ^~~~~
37 { dg-end-multiline-output "" } */
38 // { dg-message "8:remove parentheses to default-initialize a variable" "" { target *-*-* } 33 }
39 /* { dg-begin-multiline-output "" }
40 int n( );
41 ^~~~~
42 -----
43 { dg-end-multiline-output "" } */
44
45 T y(); // { dg-warning "6:empty parentheses were disambiguated as a function declaration" }
46 /* { dg-begin-multiline-output "" }
47 T y();
48 ^~
49 { dg-end-multiline-output "" } */
50
51 X x(); // { dg-warning "6:empty parentheses were disambiguated as a function declaration" }
52 /* { dg-begin-multiline-output "" }
53 X x();
54 ^~
55 { dg-end-multiline-output "" } */
56 // { dg-message "6:remove parentheses to default-initialize a variable" "" { target *-*-* } 51 }
57 /* { dg-begin-multiline-output "" }
58 X x();
59 ^~
60 --
61 { dg-end-multiline-output "" } */
62
63 U u(); // { dg-warning "6:empty parentheses were disambiguated as a function declaration" }
64 /* { dg-begin-multiline-output "" }
65 U u();
66 ^~
67 { dg-end-multiline-output "" } */
68 // { dg-message "6:remove parentheses to default-initialize a variable" "" { target *-*-* } 63 }
69 /* { dg-begin-multiline-output "" }
70 U u();
71 ^~
72 --
73 { dg-end-multiline-output "" } */
74 }