summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2008-12-16 17:51:01 +0000
committerFariborz Jahanian <fjahanian@apple.com>2008-12-16 17:51:01 +0000
commit3a1bb221781975b85ac11b484212b7eb8f30a1b4 (patch)
tree2d5b881ee8c55a2a284214e90608f5de4feb81a1
parent61d879e424101f73406bb5cc5debcea2016a4e59 (diff)
downloadbcm5719-llvm-3a1bb221781975b85ac11b484212b7eb8f30a1b4.tar.gz
bcm5719-llvm-3a1bb221781975b85ac11b484212b7eb8f30a1b4.zip
Patch to check for ObjC's property type.
llvm-svn: 61090
-rw-r--r--clang/include/clang/Basic/DiagnosticKinds.def2
-rw-r--r--clang/lib/Sema/SemaDeclObjC.cpp4
-rw-r--r--clang/test/SemaObjC/property-typecheck-2.m12
3 files changed, 18 insertions, 0 deletions
diff --git a/clang/include/clang/Basic/DiagnosticKinds.def b/clang/include/clang/Basic/DiagnosticKinds.def
index 8b0bd277672..c900a230733 100644
--- a/clang/include/clang/Basic/DiagnosticKinds.def
+++ b/clang/include/clang/Basic/DiagnosticKinds.def
@@ -456,6 +456,8 @@ DIAG(warn_objc_property_default_assign_on_object, WARNING,
"default property attribute 'assign' not appropriate for non-gc object")
DIAG(err_objc_property_requires_object, ERROR,
"property with '%0' attribute must be of object type")
+DIAG(err_property_type, ERROR,
+ "property cannot have type %0 (array or function type)")
DIAG(err_objc_directive_only_in_protocol, ERROR,
"directive may only be specified in protocols only")
DIAG(err_missing_catch_finally, ERROR,
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp
index 417803e5c16..7b6059415a0 100644
--- a/clang/lib/Sema/SemaDeclObjC.cpp
+++ b/clang/lib/Sema/SemaDeclObjC.cpp
@@ -1437,6 +1437,10 @@ Sema::DeclTy *Sema::ActOnProperty(Scope *S, SourceLocation AtLoc,
}
}
+ Type *t = T.getTypePtr();
+ if (t->isArrayType() || t->isFunctionType())
+ Diag(AtLoc, diag::err_property_type) << T;
+
ObjCPropertyDecl *PDecl = ObjCPropertyDecl::Create(Context, AtLoc,
FD.D.getIdentifier(), T);
// Regardless of setter/getter attribute, we save the default getter/setter
diff --git a/clang/test/SemaObjC/property-typecheck-2.m b/clang/test/SemaObjC/property-typecheck-2.m
new file mode 100644
index 00000000000..b8da661126e
--- /dev/null
+++ b/clang/test/SemaObjC/property-typecheck-2.m
@@ -0,0 +1,12 @@
+// RUN: clang -fsyntax-only -verify %s
+
+typedef int T[2];
+typedef void (F)(void);
+
+@interface A
+@property(assign) T p2; // expected-error {{property cannot have type 'T' (array or function type)}}
+
+@property(assign) F f2; // expected-error {{property cannot have type 'F' (array or function type)}}
+
+@end
+
OpenPOWER on IntegriCloud