[Clang] replace 'bitfield' with 'bit-field' for consistency (#117881)
[llvm-project.git] / clang / test / Parser / cxx0x-condition.cpp
blob19d5a7395d4173cc569acb58509a9a529b102cc8
1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
3 struct S { S(int); operator bool(); };
5 void f() {
6 int a;
7 typedef int n;
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; ) ;
16 if (S(a)) {} // ok
17 if (S(a) = 0) {} // expected-warning {{redundant parentheses}} expected-note 2{{}}
18 if (S(a) == 0) {} // ok
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}}
24 if (S b(a)) {} // expected-error {{variable declaration in condition cannot have a parenthesized initializer}}
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}}
30 S s(a);
31 if (S{s}) {} // ok
32 if (S a{s}) {} // ok
33 if (S a = {s}) {} // ok
34 if (S a == {s}) {} // expected-error {{did you mean '='?}}
36 if (S(b){a}) {} // ok
37 if (S(b) = {a}) {} // ok