]> granicus.if.org Git - clang/commitdiff
Class Property: warn for synthesize on a class property.
authorManman Ren <manman.ren@gmail.com>
Fri, 29 Jan 2016 19:16:39 +0000 (19:16 +0000)
committerManman Ren <manman.ren@gmail.com>
Fri, 29 Jan 2016 19:16:39 +0000 (19:16 +0000)
rdar://23891898

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@259226 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaObjCProperty.cpp
test/SemaObjC/objc-class-property.m

index f501c8a97ae4058f2a63b6ca2ee3437f7e747cad..1d2145498aef9c4cfe1e21c21584a42a3d079bb4 100644 (file)
@@ -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<
index ec057c94377cf52b321cae39a526436614cf6592..c9d2da880e1157376bd1a1546ca7f35f5e1b75cd 100644 (file)
@@ -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) {
index 449f106964b1c4422f142d674224a826cc59f374..777544009058fb737fd851599a975de57df14ef0 100644 (file)
@@ -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