diff options
-rw-r--r-- | clang/include/clang/Basic/DiagnosticKinds.def | 2 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 4 | ||||
-rw-r--r-- | clang/test/SemaObjC/property-typecheck-2.m | 12 |
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 + |