blob: ce7d1a8aefd6edf1ff9ab63fd6e636d85550808f [file] [log] [blame]
Richard Smith0635aa72012-02-22 06:49:09 +00001// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
2
3struct S { S(int); operator bool(); };
4
5void f() {
6 int a;
7 typedef int n;
8
9 while (a) ;
10 while (int x) ; // expected-error {{variable declaration in condition must have an initializer}}
11 while (float x = 0) ;
12 if (const int x = a) ; // expected-warning{{empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
13 switch (int x = a+10) {}
14 for (; int x = ++a; ) ;
15
16 if (S(a)) {} // ok
17 if (S(a) = 0) {} // ok
18 if (S(a) == 0) {} // ok
19
20 if (S(n)) {} // expected-error {{unexpected type name 'n': expected expression}}
21 if (S(n) = 0) {} // ok
22 if (S(n) == 0) {} // expected-error {{unexpected type name 'n': expected expression}}
23
24 if (S b(a)) {} // expected-error {{variable declaration in condition cannot have a parenthesized initializer}}
25
26 if (S b(n)) {} // expected-error {{a function type is not allowed here}} expected-error {{must have an initializer}}
27 if (S b(n) = 0) {} // expected-error {{a function type is not allowed here}}
28 if (S b(n) == 0) {} // expected-error {{a function type is not allowed here}} expected-error {{did you mean '='?}}
29
30 // FIXME: this is legal, and incorrectly rejected, because tentative parsing
31 // does not yet know about braced function-style casts.
32 if (S{a}) {} // unexpected-error{{unqualified-id}}
33
34 if (S a{a}) {} // ok
35 if (S a = {a}) {} // ok
36 if (S a == {a}) {} // expected-error {{did you mean '='?}}
37}