diff options
-rw-r--r-- | clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 | ||||
-rw-r--r-- | clang/lib/Sema/SemaObjCProperty.cpp | 4 | ||||
-rw-r--r-- | clang/test/SemaObjC/objc-class-property.m | 3 |
3 files changed, 7 insertions, 2 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index f501c8a97ae..1d2145498ae 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -974,6 +974,8 @@ def note_property_synthesize : Note< "property synthesized here">; def error_synthesize_category_decl : Error< "@synthesize not allowed in a category's implementation">; +def error_synthesize_on_class_property : Error< + "@synthesize not allowed on a class property %0">; def error_reference_property : Error< "property of reference type is not supported">; def error_missing_property_interface : Error< diff --git a/clang/lib/Sema/SemaObjCProperty.cpp b/clang/lib/Sema/SemaObjCProperty.cpp index ec057c94377..c9d2da880e1 100644 --- a/clang/lib/Sema/SemaObjCProperty.cpp +++ b/clang/lib/Sema/SemaObjCProperty.cpp @@ -933,6 +933,10 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, Diag(PropertyLoc, diag::error_bad_property_decl) << IDecl->getDeclName(); return nullptr; } + if (property->isClassProperty() && Synthesize) { + Diag(PropertyLoc, diag::error_synthesize_on_class_property) << PropertyId; + return nullptr; + } unsigned PIkind = property->getPropertyAttributesAsWritten(); if ((PIkind & (ObjCPropertyDecl::OBJC_PR_atomic | ObjCPropertyDecl::OBJC_PR_nonatomic) ) == 0) { diff --git a/clang/test/SemaObjC/objc-class-property.m b/clang/test/SemaObjC/objc-class-property.m index 449f106964b..77754400905 100644 --- a/clang/test/SemaObjC/objc-class-property.m +++ b/clang/test/SemaObjC/objc-class-property.m @@ -1,5 +1,4 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics @interface Root -(id) alloc; @@ -22,7 +21,7 @@ @implementation A @dynamic x; // refers to the instance property @dynamic (class) x; // refers to the class property -@synthesize z; +@synthesize z, c2; // expected-error {{@synthesize not allowed on a class property 'c2'}} @dynamic c; // refers to the class property @end |