summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/attr-malloc.c
diff options
context:
space:
mode:
authorRyan Flynn <pizza@parseerror.com>2009-08-09 20:07:29 +0000
committerRyan Flynn <pizza@parseerror.com>2009-08-09 20:07:29 +0000
commit1f1fdc070efa8d32d97a51dbffdae466ad83e480 (patch)
treee20efac5175097e57038f617b65cdadefe494953 /clang/test/Sema/attr-malloc.c
parentd461c1c559e3cd0aef3ad18246a866ab2a8e52d8 (diff)
downloadbcm5719-llvm-1f1fdc070efa8d32d97a51dbffdae466ad83e480.tar.gz
bcm5719-llvm-1f1fdc070efa8d32d97a51dbffdae466ad83e480.zip
map previously ignored __attribute((malloc)) to noalias attribute of llvm function's return
llvm-svn: 78541
Diffstat (limited to 'clang/test/Sema/attr-malloc.c')
-rw-r--r--clang/test/Sema/attr-malloc.c16
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
+
OpenPOWER on IntegriCloud