blob: 28ec631415ddf6e2d99e353781857399beb95dba [file] [log] [blame]
Richard Smithe934d7c2013-11-21 01:53:02 +00001// RUN: %clang_cc1 %s -verify
2
Argyrios Kyrtzidis278c8d32014-01-31 07:51:32 +00003#define NLL (unsigned long long)0
4
Richard Smithe934d7c2013-11-21 01:53:02 +00005// PR10837: Warn if a non-pointer-typed expression is folded to a null pointer
6int *p = 0;
7int *q = '\0'; // expected-warning{{expression which evaluates to zero treated as a null pointer constant}}
8int *r = (1 - 1); // expected-warning{{expression which evaluates to zero treated as a null pointer constant}}
9void f() {
10 p = 0;
11 q = '\0'; // expected-warning{{expression which evaluates to zero treated as a null pointer constant}}
12 r = 1 - 1; // expected-warning{{expression which evaluates to zero treated as a null pointer constant}}
Argyrios Kyrtzidis278c8d32014-01-31 07:51:32 +000013 p = NLL;
Richard Smithe934d7c2013-11-21 01:53:02 +000014}