]> granicus.if.org Git - clang/commitdiff
When we're synthesizing copy/move-assignment, we can't form a reference to an
authorEli Friedman <eli.friedman@gmail.com>
Fri, 7 Jun 2013 01:48:56 +0000 (01:48 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Fri, 7 Jun 2013 01:48:56 +0000 (01:48 +0000)
invalid field; make sure we don't try.  Fixes <rdar://problem/14084171>.

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

lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/member-init.cpp

index 059c3720d67ba427ae52435e070e36f8aca52c79..b1c0f56b4426e0dfa339835579c71075f98be146 100644 (file)
@@ -8931,7 +8931,12 @@ void Sema::DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
        Field != FieldEnd; ++Field) {
     if (Field->isUnnamedBitfield())
       continue;
-    
+
+    if (Field->isInvalidDecl()) {
+      Invalid = true;
+      continue;
+    }
+
     // Check for members of reference type; we can't copy those.
     if (Field->getType()->isReferenceType()) {
       Diag(ClassDecl->getLocation(), diag::err_uninitialized_member_for_assign)
@@ -9386,6 +9391,11 @@ void Sema::DefineImplicitMoveAssignment(SourceLocation CurrentLocation,
     if (Field->isUnnamedBitfield())
       continue;
 
+    if (Field->isInvalidDecl()) {
+      Invalid = true;
+      continue;
+    }
+
     // Check for members of reference type; we can't move those.
     if (Field->getType()->isReferenceType()) {
       Diag(ClassDecl->getLocation(), diag::err_uninitialized_member_for_assign)
index 19e8e7597e850e224b0ad3d139e088edd548ada4..6e4fd5df5a08a6b1f7fc96b78fcfdc8040a81b40 100644 (file)
@@ -89,3 +89,14 @@ namespace PR14838 {
     const function &r; // expected-note {{reference member declared here}}
   } af;
 }
+
+namespace rdar14084171 {
+  struct Point { // expected-note 3 {{candidate constructor}}
+    double x;
+    double y;
+  };
+  struct Sprite {
+    Point location = Point(0,0); // expected-error {{no matching constructor for initialization of 'rdar14084171::Point'}}
+  };
+  void f(Sprite& x) { x = x; }
+}