blob: 3bf2aedc445fa51c35cfbd8a9a3ec754ccf78a94 [file] [log] [blame]
Richard Smithe934d7c2013-11-21 01:53:02 +00001// RUN: %clang_cc1 %s -verify
2
Argyrios Kyrtzidis77ed8972014-02-11 17:53:22 +00003#define SOME_ADDR (unsigned long long)0
Argyrios Kyrtzidis278c8d32014-01-31 07:51:32 +00004
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 Kyrtzidis77ed8972014-02-11 17:53:22 +000013 p = SOME_ADDR; // expected-warning{{expression which evaluates to zero treated as a null pointer constant}}
Richard Smithe934d7c2013-11-21 01:53:02 +000014}