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