<div dir="ltr">Hi Hans, Eric Fiselier requested that we fix this bug for 3.9 (it affects libc++'s std::optional implementation), so this would be a good candidate for the branch.</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 15, 2016 at 5:13 PM, Richard Smith via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rsmith<br>
Date: Mon Aug 15 19:13:47 2016<br>
New Revision: 278763<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=278763&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=278763&view=rev</a><br>
Log:<br>
PR28978: If we need overload resolution for the move constructor of an<br>
anonymous union member of a class, we need overload resolution for the move<br>
constructor of the class itself too; we can't rely on Sema to do the right<br>
thing for us for anonymous union types.<br>
<br>
Modified:<br>
cfe/trunk/lib/AST/DeclCXX.cpp<br>
cfe/trunk/test/CXX/special/<wbr>class.copy/p11.0x.move.cpp<br>
<br>
Modified: cfe/trunk/lib/AST/DeclCXX.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=278763&r1=278762&r2=278763&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/AST/<wbr>DeclCXX.cpp?rev=278763&r1=<wbr>278762&r2=278763&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)<br>
+++ cfe/trunk/lib/AST/DeclCXX.cpp Mon Aug 15 19:13:47 2016<br>
@@ -807,6 +807,17 @@ void CXXRecordDecl::addedMember(<wbr>Decl *D)<br>
data().<wbr>DefaultedDestructorIsDeleted = true;<br>
}<br>
<br>
+ // For an anonymous union member, our overload resolution will perform<br>
+ // overload resolution for its members.<br>
+ if (Field-><wbr>isAnonymousStructOrUnion()) {<br>
+ data().<wbr>NeedOverloadResolutionForMoveC<wbr>onstructor |=<br>
+ FieldRec->data().<wbr>NeedOverloadResolutionForMoveC<wbr>onstructor;<br>
+ data().<wbr>NeedOverloadResolutionForMoveA<wbr>ssignment |=<br>
+ FieldRec->data().<wbr>NeedOverloadResolutionForMoveA<wbr>ssignment;<br>
+ data().<wbr>NeedOverloadResolutionForDestr<wbr>uctor |=<br>
+ FieldRec->data().<wbr>NeedOverloadResolutionForDestr<wbr>uctor;<br>
+ }<br>
+<br>
// C++0x [class.ctor]p5:<br>
// A default constructor is trivial [...] if:<br>
// -- for all the non-static data members of its class that are of<br>
<br>
Modified: cfe/trunk/test/CXX/special/<wbr>class.copy/p11.0x.move.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/special/class.copy/p11.0x.move.cpp?rev=278763&r1=278762&r2=278763&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/test/CXX/<wbr>special/class.copy/p11.0x.<wbr>move.cpp?rev=278763&r1=278762&<wbr>r2=278763&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/CXX/special/<wbr>class.copy/p11.0x.move.cpp (original)<br>
+++ cfe/trunk/test/CXX/special/<wbr>class.copy/p11.0x.move.cpp Mon Aug 15 19:13:47 2016<br>
@@ -4,6 +4,9 @@ struct Trivial {};<br>
struct NonTrivial {<br>
NonTrivial(NonTrivial&&); // expected-note{{copy constructor is implicitly deleted}}<br>
};<br>
+struct DeletedCopy {<br>
+ DeletedCopy(const DeletedCopy&) = delete;<br>
+};<br>
<br>
// A defaulted move constructor for a class X is defined as deleted if X has:<br>
<br>
@@ -22,6 +25,15 @@ struct DeletedNTVariant2 {<br>
};<br>
DeletedNTVariant2::<wbr>DeletedNTVariant2(<wbr>DeletedNTVariant2&&) = default; // expected-error{{would delete}}<br>
<br>
+// Note, move constructor is not a candidate because it is deleted.<br>
+template<typename T> struct DeletedNTVariant3 { // expected-note 2{{default}} expected-note 2{{copy}}<br>
+ union {<br>
+ T NT;<br>
+ };<br>
+};<br>
+extern DeletedNTVariant3<NonTrivial> dntv3a(0); // expected-error {{no matching}}<br>
+extern DeletedNTVariant3<DeletedCopy> dntv3a(0); // expected-error {{no matching}}<br>
+<br>
// -- a non-static data member of class type M (or array thereof) that cannot be<br>
// copied because overload resolution results in an ambiguity or a function<br>
// that is deleted or inaccessible<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>