From: Eli Friedman Date: Fri, 7 Jun 2013 01:48:56 +0000 (+0000) Subject: When we're synthesizing copy/move-assignment, we can't form a reference to an X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8150da3796300bdc876775e1782331f0e43d2d94;p=clang When we're synthesizing copy/move-assignment, we can't form a reference to an invalid field; make sure we don't try. Fixes . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183479 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 059c3720d6..b1c0f56b44 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -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) diff --git a/test/SemaCXX/member-init.cpp b/test/SemaCXX/member-init.cpp index 19e8e7597e..6e4fd5df5a 100644 --- a/test/SemaCXX/member-init.cpp +++ b/test/SemaCXX/member-init.cpp @@ -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; } +}