From: Fariborz Jahanian Date: Sat, 11 Jun 2011 00:45:12 +0000 (+0000) Subject: Restore 'atomic' as an attribute of objc X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=45937ae10a0f70f74508165aab4f2b63e18ea747;p=clang Restore 'atomic' as an attribute of objc properties. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132866 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index 6b2113a695..0a4d864cd8 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -1380,7 +1380,8 @@ public: OBJC_PR_retain = 0x10, OBJC_PR_copy = 0x20, OBJC_PR_nonatomic = 0x40, - OBJC_PR_setter = 0x80 + OBJC_PR_setter = 0x80, + OBJC_PR_atomic = 0x100 }; enum SetterKind { Assign, Retain, Copy }; diff --git a/include/clang/Sema/DeclSpec.h b/include/clang/Sema/DeclSpec.h index 456612bc22..be1f5f8c79 100644 --- a/include/clang/Sema/DeclSpec.h +++ b/include/clang/Sema/DeclSpec.h @@ -688,7 +688,8 @@ public: DQ_PR_retain = 0x10, DQ_PR_copy = 0x20, DQ_PR_nonatomic = 0x40, - DQ_PR_setter = 0x80 + DQ_PR_setter = 0x80, + DQ_PR_atomic = 0x100 }; diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp index 8c8fd746a6..fdbedc54d1 100644 --- a/lib/Parse/ParseObjc.cpp +++ b/lib/Parse/ParseObjc.cpp @@ -512,6 +512,8 @@ void Parser::ParseObjCPropertyAttribute(ObjCDeclSpec &DS, Decl *ClassDecl) { DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_copy); else if (II->isStr("nonatomic")) DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_nonatomic); + else if (II->isStr("atomic")) + DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_atomic); else if (II->isStr("getter") || II->isStr("setter")) { bool IsSetter = II->getNameStart()[0] == 's'; diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index 109826942e..6c4469cef9 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -295,6 +295,8 @@ ObjCPropertyDecl *Sema::CreatePropertyDecl(Scope *S, if (Attributes & ObjCDeclSpec::DQ_PR_nonatomic) PDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_nonatomic); + else if (Attributes & ObjCDeclSpec::DQ_PR_atomic) + PDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_atomic); PDecl->setPropertyAttributesAsWritten(PDecl->getPropertyAttributes()); @@ -346,7 +348,8 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, return 0; } unsigned PIkind = property->getPropertyAttributesAsWritten(); - if ((PIkind & ObjCPropertyDecl::OBJC_PR_nonatomic) == 0) { + if ((PIkind & (ObjCPropertyDecl::OBJC_PR_atomic | + ObjCPropertyDecl::OBJC_PR_nonatomic) ) == 0) { if (AtLoc.isValid()) Diag(AtLoc, diag::warn_implicit_atomic_property); else @@ -1088,7 +1091,8 @@ Sema::AtomicPropertySetterGetterRules (ObjCImplDecl* IMPDecl, unsigned Attributes = Property->getPropertyAttributes(); unsigned AttributesAsWrittern = Property->getPropertyAttributesAsWritten(); - if (!(AttributesAsWrittern & ObjCPropertyDecl::OBJC_PR_nonatomic)) { + if (!(AttributesAsWrittern & ObjCPropertyDecl::OBJC_PR_atomic) && + !(AttributesAsWrittern & ObjCPropertyDecl::OBJC_PR_nonatomic)) { GetterMethod = IMPDecl->getInstanceMethod(Property->getGetterName()); SetterMethod = IMPDecl->getInstanceMethod(Property->getSetterName()); LookedUpGetterSetter = true; diff --git a/test/SemaObjC/warn-implicit-atomic-property.m b/test/SemaObjC/warn-implicit-atomic-property.m index bf60dbb630..0b4590a42d 100644 --- a/test/SemaObjC/warn-implicit-atomic-property.m +++ b/test/SemaObjC/warn-implicit-atomic-property.m @@ -3,11 +3,11 @@ @interface Super @property (nonatomic, readwrite) int P; // OK -@property (readwrite) int P1; // expected-note {{property declared here}} +@property (atomic, readwrite) int P1; // OK @property (readwrite) int P2; // expected-note {{property declared here}} @property int P3; // expected-note {{property declared here}} @end @implementation Super // expected-warning {{property is assumed atomic when auto-synthesizing the property [-Wimplicit-atomic-properties]}} -@synthesize P,P1,P2; // expected-warning 2 {{property is assumed atomic by default [-Wimplicit-atomic-properties]}} +@synthesize P,P1,P2; // expected-warning {{property is assumed atomic by default [-Wimplicit-atomic-properties]}} @end