From: Fariborz Jahanian Date: Fri, 7 Oct 2011 21:08:14 +0000 (+0000) Subject: objc++: some minor cleanup and a test case X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=13bf6336ab395eb6af487ab96d32229460907769;p=clang 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 --- 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>; + " operator">, InGroup>; 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(); if (const CXXOperatorCallExpr *CXXCE = - dyn_cast_or_null(callExpr)) { - const CallExpr *CE = cast(CXXCE); - if (const FunctionDecl *FuncDecl = CE->getDirectCallee()) { + dyn_cast_or_null(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()); } 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