39 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s2 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)) {} // ok17 if (S(a) = 0) {} // expected-warning {{redundant parentheses}} expected-note 2{{}}18 if (S(a) == 0) {} // ok19 20 if (S(n)) {} // expected-error {{unexpected type name 'n': expected expression}}21 if (S(n) = 0) {} // expected-warning {{redundant parentheses}} expected-note 2{{}}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}}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}}29 30 S s(a);31 if (S{s}) {} // ok32 if (S a{s}) {} // ok33 if (S a = {s}) {} // ok34 if (S a == {s}) {} // expected-error {{did you mean '='?}}35 36 if (S(b){a}) {} // ok37 if (S(b) = {a}) {} // ok38}39