1 // RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-unreachable-code
2
test1()3 void test1() {
4 { ; { ;;}} ;;
5 }
6
test2()7 void test2() {
8 if (0) { if (1) {} } else { }
9
10 do { } while (0);
11
12 while (0) while(0) do ; while(0);
13
14 for ((void)0;0;(void)0)
15 for (;;)
16 for ((void)9;0;(void)2)
17 ;
18 for (int X = 0; 0; (void)0);
19 }
20
test3()21 void test3() {
22 switch (0) {
23
24 case 4:
25 if (0) {
26 case 6: ;
27 }
28 default:
29 ;
30 }
31 }
32
test4()33 void test4() {
34 if (0); // expected-warning {{if statement has empty body}} expected-note {{put the semicolon on a separate line to silence this warning}}
35
36 int X; // declaration in a block.
37
38 foo: if (0); // expected-warning {{if statement has empty body}} expected-note {{put the semicolon on a separate line to silence this warning}}
39 }
40
41 typedef int t;
test5()42 void test5() {
43 if (0); // expected-warning {{if statement has empty body}} expected-note {{put the semicolon on a separate line to silence this warning}}
44
45 t x = 0;
46
47 if (0); // expected-warning {{if statement has empty body}} expected-note {{put the semicolon on a separate line to silence this warning}}
48 }
49
50
test6(void)51 void test6(void) {
52 do
53 . // expected-error {{expected expression}}
54 while (0);
55 }
56
test7()57 int test7() {
58 return 4 // expected-error {{expected ';' after return statement}}
59 }
60
61 void test8() {
62 // Should not skip '}' and produce a "expected '}'" error.
63 undecl // expected-error {{use of undeclared identifier 'undecl'}}
64 }
65
66 int test9() {
67 int T[] = {1, 2, };
68
69 int X;
70 X = 0, // expected-error {{expected ';' after expression}}
71 {
72 }
73
74 X = 0, // expected-error {{expected ';' after expression}}
75 if (0)
76 ;
77
78 return 4, // expected-error {{expected ';' after return statement}}
79 }
80