2011-03-01 03:49:42 +08:00
|
|
|
// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-inline-call -analyzer-store region -verify %s
|
2011-02-19 09:08:37 +08:00
|
|
|
// XFAIL: *
|
2010-11-01 17:09:44 +08:00
|
|
|
|
2010-04-20 13:48:57 +08:00
|
|
|
struct A {
|
|
|
|
int x;
|
|
|
|
A(int a) { x = a; }
|
2010-11-24 21:48:50 +08:00
|
|
|
int getx() const { return x; }
|
2010-04-20 13:48:57 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
void f1() {
|
|
|
|
A x(3);
|
|
|
|
if (x.getx() == 3) {
|
|
|
|
int *p = 0;
|
|
|
|
*p = 3; // expected-warning{{Dereference of null pointer}}
|
|
|
|
} else {
|
|
|
|
int *p = 0;
|
|
|
|
*p = 3; // no-warning
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-25 11:18:57 +08:00
|
|
|
void f2() {
|
|
|
|
const A &x = A(3);
|
|
|
|
if (x.getx() == 3) {
|
|
|
|
int *p = 0;
|
|
|
|
*p = 3; // expected-warning{{Dereference of null pointer}}
|
|
|
|
} else {
|
|
|
|
int *p = 0;
|
|
|
|
*p = 3; // no-warning
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-19 09:08:37 +08:00
|
|
|
void f3() {
|
|
|
|
const A &x = (A)3;
|
|
|
|
if (x.getx() == 3) {
|
|
|
|
int *p = 0;
|
|
|
|
*p = 3; // expected-warning{{Dereference of null pointer}}
|
|
|
|
} else {
|
|
|
|
int *p = 0;
|
|
|
|
*p = 3; // no-warning
|
|
|
|
}
|
|
|
|
}
|