]> granicus.if.org Git - clang/commitdiff
objc: err on a property designated both atomic and
authorFariborz Jahanian <fjahanian@apple.com>
Mon, 10 Oct 2011 21:53:24 +0000 (21:53 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Mon, 10 Oct 2011 21:53:24 +0000 (21:53 +0000)
nonatomic. // rdar://10260017

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

lib/Sema/SemaObjCProperty.cpp
test/SemaObjC/conflict-atomic-property.m [new file with mode: 0644]

index 727c7b8b64c8c8da4c1e64b1417eab35deadb46e..df95396ee49517698808785a78c1ee8eccd9255f 100644 (file)
@@ -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 (file)
index 0000000..033980c
--- /dev/null
@@ -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