[cfe-commits] r113555 - in /cfe/trunk: lib/AST/ExprClassification.cpp lib/Sema/SemaExpr.cpp test/CodeGenObjCXX/property-objects.mm test/SemaObjCXX/propert-dot-error.mm

Fariborz Jahanian fjahanian at apple.com
Thu Sep 9 16:01:10 PDT 2010


Author: fjahanian
Date: Thu Sep  9 18:01:10 2010
New Revision: 113555

URL: http://llvm.org/viewvc/llvm-project?rev=113555&view=rev
Log:
property reference expression used on lhs of assignment
follows objective's semantics and is not overload'able
with an assignment operator. Fixes a crash and a missing
diagnostics. Radar 8379892.

Added:
    cfe/trunk/test/SemaObjCXX/propert-dot-error.mm
Modified:
    cfe/trunk/lib/AST/ExprClassification.cpp
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/CodeGenObjCXX/property-objects.mm

Modified: cfe/trunk/lib/AST/ExprClassification.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprClassification.cpp?rev=113555&r1=113554&r2=113555&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprClassification.cpp (original)
+++ cfe/trunk/lib/AST/ExprClassification.cpp Thu Sep  9 18:01:10 2010
@@ -420,7 +420,8 @@
 
   // Records with any const fields (recursively) are not modifiable.
   if (const RecordType *R = CT->getAs<RecordType>()) {
-    assert(!Ctx.getLangOptions().CPlusPlus &&
+    assert((isa<ObjCImplicitSetterGetterRefExpr>(E) || 
+            !Ctx.getLangOptions().CPlusPlus) &&
            "C++ struct assignment should be resolved by the "
            "copy assignment operator.");
     if (R->hasConstFields())

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=113555&r1=113554&r2=113555&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Sep  9 18:01:10 2010
@@ -6685,6 +6685,8 @@
                             BinaryOperatorKind Opc,
                             Expr *lhs, Expr *rhs) {
   if (getLangOptions().CPlusPlus &&
+      (!isa<ObjCImplicitSetterGetterRefExpr>(lhs) ||
+       rhs->isTypeDependent()) &&
       (lhs->getType()->isOverloadableType() ||
        rhs->getType()->isOverloadableType())) {
     // Find all of the overloaded operators visible from this

Modified: cfe/trunk/test/CodeGenObjCXX/property-objects.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/property-objects.mm?rev=113555&r1=113554&r2=113555&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjCXX/property-objects.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/property-objects.mm Thu Sep  9 18:01:10 2010
@@ -57,3 +57,22 @@
   return 0;
 }
 
+// rdar://8379892
+// CHECK: define void @_Z1fP1A
+// CHECK: @objc_msgSend to void
+struct X {
+  X();
+  X(const X&);
+  ~X();
+};
+
+ at interface A {
+  X xval;
+}
+- (X)x;
+- (void)setX:(X)x;
+ at end
+
+void f(A* a) {
+  a.x = X();
+}

Added: cfe/trunk/test/SemaObjCXX/propert-dot-error.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/propert-dot-error.mm?rev=113555&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjCXX/propert-dot-error.mm (added)
+++ cfe/trunk/test/SemaObjCXX/propert-dot-error.mm Thu Sep  9 18:01:10 2010
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar: // 8379892
+
+struct X {
+  X();
+  X(const X&);
+  ~X();
+};
+
+ at interface A {
+  X xval;
+}
+
+- (X)x;
+- (void)setx:(X)x;
+ at end
+
+void f(A* a) {
+  a.x = X(); // expected-error {{setter method is needed to assign to object using property assignment syntax}}
+}
+





More information about the cfe-commits mailing list