| 1 |
// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s |
| 2 |
|
| 3 |
typedef unsigned uintptr_t; |
| 4 |
|
| 5 |
void f1(void) { |
| 6 |
int *p; |
| 7 |
*p = 0; // expected-warning{{Dereference of undefined pointer value}} |
| 8 |
} |
| 9 |
|
| 10 |
struct foo_struct { |
| 11 |
int x; |
| 12 |
}; |
| 13 |
|
| 14 |
int f2(void) { |
| 15 |
struct foo_struct *p; |
| 16 |
|
| 17 |
return p->x++; // expected-warning{{Access to field 'x' results in a dereference of an undefined pointer value (loaded from variable 'p')}} |
| 18 |
} |
| 19 |
|
| 20 |
int f3(void) { |
| 21 |
char *x; |
| 22 |
int i = 2; |
| 23 |
|
| 24 |
return x[i + 1]; // expected-warning{{Array access (from variable 'x') results in an undefined pointer dereference}} |
| 25 |
} |
| 26 |
|
| 27 |
int f3_b(void) { |
| 28 |
char *x; |
| 29 |
int i = 2; |
| 30 |
|
| 31 |
return x[i + 1]++; // expected-warning{{Array access (from variable 'x') results in an undefined pointer dereference}} |
| 32 |
} |