blob: e2779e8d914f9b235f1c90c95a27b8c90715bb3c [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc -verify -analyze -checker-cfref -analyzer-store=region %s
Ted Kremenek14553ab2009-01-30 00:08:43 +00002
3struct tea_cheese { unsigned magic; };
4typedef struct tea_cheese kernel_tea_cheese_t;
5extern kernel_tea_cheese_t _wonky_gesticulate_cheese;
6
7// This test case exercises the ElementRegion::getRValueType() logic.
8
9
10void foo( void )
11{
12 kernel_tea_cheese_t *wonky = &_wonky_gesticulate_cheese;
13 struct load_wine *cmd = (void*) &wonky[1];
14 cmd = cmd;
15 char *p = (void*) &wonky[1];
Ted Kremenek39abcdf2009-08-01 05:59:39 +000016 *p = 1; // no-warning
Zhongxing Xuccb16162009-05-06 08:08:27 +000017 kernel_tea_cheese_t *q = &wonky[1];
Ted Kremenek39abcdf2009-08-01 05:59:39 +000018 // This test case tests both the RegionStore logic (doesn't crash) and
19 // the out-of-bounds checking. We don't expect the warning for now since
20 // out-of-bound checking is temporarily disabled.
21 kernel_tea_cheese_t r = *q; // eventually-warning{{out-of-bound memory position}}
Ted Kremenek14553ab2009-01-30 00:08:43 +000022}