]> granicus.if.org Git - clang/commitdiff
objc++: some minor cleanup and a test case
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 7 Oct 2011 21:08:14 +0000 (21:08 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 7 Oct 2011 21:08:14 +0000 (21:08 +0000)
for atomic setters which requires assignment operator.

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

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaObjCProperty.cpp
test/SemaObjCXX/property-reference.mm
test/SemaObjCXX/property-synthesis-error.mm

index 28e0fab4e3b8a9a706c626938170b6e52d910af3..368bdc3b108be655b761901f0a94471ab838d1d4 100644 (file)
@@ -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">,
index 13ccf82cf4f1b2f2120face7089d0a25a6005d4e..7eb552c84a7b62ba5f772643daa4854a13abcea1 100644 (file)
@@ -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>());
     }
index 98bc7273001f432f374ca9b5edc972a6eeee627f..236dba61fc2d8d22c7000642fc9cea22f5ea5932 100644 (file)
@@ -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
index f79a56db6cd0ed913cd72a826db94450367b84d9..5ba4b70a2b6908909c74df8b3901cc1be55cd940 100644 (file)
@@ -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