1 // RUN: %clang_cc1 -fsyntax-only -verify %s 2 3 int* j = false; // expected-warning{{initialization of pointer of type 'int *' to null from a constant boolean expression}} 4 5 void foo(int* i, int *j=(false)) // expected-warning{{initialization of pointer of type 'int *' to null from a constant boolean expression}} 6 { 7 foo(false); // expected-warning{{initialization of pointer of type 'int *' to null from a constant boolean expression}} 8 foo((int*)false); // no-warning: explicit cast 9 foo(0); // no-warning: not a bool, even though its convertible to bool 10 11 foo(false == true); // expected-warning{{initialization of pointer of type 'int *' to null from a constant boolean expression}} 12 foo((42 + 24) < 32); // expected-warning{{initialization of pointer of type 'int *' to null from a constant boolean expression}} 13 14 const bool kFlag = false; 15 foo(kFlag); // expected-warning{{initialization of pointer of type 'int *' to null from a constant boolean expression}} 16 } 17 18 char f(struct Undefined*); 19 double f(...); 20 21 // Ensure that when using false in metaprogramming machinery its conversion 22 // isn't flagged. 23 template <int N> struct S {}; 24 S<sizeof(f(false))> s; 25