1 // RUN: %clang_cc1 -fsyntax-only -verify %s 2 // RUN: %clang_cc1 -fsyntax-only -verify -Wundefined-bool-conversion %s 3 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-bool-conversion -Wundefined-bool-conversion %s 4 // RUN: %clang_cc1 -fsyntax-only -verify -Wbool-conversion %s 5 6 void test1(int &x) { 7 if (x == 1) { } 8 if (&x) { } 9 // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true}} 10 11 if (!&x) { } 12 // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true}} 13 } 14 15 class test2 { 16 test2() : x(y) {} 17 18 void foo() { 19 if (this) { } 20 // expected-warning@-1{{'this' pointer cannot be null in well-defined C++ code; pointer may be assumed to always convert to true}} 21 22 if (!this) { } 23 // expected-warning@-1{{'this' pointer cannot be null in well-defined C++ code; pointer may be assumed to always convert to true}} 24 } 25 26 void bar() { 27 if (x == 1) { } 28 if (&x) { } 29 // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true}} 30 31 if (!&x) { } 32 // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true}} 33 } 34 35 int &x; 36 int y; 37 }; 38