xref: /minix3/external/bsd/llvm/dist/clang/test/Sema/warn-null.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 %s -verify
2*0a6a1f1dSLionel Sambuc 
3*0a6a1f1dSLionel Sambuc #define SOME_ADDR (unsigned long long)0
4*0a6a1f1dSLionel Sambuc 
5*0a6a1f1dSLionel Sambuc // PR10837: Warn if a non-pointer-typed expression is folded to a null pointer
6*0a6a1f1dSLionel Sambuc int *p = 0;
7*0a6a1f1dSLionel Sambuc int *q = '\0'; // expected-warning{{expression which evaluates to zero treated as a null pointer constant}}
8*0a6a1f1dSLionel Sambuc int *r = (1 - 1); // expected-warning{{expression which evaluates to zero treated as a null pointer constant}}
f()9*0a6a1f1dSLionel Sambuc void f() {
10*0a6a1f1dSLionel Sambuc   p = 0;
11*0a6a1f1dSLionel Sambuc   q = '\0'; // expected-warning{{expression which evaluates to zero treated as a null pointer constant}}
12*0a6a1f1dSLionel Sambuc   r = 1 - 1; // expected-warning{{expression which evaluates to zero treated as a null pointer constant}}
13*0a6a1f1dSLionel Sambuc   p = SOME_ADDR; // expected-warning{{expression which evaluates to zero treated as a null pointer constant}}
14*0a6a1f1dSLionel Sambuc }
15