1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 
3 void test() {
4   int x;
5   if (x) ++x;
6   if (int x=0) ++x;
7 
8   typedef int arr[10];
9   while (arr x=0) ; // expected-error {{an array type is not allowed here}} expected-error {{array initializer must be an initializer list}}
10   while (int f()=0) ; // expected-warning {{interpreted as a function declaration}} expected-note {{initializer}} expected-error {{a function type is not allowed here}}
11 
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)}}
18 
19   while (struct NewS *x=0) ;
20   while (struct S {} *x=0) ; // expected-error {{types may not be defined in conditions}}
21   while (struct {} *x=0) ; // expected-error {{types may not be defined in conditions}}
22   switch (enum {E} x=0) ; // expected-error {{types may not be defined in conditions}} expected-error {{cannot initialize}} \
23   // expected-warning{{enumeration value 'E' not handled in switch}}
24 
25   if (int x=0) { // expected-note 2 {{previous definition is here}}
26     int x;  // expected-error {{redefinition of 'x'}}
27   }
28   else
29     int x;  // expected-error {{redefinition of 'x'}}
30   while (int x=0) int x; // expected-error {{redefinition of 'x'}} expected-note {{previous definition is here}}
31   while (int x=0) { int x; } // expected-error {{redefinition of 'x'}} expected-note {{previous definition is here}}
32   for (int x; int x=0; ) ; // expected-error {{redefinition of 'x'}} expected-note {{previous definition is here}}
33   for (int x; ; ) int x; // expected-error {{redefinition of 'x'}} expected-note {{previous definition is here}}
34   for (; int x=0; ) 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   switch (int x=0) { default: int x; } // expected-error {{redefinition of 'x'}} expected-note {{previous definition is here}}
37 }
38 
39 int* get_int_ptr();
40 
41 void test2() {
42   float *ip;
43   if (int *ip = ip) {
44   }
45 }
46 
47 // Make sure we do function/array decay.
48 void test3() {
49   if ("help")
50     (void) 0;
51 
52   if (test3) // expected-warning {{address of function 'test3' will always evaluate to 'true'}} \
53                 expected-note {{prefix with the address-of operator to silence this warning}}
54     (void) 0;
55 }
56 
57 void test4(bool (&x)(void)) {
58   while (x);
59 }
60