blob: 5672eea72bcf70313036fb2056bde96e33f22991 [file] [log] [blame]
Douglas Gregor87c30072010-07-26 04:08:02 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Cedric Venet3d658642009-02-14 20:20:19 +00002
Richard Smith0635aa72012-02-22 06:49:09 +00003struct S { S(int); operator bool(); };
4
Cedric Venet3d658642009-02-14 20:20:19 +00005void f() {
6 int a;
7 while (a) ;
Richard Smith0635aa72012-02-22 06:49:09 +00008 while (int x) ; // expected-error {{variable declaration in condition must have an initializer}}
Cedric Venet3d658642009-02-14 20:20:19 +00009 while (float x = 0) ;
Dmitri Gribenko625bb562012-02-14 22:14:32 +000010 if (const int x = a) ; // expected-warning{{empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
Cedric Venet3d658642009-02-14 20:20:19 +000011 switch (int x = a+10) {}
12 for (; int x = ++a; ) ;
Richard Smith0635aa72012-02-22 06:49:09 +000013
14 if (S a(42)) {} // expected-error {{variable declaration in condition cannot have a parenthesized initializer}}
Cedric Venet3d658642009-02-14 20:20:19 +000015}