diff options
Diffstat (limited to 'clang/test/Sema/attr-malloc.c')
-rw-r--r-- | clang/test/Sema/attr-malloc.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/test/Sema/attr-malloc.c b/clang/test/Sema/attr-malloc.c new file mode 100644 index 00000000000..8603cc05a54 --- /dev/null +++ b/clang/test/Sema/attr-malloc.c @@ -0,0 +1,16 @@ +// RUN: clang-cc -verify -fsyntax-only %s && +// RUN: clang-cc -emit-llvm -o %t %s && + +#include <stdlib.h> + +int no_vars __attribute((malloc)); // expected-warning {{only applies to function types}} + +__attribute((malloc)) +void * xalloc(unsigned n) { return malloc(n); } +// RUN: grep 'define noalias .* @xalloc(' %t && + +#define __malloc_like __attribute((__malloc__)) +void * xalloc2(unsigned) __malloc_like; +void * xalloc2(unsigned n) { return malloc(n); } +// RUN: grep 'define noalias .* @xalloc2(' %t + |