| 1 |
#include "analyzer-decls.h" |
| 2 |
|
| 3 |
int a[1024]; |
| 4 |
int b[1024]; |
| 5 |
|
| 6 |
extern void escape (void *ptr); |
| 7 |
|
| 8 |
void test_1 (int *p) |
| 9 |
{ |
| 10 |
int c, d; |
| 11 |
escape (&c); |
| 12 |
a[16] = 42; |
| 13 |
b[16] = 17; |
| 14 |
c = 33; |
| 15 |
d = 44; |
| 16 |
__analyzer_eval (a[16] == 42); /* { dg-warning "TRUE" } */ |
| 17 |
__analyzer_eval (b[16] == 17); /* { dg-warning "TRUE" } */ |
| 18 |
__analyzer_eval (c == 33); /* { dg-warning "TRUE" } */ |
| 19 |
__analyzer_eval (d == 44); /* { dg-warning "TRUE" } */ |
| 20 |
|
| 21 |
/* Write through an externally-provided pointer. */ |
| 22 |
*p = 100; |
| 23 |
/* It could clobber our writes to the global arrays... */ |
| 24 |
__analyzer_eval (a[16] == 42); /* { dg-warning "UNKNOWN" } */ |
| 25 |
__analyzer_eval (b[16] == 17); /* { dg-warning "UNKNOWN" } */ |
| 26 |
/* ...but can't clobber locals, even ones like "c" that have escaped. */ |
| 27 |
__analyzer_eval (c == 33); /* { dg-warning "TRUE" } */ |
| 28 |
__analyzer_eval (d == 44); /* { dg-warning "TRUE" } */ |
| 29 |
} |