xref: /aosp_15_r20/external/clang/test/SemaCXX/warn-address.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify -Wno-bool-conversion -Wno-string-compare -Wno-tautological-compare -Waddress %s
2*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify %s
3*67e74705SXin Li 
4*67e74705SXin Li void foo();
5*67e74705SXin Li int arr[5];
6*67e74705SXin Li int global;
7*67e74705SXin Li const char* str = "";
8*67e74705SXin Li 
test()9*67e74705SXin Li void test() {
10*67e74705SXin Li   if (foo) {}            // expected-warning{{always evaluate to 'true'}} \
11*67e74705SXin Li                          // expected-note{{silence}}
12*67e74705SXin Li   if (arr) {}            // expected-warning{{always evaluate to 'true'}}
13*67e74705SXin Li   if (&global) {}        // expected-warning{{always evaluate to 'true'}}
14*67e74705SXin Li   if (foo == 0) {}       // expected-warning{{always false}} \
15*67e74705SXin Li                          // expected-note{{silence}}
16*67e74705SXin Li   if (arr == 0) {}       // expected-warning{{always false}}
17*67e74705SXin Li   if (&global == 0) {}   // expected-warning{{always false}}
18*67e74705SXin Li 
19*67e74705SXin Li   if (str == "foo") {}   // expected-warning{{unspecified}}
20*67e74705SXin Li }
21