xref: /aosp_15_r20/external/clang/test/Parser/cxx-condition.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify %s
2*67e74705SXin Li 
3*67e74705SXin Li struct S { S(int); operator bool(); };
4*67e74705SXin Li 
f()5*67e74705SXin Li void f() {
6*67e74705SXin Li   int a;
7*67e74705SXin Li   while (a) ;
8*67e74705SXin Li   while (int x) ; // expected-error {{variable declaration in condition must have an initializer}}
9*67e74705SXin Li   while (float x = 0) ;
10*67e74705SXin Li   if (const int x = a) ; // expected-warning{{empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
11*67e74705SXin Li   switch (int x = a+10) {}
12*67e74705SXin Li   for (; int x = ++a; ) ;
13*67e74705SXin Li 
14*67e74705SXin Li   if (S a(42)) {} // expected-error {{variable declaration in condition cannot have a parenthesized initializer}}
15*67e74705SXin Li }
16