From 9d1bbeab2475fe45a3d4cb8de6810bc3275f1dd7 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Mon, 10 Oct 2011 21:53:24 +0000 Subject: [PATCH] objc: err on a property designated both atomic and nonatomic. // rdar://10260017 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141580 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaObjCProperty.cpp | 7 +++++++ test/SemaObjC/conflict-atomic-property.m | 10 ++++++++++ 2 files changed, 17 insertions(+) create mode 100644 test/SemaObjC/conflict-atomic-property.m diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index 727c7b8b64..df95396ee4 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -1744,6 +1744,13 @@ void Sema::CheckObjCPropertyAttributes(Decl *PDecl, Attributes &= ~ObjCDeclSpec::DQ_PR_weak; } + if ((Attributes & ObjCDeclSpec::DQ_PR_atomic) && + (Attributes & ObjCDeclSpec::DQ_PR_nonatomic)) { + Diag(Loc, diag::err_objc_property_attr_mutually_exclusive) + << "atomic" << "nonatomic"; + Attributes &= ~ObjCDeclSpec::DQ_PR_atomic; + } + // Warn if user supplied no assignment attribute, property is // readwrite, and this is an object type. if (!(Attributes & (ObjCDeclSpec::DQ_PR_assign | ObjCDeclSpec::DQ_PR_copy | diff --git a/test/SemaObjC/conflict-atomic-property.m b/test/SemaObjC/conflict-atomic-property.m new file mode 100644 index 0000000000..033980c38c --- /dev/null +++ b/test/SemaObjC/conflict-atomic-property.m @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// rdar://10260017 + +@interface Foo +@property (nonatomic, assign, atomic) float dummy; // expected-error {{property attributes 'atomic' and 'nonatomic' are mutually exclusive}} +@property (nonatomic, assign) float d1; +@property (atomic, assign) float d2; +@property (assign) float d3; +@property (atomic, nonatomic, assign) float d4; // expected-error {{property attributes 'atomic' and 'nonatomic' are mutually exclusive}} +@end -- 2.40.0