[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / SemaCXX / condition.cpp
blobdb7694c7ee024d732ca63cceb28083e06b4c4fea
1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
3 void test() {
4 int x;
5 if (x) ++x;
6 if (int x=0) ++x;
8 typedef int arr[10];
9 while (arr x={0}) ; // expected-error {{an array type is not allowed here}}
10 while (int f()=0) ; // expected-error {{a function type is not allowed here}}
12 struct S {} s;
13 if (s) ++x; // expected-error {{value of type 'struct S' is not contextually convertible to 'bool'}}
14 while (struct S x=s) ; // expected-error {{value of type 'struct S' is not contextually convertible to 'bool'}}
15 do ; while (s); // expected-error {{value of type 'struct S' is not contextually convertible to 'bool'}}
16 for (;s;) ; // expected-error {{value of type 'struct S' is not contextually convertible to 'bool'}}
17 switch (s) {} // expected-error {{statement requires expression of integer type ('struct S' invalid)}}
19 while (struct NewS *x=0) ;
20 while (struct S {} *x=0) ; // expected-error {{'S' cannot be defined in a condition}}
21 while (struct {} *x=0) ; // expected-error-re {{'(unnamed struct at {{.*}})' cannot be defined in a condition}}
22 switch (enum {E} x=0) ; // expected-error-re {{'(unnamed enum at {{.*}})' cannot be defined in a condition}}
23 // expected-warning@-1 {{switch statement has empty body}}
24 // expected-note@-2 {{put the semicolon on a separate line}}
26 if (int x=0) { // expected-note 2 {{previous definition is here}}
27 int x; // expected-error {{redefinition of 'x'}}
29 else
30 int x; // expected-error {{redefinition of 'x'}}
31 while (int x=0) int x; // expected-error {{redefinition of 'x'}} expected-note {{previous definition is here}}
32 while (int x=0) { int x; } // expected-error {{redefinition of 'x'}} expected-note {{previous definition is here}}
33 for (int x; int x=0; ) ; // expected-error {{redefinition of 'x'}} expected-note {{previous definition is here}}
34 for (int x; ; ) int x; // expected-error {{redefinition of 'x'}} expected-note {{previous definition is here}}
35 for (; int x=0; ) int x; // expected-error {{redefinition of 'x'}} expected-note {{previous definition is here}}
36 for (; int x=0; ) { int x; } // expected-error {{redefinition of 'x'}} expected-note {{previous definition is here}}
37 switch (int x=0) { default: int x; } // expected-error {{redefinition of 'x'}} expected-note {{previous definition is here}}
40 int* get_int_ptr();
42 void test2() {
43 float *ip;
44 if (int *ip = ip) {
48 // Make sure we do function/array decay.
49 void test3() {
50 if ("help")
51 (void) 0;
53 if (test3) // expected-warning {{address of function 'test3' will always evaluate to 'true'}} \
54 expected-note {{prefix with the address-of operator to silence this warning}}
55 (void) 0;
58 void test4(bool (&x)(void)) {
59 while (x);
62 template <class>
63 void test5() {
64 if (struct S {}* p = 0) // expected-error {{'S' cannot be defined in a condition}}
67 void test5_inst() {
68 test5<int>();
71 void PR28373() {
72 if (!x) {} // expected-error {{undeclared}}