aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2011-10-07 21:08:14 +0000
committerFariborz Jahanian <fjahanian@apple.com>2011-10-07 21:08:14 +0000
commit13bf6336ab395eb6af487ab96d32229460907769 (patch)
tree3257859051bcc03396f4e9edbd40812d1c21be80
parent63d3201619fdac284adfd3b9328562fa20a01c40 (diff)
objc++: some minor cleanup and a test case
for atomic setters which requires assignment operator. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141415 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/DiagnosticSemaKinds.td2
-rw-r--r--lib/Sema/SemaObjCProperty.cpp7
-rw-r--r--test/SemaObjCXX/property-reference.mm2
-rw-r--r--test/SemaObjCXX/property-synthesis-error.mm15
4 files changed, 18 insertions, 8 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index 28e0fab4e3..368bdc3b10 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -505,7 +505,7 @@ def note_atomic_property_fixup_suggest : Note<"setter and getter must both be "
"synthesized, or both be user defined,or the property must be nonatomic">;
def warn_atomic_property_nontrivial_assign_op : Warning<
"atomic property of type %0 synthesizing setter using non-trivial assignment"
- "operator">, InGroup<DiagGroup<"objc-property-atomic-setter-synthesis">>;
+ " operator">, InGroup<DiagGroup<"objc-property-atomic-setter-synthesis">>;
def warn_ownin_getter_rule : Warning<
"property's synthesized getter follows Cocoa naming"
" convention for returning 'owned' objects">,
diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp
index 13ccf82cf4..7eb552c84a 100644
--- a/lib/Sema/SemaObjCProperty.cpp
+++ b/lib/Sema/SemaObjCProperty.cpp
@@ -805,15 +805,12 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S,
ObjCPropertyDecl::OBJC_PR_atomic) {
Expr *callExpr = Res.takeAs<Expr>();
if (const CXXOperatorCallExpr *CXXCE =
- dyn_cast_or_null<CXXOperatorCallExpr>(callExpr)) {
- const CallExpr *CE = cast<CallExpr>(CXXCE);
- if (const FunctionDecl *FuncDecl = CE->getDirectCallee()) {
+ dyn_cast_or_null<CXXOperatorCallExpr>(callExpr))
+ if (const FunctionDecl *FuncDecl = CXXCE->getDirectCallee())
if (!FuncDecl->isTrivial())
Diag(PropertyLoc,
diag::warn_atomic_property_nontrivial_assign_op)
<< property->getType();
- }
- }
}
PIDecl->setSetterCXXAssignment(Res.takeAs<Expr>());
}
diff --git a/test/SemaObjCXX/property-reference.mm b/test/SemaObjCXX/property-reference.mm
index 98bc727300..236dba61fc 100644
--- a/test/SemaObjCXX/property-reference.mm
+++ b/test/SemaObjCXX/property-reference.mm
@@ -29,7 +29,7 @@ typedef const TCPPObject& CREF_TCPPObject;
@implementation TNSObject
@synthesize cppObjectNonAtomic;
-@synthesize cppObjectAtomic; // expected-warning{{atomic property of type 'CREF_TCPPObject' (aka 'const TCPPObject &') synthesizing setter using non-trivial assignmentoperator}}
+@synthesize cppObjectAtomic; // expected-warning{{atomic property of type 'CREF_TCPPObject' (aka 'const TCPPObject &') synthesizing setter using non-trivial assignment operator}}
@dynamic cppObjectDynamic;
- (const TCPPObject&) cppObjectNonAtomic
diff --git a/test/SemaObjCXX/property-synthesis-error.mm b/test/SemaObjCXX/property-synthesis-error.mm
index f79a56db6c..5ba4b70a2b 100644
--- a/test/SemaObjCXX/property-synthesis-error.mm
+++ b/test/SemaObjCXX/property-synthesis-error.mm
@@ -43,19 +43,32 @@ private:
void* fData;
};
+class Trivial
+{
+public:
+ Trivial(const Trivial& inObj);
+ Trivial();
+ ~Trivial();
+private:
+ void* fData;
+};
+
@interface MyDocument
{
@private
TCPPObject _cppObject;
TCPPObject _ncppObject;
+ Trivial _tcppObject;
}
@property (assign, readwrite) const TCPPObject& cppObject;
@property (assign, readwrite, nonatomic) const TCPPObject& ncppObject;
+@property (assign, readwrite) const Trivial& tcppObject;
@end
@implementation MyDocument
-@synthesize cppObject = _cppObject; // expected-warning {{atomic property of type 'const TCPPObject &' synthesizing setter using non-trivial assignmentoperator}}
+@synthesize cppObject = _cppObject; // expected-warning {{atomic property of type 'const TCPPObject &' synthesizing setter using non-trivial assignment operator}}
@synthesize ncppObject = _ncppObject;
+@synthesize tcppObject = _tcppObject;
@end