From 13cc256e404620c1de0cbcc4e43ce1e2dbbc4898 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sun, 2 Dec 2012 13:20:44 +0000 Subject: Vendor import of clang release_32 branch r168974 (effectively, 3.2 RC2): http://llvm.org/svn/llvm-project/cfe/branches/release_32@168974 --- test/Analysis/malloc-sizeof.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test/Analysis/malloc-sizeof.c') 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; +} -- cgit v1.2.3