aboutsummaryrefslogtreecommitdiff
path: root/test/SemaObjC
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-08-14 20:49:40 +0000
committerTed Kremenek <kremenek@apple.com>2009-08-14 20:49:40 +0000
commita18d7d80eb914a48521f0b7b25057fb8a69c4652 (patch)
tree7cc329701a9967554437e03ba8b0fb90fd78401f /test/SemaObjC
parent343a3cf57ee950b024bade8b6b0a2b51663f43cd (diff)
Improve Sema's handling of attribute 'malloc' to reject the attribute when
attaching to Objective-C methods (which mirrors GCC's behavior) and to allow the return type of the function to be an Objective-C pointer or Block pointer (which GCC also accepts). Along the way, add 'const' to some of the pointer arguments of various utility functions... git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79040 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaObjC')
-rw-r--r--test/SemaObjC/attr-malloc.m14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/SemaObjC/attr-malloc.m b/test/SemaObjC/attr-malloc.m
new file mode 100644
index 0000000000..14cf5ff5e2
--- /dev/null
+++ b/test/SemaObjC/attr-malloc.m
@@ -0,0 +1,14 @@
+// RUN: clang-cc -verify -fsyntax-only -fblocks %s
+
+#include <stdlib.h>
+
+@interface TestAttrMallocOnMethods {}
+- (id) test1 __attribute((malloc)); // expected-warning{{'malloc' attribute only applies to function types}}
+- (int) test2 __attribute((malloc)); // expected-warning{{'malloc' attribute only applies to function types}}
+@end
+
+id bar(void) __attribute((malloc)); // no-warning
+
+typedef void (^bptr)(void);
+bptr baz(void) __attribute((malloc)); // no-warning
+