rdar-6541136-region.c revision 58e689fead1490611bcd114fb707bfc08a12049e
1// RUN: clang-cc -verify -analyze -checker-cfref -analyzer-store=region %s 2 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]; 16 //*p = 1; // this is also an out-of-bound access. 17 kernel_tea_cheese_t *q = &wonky[1]; 18 // 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; // expected-warning{{Access out-of-bound array element (buffer overflow)}} 22} 23