Add more tests testing derefs in BinOps and Casts.

This commit is contained in:
Baozeng Ding 2013-09-25 09:56:14 +02:00 committed by sftnight
parent e9376dd7a6
commit fc98551c43
2 changed files with 20 additions and 0 deletions

10
test/NullDeref/BinOp.C Normal file
View File

@ -0,0 +1,10 @@
// RUN: cat %s | %cling -Xclang -verify
//This file checks a pointer load operation for null prt dereference.
// XFAIL: i686-pc-linux-gnu
int *p = 0;
int x;
x = *p + 2; // expected-warning {{null passed to a callee which requires a non-null argument}}
x = 2 + *p; // expected-warning {{null passed to a callee which requires a non-null argument}}
x = *p > 2; // expected-warning {{null passed to a callee which requires a non-null argument}}
x = 2 > *p; // expected-warning {{null passed to a callee which requires a non-null argument}}

10
test/NullDeref/Cast.C Normal file
View File

@ -0,0 +1,10 @@
// RUN: cat %s | %cling -Xclang -verify
//This file checks a pointer load operation for null prt dereference.
// XFAIL: i686-pc-linux-gnu
int *p = 0;;
double x;
x = double(*p); // expected-warning {{null passed to a callee which requires a non-null argument}}
void *q = 0;
int y;
y = int(*(int *)q); // expected-warning {{null passed to a callee which requires a non-null argument}}