diff options
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/Analysis/no-outofbounds.c | 11 | ||||
-rw-r--r-- | clang/test/Analysis/outofbound.c | 5 | ||||
-rw-r--r-- | clang/test/Analysis/rdar-6442306-1.m | 2 |
3 files changed, 17 insertions, 1 deletions
diff --git a/clang/test/Analysis/no-outofbounds.c b/clang/test/Analysis/no-outofbounds.c index 49ee80e8c23..a97b68e2d6d 100644 --- a/clang/test/Analysis/no-outofbounds.c +++ b/clang/test/Analysis/no-outofbounds.c @@ -18,3 +18,14 @@ void g() { char *b = (char*)a; b[3] = 'c'; // no-warning } + +typedef typeof(sizeof(int)) size_t; +void *malloc(size_t); +void free(void *); + +void field() { + struct vec { size_t len; int data[0]; }; + struct vec *a = malloc(sizeof(struct vec) + 10); + a->len = 10; + a->data[1] = 5; // no-warning +} diff --git a/clang/test/Analysis/outofbound.c b/clang/test/Analysis/outofbound.c index 24766be9183..305d5e56cbb 100644 --- a/clang/test/Analysis/outofbound.c +++ b/clang/test/Analysis/outofbound.c @@ -49,3 +49,8 @@ void f6() { int *b = (int*)a; b[1] = 3; // expected-warning{{out-of-bound}} } + +void f7() { + struct three_words a; + a.c[3] = 1; // expected-warning{{out-of-bound}} +} diff --git a/clang/test/Analysis/rdar-6442306-1.m b/clang/test/Analysis/rdar-6442306-1.m index a2af94637d0..dfe9b722d13 100644 --- a/clang/test/Analysis/rdar-6442306-1.m +++ b/clang/test/Analysis/rdar-6442306-1.m @@ -10,7 +10,7 @@ struct QuxSize {}; typedef struct QuxSize QuxSize; typedef struct { Foo_record_t Foo; - QuxSize size; + QuxSize size[0]; } __Request__SetPortalSize_t; double __Foo_READSWAP__double(double*); |