diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2012-12-02 13:20:44 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2012-12-02 13:20:44 +0000 |
commit | 13cc256e404620c1de0cbcc4e43ce1e2dbbc4898 (patch) | |
tree | 2732d02d7d51218d6eed98ac7fcfc5b8794896b5 /test/Analysis/malloc-sizeof.c | |
parent | 657bc3d9848e3be92029b2416031340988cd0111 (diff) |
Notes
Diffstat (limited to 'test/Analysis/malloc-sizeof.c')
-rw-r--r-- | test/Analysis/malloc-sizeof.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/Analysis/malloc-sizeof.c b/test/Analysis/malloc-sizeof.c index 6eb466ac6a11a..7a8585fa84422 100644 --- a/test/Analysis/malloc-sizeof.c +++ b/test/Analysis/malloc-sizeof.c @@ -34,3 +34,19 @@ void ignore_const() { const char ***y = (const char ***)malloc(1 * sizeof(char *)); // expected-warning {{Result of 'malloc' is converted to a pointer of type 'const char **', which is incompatible with sizeof operand type 'char *'}} free(x); } + +int *mallocArraySize() { + static const int sTable[10]; + static const int nestedTable[10][2]; + int *table = malloc(sizeof sTable); + int *table1 = malloc(sizeof nestedTable); + int (*table2)[2] = malloc(sizeof nestedTable); + int (*table3)[10][2] = malloc(sizeof nestedTable); + return table; +} + +int *mallocWrongArraySize() { + static const double sTable[10]; + int *table = malloc(sizeof sTable); // expected-warning {{Result of 'malloc' is converted to a pointer of type 'int', which is incompatible with sizeof operand type 'const double [10]'}} + return table; +} |