1 // RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -verify %s
3 extern int a
[] __attribute__((weak
));
8 const char str
[] = "text";
14 if (!b
) {} // expected-warning {{address of array 'b' will always evaluate to 'true'}}
15 if (b
== 0) {} // expected-warning {{comparison of array 'b' equal to a null pointer is always false}}
16 if (!c
.x
) {} // expected-warning {{address of array 'c.x' will always evaluate to 'true'}}
17 if (c
.x
== 0) {} // expected-warning {{comparison of array 'c.x' equal to a null pointer is always false}}
18 if (!str
) {} // expected-warning {{address of array 'str' will always evaluate to 'true'}}
19 if (0 == str
) {} // expected-warning {{comparison of array 'str' equal to a null pointer is always false}}
25 if (!array
) { // expected-warning {{address of array 'array' will always evaluate to 'true'}}
27 } else if (array
!= 0) { // expected-warning {{comparison of array 'array' not equal to a null pointer is always true}}
30 if (array
== 0) // expected-warning {{comparison of array 'array' equal to a null pointer is always false}}
37 int test2(int* pointer
, char ch
, void * pv
) {
38 if (!&pointer
) { // expected-warning {{address of 'pointer' will always evaluate to 'true'}}
42 if (&pointer
) { // expected-warning {{address of 'pointer' will always evaluate to 'true'}}
46 if (&pointer
== NULL
) {} // expected-warning {{comparison of address of 'pointer' equal to a null pointer is always false}}
48 if (&pointer
!= NULL
) {} // expected-warning {{comparison of address of 'pointer' not equal to a null pointer is always true}}
54 if (array
) { } // expected-warning {{address of array 'array' will always evaluate to 'true'}}
55 if (array
!= 0) {} // expected-warning {{comparison of array 'array' not equal to a null pointer is always true}}
56 if (!array
) { } // expected-warning {{address of array 'array' will always evaluate to 'true'}}
57 if (array
== 0) {} // expected-warning {{comparison of array 'array' equal to a null pointer is always false}}
60 array
) {} // expected-warning {{address of array 'array' will always evaluate to 'true'}}
63 array
) {} // expected-warning {{address of array 'array' will always evaluate to 'true'}}
66 !array
) {} // expected-warning {{address of array 'array' will always evaluate to 'true'}}
68 !array
) {} // expected-warning {{address of array 'array' will always evaluate to 'true'}}
70 if (array
&& // expected-warning {{address of array 'array' will always evaluate to 'true'}}
72 if (!array
|| // expected-warning {{address of array 'array' will always evaluate to 'true'}}
75 if (array
|| // expected-warning {{address of array 'array' will always evaluate to 'true'}}
76 (!array
&& array
[0])) {} // expected-warning {{address of array 'array' will always evaluate to 'true'}}
79 #define SAVE_READ(PTR) if( (PTR) && (&result) ) *result=*PTR;
80 void _HTTPClientErrorHandler(int me
)
86 void test_conditional_operator(void) {
88 x
= b
? 1 : 0; // expected-warning {{address of array}}
89 x
= c
.x
? 1 : 0; // expected-warning {{address of array}}
90 x
= str
? 1 : 0; // expected-warning {{address of array}}
91 x
= array
? 1 : 0; // expected-warning {{address of array}}
92 x
= &x
? 1 : 0; // expected-warning {{address of 'x'}}
97 int b
= (&a
) == ((void *) 0); // expected-warning {{comparison of address of 'a' equal to a null pointer is always false}}