1 /* { dg-options "-fdiagnostics-show-caret -Wno-switch-unreachable" } */
2
3 extern int foo (void);
4
missing_open_paren(void)5 void missing_open_paren (void)
6 {
7 if foo ()) /* { dg-line missing_open_paren } */
8 {
9 }
10 /* { dg-error "expected '\\(' before 'foo'" "" { target c } missing_open_paren } */
11 /* { dg-begin-multiline-output "" }
12 if foo ())
13 ^~~
14 (
15 { dg-end-multiline-output "" } */
16 /* { dg-error "expected statement before '\\)' token" "" { target c } missing_open_paren } */
17 /* { dg-begin-multiline-output "" }
18 if foo ())
19 ^
20 { dg-end-multiline-output "" } */
21 }
22
missing_close_square(void)23 void missing_close_square (void)
24 {
25 const char test [42; /* { dg-error "22: expected ']' before ';' token" } */
26 /* { dg-begin-multiline-output "" }
27 const char test [42;
28 ^
29 ]
30 { dg-end-multiline-output "" } */
31 }
32
33 int missing_semicolon (void)
34 {
35 return 42 /* { dg-error "expected ';'" } */
36 }
37 /* { dg-begin-multiline-output "" }
38 return 42
39 ^
40 ;
41 }
42 ~
43 { dg-end-multiline-output "" } */
44
45
46 /* We don't offer a fix-it hint for this case in C, as it could be
47 colon or ellipsis.
48 TODO: we could be smarter about error-recovery here; given the
49 return perhaps we could assume a missing colon. */
50
51 int missing_colon_in_switch (int val)
52 {
53 switch (val)
54 {
55 case 42
56 return 42; /* { dg-error "expected ':' or '...' before 'return'" } */
57 /* { dg-begin-multiline-output "" }
58 return 42;
59 ^~~~~~
60 { dg-end-multiline-output "" } */
61
62 default:
63 return val;
64 }
65 }
66
67 /* { dg-begin-multiline-output "" }
68 int dummy;
69 ^~~
70 { dg-end-multiline-output "" } */
71 int dummy;/* { dg-error "expected declaration or statement at end of input" "" { target c } } */
72