[llvm-branch-commits] [cfe-branch] r278817 - Merging r278763:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Aug 16 09:19:18 PDT 2016


Author: hans
Date: Tue Aug 16 11:19:18 2016
New Revision: 278817

URL: http://llvm.org/viewvc/llvm-project?rev=278817&view=rev
Log:
Merging r278763:
------------------------------------------------------------------------
r278763 | rsmith | 2016-08-15 17:13:47 -0700 (Mon, 15 Aug 2016) | 5 lines

PR28978: If we need overload resolution for the move constructor of an
anonymous union member of a class, we need overload resolution for the move
constructor of the class itself too; we can't rely on Sema to do the right
thing for us for anonymous union types.

------------------------------------------------------------------------

Modified:
    cfe/branches/release_39/   (props changed)
    cfe/branches/release_39/lib/AST/DeclCXX.cpp
    cfe/branches/release_39/test/CXX/special/class.copy/p11.0x.move.cpp

Propchange: cfe/branches/release_39/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Aug 16 11:19:18 2016
@@ -1,4 +1,4 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:275880,275967,276102,276350,276361,276473,276653,276716,276887,276891,276900,276979,276983,277095,277138,277141,277221,277307,277522,277743,277783,277796-277797,277866,277889,277900,278139,278156,278234-278235,278393,278395
+/cfe/trunk:275880,275967,276102,276350,276361,276473,276653,276716,276887,276891,276900,276979,276983,277095,277138,277141,277221,277307,277522,277743,277783,277796-277797,277866,277889,277900,278139,278156,278234-278235,278393,278395,278763
 /cfe/trunk/test:170344
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/release_39/lib/AST/DeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/lib/AST/DeclCXX.cpp?rev=278817&r1=278816&r2=278817&view=diff
==============================================================================
--- cfe/branches/release_39/lib/AST/DeclCXX.cpp (original)
+++ cfe/branches/release_39/lib/AST/DeclCXX.cpp Tue Aug 16 11:19:18 2016
@@ -807,6 +807,17 @@ void CXXRecordDecl::addedMember(Decl *D)
             data().DefaultedDestructorIsDeleted = true;
         }
 
+        // For an anonymous union member, our overload resolution will perform
+        // overload resolution for its members.
+        if (Field->isAnonymousStructOrUnion()) {
+          data().NeedOverloadResolutionForMoveConstructor |=
+              FieldRec->data().NeedOverloadResolutionForMoveConstructor;
+          data().NeedOverloadResolutionForMoveAssignment |=
+              FieldRec->data().NeedOverloadResolutionForMoveAssignment;
+          data().NeedOverloadResolutionForDestructor |=
+              FieldRec->data().NeedOverloadResolutionForDestructor;
+        }
+
         // C++0x [class.ctor]p5:
         //   A default constructor is trivial [...] if:
         //    -- for all the non-static data members of its class that are of

Modified: cfe/branches/release_39/test/CXX/special/class.copy/p11.0x.move.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/test/CXX/special/class.copy/p11.0x.move.cpp?rev=278817&r1=278816&r2=278817&view=diff
==============================================================================
--- cfe/branches/release_39/test/CXX/special/class.copy/p11.0x.move.cpp (original)
+++ cfe/branches/release_39/test/CXX/special/class.copy/p11.0x.move.cpp Tue Aug 16 11:19:18 2016
@@ -4,6 +4,9 @@ struct Trivial {};
 struct NonTrivial {
   NonTrivial(NonTrivial&&); // expected-note{{copy constructor is implicitly deleted}}
 };
+struct DeletedCopy {
+  DeletedCopy(const DeletedCopy&) = delete;
+};
 
 // A defaulted move constructor for a class X is defined as deleted if X has:
 
@@ -22,6 +25,15 @@ struct DeletedNTVariant2 {
 };
 DeletedNTVariant2::DeletedNTVariant2(DeletedNTVariant2&&) = default; // expected-error{{would delete}}
 
+// Note, move constructor is not a candidate because it is deleted.
+template<typename T> struct DeletedNTVariant3 { // expected-note 2{{default}} expected-note 2{{copy}}
+  union {
+    T NT;
+  };
+};
+extern DeletedNTVariant3<NonTrivial> dntv3a(0); // expected-error {{no matching}}
+extern DeletedNTVariant3<DeletedCopy> dntv3a(0); // expected-error {{no matching}}
+
 // -- a non-static data member of class type M (or array thereof) that cannot be
 //    copied because overload resolution results in an ambiguity or a function
 //    that is deleted or inaccessible




More information about the llvm-branch-commits mailing list