]> granicus.if.org Git - clang/commitdiff
ObjectiveC++: support for passing C++11 style initialized temporaries to
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 16 Oct 2013 17:51:43 +0000 (17:51 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 16 Oct 2013 17:51:43 +0000 (17:51 +0000)
objc++ properties using property-dot syntax.
// rdar://14654207

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

lib/Sema/SemaPseudoObject.cpp
test/SemaObjCXX/properties.mm

index 106250fe0f5286e9bfc649fd5a1bd3171818095d..af74f0d4a3e80a53009b6b9a5d7b83245a70c1ce 100644 (file)
@@ -730,6 +730,16 @@ ExprResult ObjCPropertyOpBuilder::buildSet(Expr *op, SourceLocation opcLoc,
       op = opResult.take();
       assert(op && "successful assignment left argument invalid?");
     }
+    else if (OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(op)) {
+      Expr *Initializer = OVE->getSourceExpr();
+      // passing C++11 style initialized temporaries to objc++ properties
+      // requires special treatment by removing OpaqueValueExpr so type
+      // conversion takes place and adding the OpaqueValueExpr later on.
+      if (isa<InitListExpr>(Initializer) &&
+          Initializer->getType()->isVoidType()) {
+        op = Initializer;
+      }
+    }
   }
 
   // Arguments.
index 36f59b650cec7a0e84e4a3c5c4ace71984604883..7bb4fab3d3fd9ff662ffbbce2459a65016cac288 100644 (file)
@@ -172,3 +172,34 @@ namespace test10 {
 @implementation PropertyOfItself
 @synthesize x;
 @end
+
+// rdar://14654207
+struct CGSize {
+  double width;
+  double height;
+};
+typedef struct CGSize CGSize;
+
+struct CGRect {
+  CGSize origin;
+  CGSize size;
+};
+typedef struct CGRect CGRect;
+
+typedef CGRect NSRect;
+void HappySetFrame(NSRect frame) {}
+
+__attribute__((objc_root_class))
+@interface NSObject 
+@property CGRect frame;
+@end
+
+@implementation NSObject
+- (void) nothing
+{
+       HappySetFrame({{0,0}, {13,14}});
+       [self setFrame: {{0,0}, {13,14}}];
+        self.frame = {{0,0}, {13,14}};
+        self.frame = (CGRect){{3,5}, {13,14}};
+}
+@end