blob: 8215f4c92a604e5107c39277ec6c553f7bdaf864 [file] [log] [blame]
Mike Stump0978af82010-01-23 20:12:18 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-unreachable-code
Chris Lattner4dfe4b92006-08-09 05:47:56 +00002
Mike Stump753d1202009-07-22 00:43:08 +00003void test1() {
Chris Lattner4dfe4b92006-08-09 05:47:56 +00004 { ; { ;;}} ;;
5}
6
Mike Stump753d1202009-07-22 00:43:08 +00007void test2() {
Chris Lattner905caf32006-08-10 04:59:23 +00008 if (0) { if (1) {} } else { }
9
10 do { } while (0);
11
12 while (0) while(0) do ; while(0);
13
Daniel Dunbar769f9402009-08-01 06:07:15 +000014 for ((void)0;0;(void)0)
Chris Lattner905caf32006-08-10 04:59:23 +000015 for (;;)
Daniel Dunbar769f9402009-08-01 06:07:15 +000016 for ((void)9;0;(void)2)
Chris Lattner905caf32006-08-10 04:59:23 +000017 ;
Daniel Dunbar769f9402009-08-01 06:07:15 +000018 for (int X = 0; 0; (void)0);
Chris Lattner905caf32006-08-10 04:59:23 +000019}
Chris Lattner97353f22006-08-10 05:59:30 +000020
Mike Stump753d1202009-07-22 00:43:08 +000021void test3() {
Chris Lattner97353f22006-08-10 05:59:30 +000022 switch (0) {
23
24 case 4:
25 if (0) {
26 case 6: ;
27 }
28 default:
29 ;
30 }
31}
Chris Lattnerf8afb622006-08-10 18:26:31 +000032
Mike Stump753d1202009-07-22 00:43:08 +000033void test4() {
Dmitri Gribenko800ddf32012-02-14 22:14:32 +000034 if (0); // expected-warning {{if statement has empty body}} expected-note {{put the semicolon on a separate line to silence this warning}}
Chris Lattnerf8afb622006-08-10 18:26:31 +000035
36 int X; // declaration in a block.
37
Dmitri Gribenko800ddf32012-02-14 22:14:32 +000038foo: if (0); // expected-warning {{if statement has empty body}} expected-note {{put the semicolon on a separate line to silence this warning}}
Chris Lattnerf8afb622006-08-10 18:26:31 +000039}
Chris Lattner2f9980e2006-08-10 18:39:24 +000040
41typedef int t;
42void test5() {
Dmitri Gribenko800ddf32012-02-14 22:14:32 +000043 if (0); // expected-warning {{if statement has empty body}} expected-note {{put the semicolon on a separate line to silence this warning}}
Chris Lattner2f9980e2006-08-10 18:39:24 +000044
Chris Lattner9226b922008-11-13 18:42:17 +000045 t x = 0;
Chris Lattner2f9980e2006-08-10 18:39:24 +000046
Dmitri Gribenko800ddf32012-02-14 22:14:32 +000047 if (0); // expected-warning {{if statement has empty body}} expected-note {{put the semicolon on a separate line to silence this warning}}
Chris Lattner2f9980e2006-08-10 18:39:24 +000048}
Chris Lattnereddbcb22006-08-11 01:38:08 +000049
Chris Lattner0046de12008-11-13 18:52:53 +000050
51void test6(void) {
52 do
53 . // expected-error {{expected expression}}
54 while (0);
55}
56
Chris Lattner8e3eed02009-06-14 00:23:56 +000057int test7() {
58 return 4 // expected-error {{expected ';' after return statement}}
59}
Argyrios Kyrtzidis90ab3b72010-03-31 00:37:59 +000060
61void test8() {
62 // Should not skip '}' and produce a "expected '}'" error.
63 undecl // expected-error {{use of undeclared identifier 'undecl'}}
64}
Richard Smith0875c532012-09-18 00:52:05 +000065
66int 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}