diff options
author | Manman Ren <manman.ren@gmail.com> | 2016-01-29 19:16:39 +0000 |
---|---|---|
committer | Manman Ren <manman.ren@gmail.com> | 2016-01-29 19:16:39 +0000 |
commit | dfef4069e3a02b8e1461434971ff0060afa89a4e (patch) | |
tree | b78b0cd17ef6d100ae9f2e22ef2049a2aca7e212 | |
parent | 0fe61f868865c4c643cc5576e5ee63f94f382d8a (diff) | |
download | bcm5719-llvm-dfef4069e3a02b8e1461434971ff0060afa89a4e.tar.gz bcm5719-llvm-dfef4069e3a02b8e1461434971ff0060afa89a4e.zip |
Class Property: warn for synthesize on a class property.
rdar://23891898
llvm-svn: 259226
-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 |