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