summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/warn-null.c
blob: 3bf2aedc445fa51c35cfbd8a9a3ec754ccf78a94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// RUN: %clang_cc1 %s -verify

#define SOME_ADDR (unsigned long long)0

// PR10837: Warn if a non-pointer-typed expression is folded to a null pointer
int *p = 0;
int *q = '\0'; // expected-warning{{expression which evaluates to zero treated as a null pointer constant}}
int *r = (1 - 1); // expected-warning{{expression which evaluates to zero treated as a null pointer constant}}
void f() {
  p = 0;
  q = '\0'; // expected-warning{{expression which evaluates to zero treated as a null pointer constant}}
  r = 1 - 1; // expected-warning{{expression which evaluates to zero treated as a null pointer constant}}
  p = SOME_ADDR; // expected-warning{{expression which evaluates to zero treated as a null pointer constant}}
}
OpenPOWER on IntegriCloud