xref: /llvm-project/clang/test/Parser/cxx-condition.cpp (revision 2a15b7460577b5f22b187a8ab9208da5360b983a)
167ca40c4SDouglas Gregor // RUN: %clang_cc1 -fsyntax-only -verify %s
22b4072feSArgyrios Kyrtzidis 
3*2a15b746SRichard Smith struct S { S(int); operator bool(); };
4*2a15b746SRichard Smith 
f()52b4072feSArgyrios Kyrtzidis void f() {
62b4072feSArgyrios Kyrtzidis   int a;
72b4072feSArgyrios Kyrtzidis   while (a) ;
8*2a15b746SRichard Smith   while (int x) ; // expected-error {{variable declaration in condition must have an initializer}}
92b4072feSArgyrios Kyrtzidis   while (float x = 0) ;
10800ddf3dSDmitri Gribenko   if (const int x = a) ; // expected-warning{{empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
112b4072feSArgyrios Kyrtzidis   switch (int x = a+10) {}
122b4072feSArgyrios Kyrtzidis   for (; int x = ++a; ) ;
13*2a15b746SRichard Smith 
14*2a15b746SRichard Smith   if (S a(42)) {} // expected-error {{variable declaration in condition cannot have a parenthesized initializer}}
152b4072feSArgyrios Kyrtzidis }
16