Douglas Gregor | 87c3007 | 2010-07-26 04:08:02 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Cedric Venet | 3d65864 | 2009-02-14 20:20:19 +0000 | [diff] [blame] | 2 | |
Richard Smith | 0635aa7 | 2012-02-22 06:49:09 +0000 | [diff] [blame] | 3 | struct S { S(int); operator bool(); }; |
| 4 | |
Cedric Venet | 3d65864 | 2009-02-14 20:20:19 +0000 | [diff] [blame] | 5 | void f() { |
| 6 | int a; |
| 7 | while (a) ; |
Richard Smith | 0635aa7 | 2012-02-22 06:49:09 +0000 | [diff] [blame] | 8 | while (int x) ; // expected-error {{variable declaration in condition must have an initializer}} |
Cedric Venet | 3d65864 | 2009-02-14 20:20:19 +0000 | [diff] [blame] | 9 | while (float x = 0) ; |
Dmitri Gribenko | 625bb56 | 2012-02-14 22:14:32 +0000 | [diff] [blame] | 10 | if (const int x = a) ; // expected-warning{{empty body}} expected-note{{put the semicolon on a separate line to silence this warning}} |
Cedric Venet | 3d65864 | 2009-02-14 20:20:19 +0000 | [diff] [blame] | 11 | switch (int x = a+10) {} |
| 12 | for (; int x = ++a; ) ; |
Richard Smith | 0635aa7 | 2012-02-22 06:49:09 +0000 | [diff] [blame] | 13 | |
| 14 | if (S a(42)) {} // expected-error {{variable declaration in condition cannot have a parenthesized initializer}} |
Cedric Venet | 3d65864 | 2009-02-14 20:20:19 +0000 | [diff] [blame] | 15 | } |