2 // { dg-do compile { target c++11 } }
3 // { dg-additional-options "-fdiagnostics-show-caret" }
4 // Test -Wvexing-parse's fix-it hints in C++11.
6 #include <initializer_list>
12 S(std::initializer_list<X>);
23 W(std::initializer_list<X>);
36 Careful what we're suggesting:
38 S a({X()}) -> (std::initializer_list<X>)
39 S a{X()} -> (std::initializer_list<X>)
41 S a(X()); // { dg-warning "6:parentheses were disambiguated as a function declaration" }
42 /* { dg-begin-multiline-output "" }
45 { dg-end-multiline-output "" } */
46 // { dg-message "6:add parentheses to declare a variable" "" { target *-*-* } 41 }
47 /* { dg-begin-multiline-output "" }
51 { dg-end-multiline-output "" } */
53 T t(X()); // { dg-warning "6:parentheses were disambiguated as a function declaration" }
54 /* { dg-begin-multiline-output "" }
57 { dg-end-multiline-output "" } */
58 // { dg-message "6:replace parentheses with braces to declare a variable" "" { target *-*-* } 53 }
59 /* { dg-begin-multiline-output "" }
65 { dg-end-multiline-output "" } */
67 int n( ); // { dg-warning "8:empty parentheses were disambiguated as a function declaration" }
68 /* { dg-begin-multiline-output "" }
71 { dg-end-multiline-output "" } */
72 // { dg-message "8:remove parentheses to default-initialize a variable" "" { target *-*-* } 67 }
73 /* { dg-begin-multiline-output "" }
77 { dg-end-multiline-output "" } */
78 // { dg-message "8:or replace parentheses with braces to value-initialize a variable" "" { target *-*-* } 67 }
80 S s(); // { dg-warning "6:empty parentheses were disambiguated as a function declaration" }
81 /* { dg-begin-multiline-output "" }
84 { dg-end-multiline-output "" } */
86 X x(); // { dg-warning "6:empty parentheses were disambiguated as a function declaration" }
87 /* { dg-begin-multiline-output "" }
90 { dg-end-multiline-output "" } */
91 // { dg-message "6:remove parentheses to default-initialize a variable" "" { target *-*-* } 86 }
92 /* { dg-begin-multiline-output "" }
96 { dg-end-multiline-output "" } */
97 // { dg-message "6:or replace parentheses with braces to aggregate-initialize a variable" "" { target *-*-* } 86 }
99 W w(); // { dg-warning "6:empty parentheses were disambiguated as a function declaration" }
100 /* { dg-begin-multiline-output "" }
103 { dg-end-multiline-output "" } */
104 // { dg-message "6:remove parentheses to default-initialize a variable" "" { target *-*-* } 99 }
105 /* { dg-begin-multiline-output "" }
109 { dg-end-multiline-output "" } */
111 T t2(); // { dg-warning "7:empty parentheses were disambiguated as a function declaration" }
112 /* { dg-begin-multiline-output "" }
115 { dg-end-multiline-output "" } */
117 U u(); // { dg-warning "6:empty parentheses were disambiguated as a function declaration" }
118 /* { dg-begin-multiline-output "" }
121 { dg-end-multiline-output "" } */
122 // { dg-message "6:remove parentheses to default-initialize a variable" "" { target *-*-* } 117 }
123 /* { dg-begin-multiline-output "" }
127 { dg-end-multiline-output "" } */
128 // { dg-message "6:or replace parentheses with braces to value-initialize a variable" "" { target *-*-* } 117 }