1 /* { dg-options "-fdiagnostics-show-caret -Wno-return-type" } */
2
3 extern int foo (void);
4 extern int bar (void);
5
missing_close_paren_in_switch(int i)6 int missing_close_paren_in_switch (int i)
7 {
8 switch (i /* { dg-error "12: expected '\\)' before '.' token" } */
9 {
10 /* { dg-begin-multiline-output "" }
11 switch (i
12 ~ ^
13 )
14 {
15 ~
16 { dg-end-multiline-output "" } */
17
18 case 0:
19 return 5;
20 default:
21 return i;
22 }
23 } /* { dg-error "1: expected" } */
24 /* { dg-begin-multiline-output "" }
25 }
26 ^
27 { dg-end-multiline-output "" } */
28
29 void missing_close_paren_in_if (void)
30 {
31 if (foo () /* { dg-line start_of_if } */
32 && bar () /* { dg-error "16: expected '\\)' before '.' token" } */
33 {
34 /* { dg-begin-multiline-output "" }
35 && bar ()
36 ^
37 )
38 {
39 ~
40 { dg-end-multiline-output "" } */
41 /* { dg-message "6: to match this '\\('" "" { target *-*-* } start_of_if } */
42 /* { dg-begin-multiline-output "" }
43 if (foo ()
44 ^
45 { dg-end-multiline-output "" } */
46 }
47 } /* { dg-error "1: expected" } */
48 /* { dg-begin-multiline-output "" }
49 }
50 ^
51 { dg-end-multiline-output "" } */
52
53 int missing_colon_in_ternary (int flag)
54 {
55 return flag ? 42 0; /* { dg-error "expected ':' before numeric constant" } */
56 /* { dg-begin-multiline-output "" }
57 return flag ? 42 0;
58 ^~
59 :
60 { dg-end-multiline-output "" } */
61 }
62