r183479 - When we're synthesizing copy/move-assignment, we can't form a reference to an
Eli Friedman
eli.friedman at gmail.com
Thu Jun 6 18:48:56 PDT 2013
Author: efriedma
Date: Thu Jun 6 20:48:56 2013
New Revision: 183479
URL: http://llvm.org/viewvc/llvm-project?rev=183479&view=rev
Log:
When we're synthesizing copy/move-assignment, we can't form a reference to an
invalid field; make sure we don't try. Fixes <rdar://problem/14084171>.
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/member-init.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=183479&r1=183478&r2=183479&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Jun 6 20:48:56 2013
@@ -8931,7 +8931,12 @@ void Sema::DefineImplicitCopyAssignment(
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(
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)
Modified: cfe/trunk/test/SemaCXX/member-init.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/member-init.cpp?rev=183479&r1=183478&r2=183479&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/member-init.cpp (original)
+++ cfe/trunk/test/SemaCXX/member-init.cpp Thu Jun 6 20:48:56 2013
@@ -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; }
+}
More information about the cfe-commits
mailing list