r278763 - PR28978: If we need overload resolution for the move constructor of an

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 16 09:27:39 PDT 2016


r278817. Many thanks.

On Mon, Aug 15, 2016 at 5:36 PM, Richard Smith <richard at metafoo.co.uk> wrote:
> 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.
>
> On Mon, Aug 15, 2016 at 5:13 PM, Richard Smith via cfe-commits
> <cfe-commits at lists.llvm.org> wrote:
>>
>> Author: rsmith
>> Date: Mon Aug 15 19:13:47 2016
>> New Revision: 278763
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=278763&view=rev
>> Log:
>> 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/trunk/lib/AST/DeclCXX.cpp
>>     cfe/trunk/test/CXX/special/class.copy/p11.0x.move.cpp
>>
>> Modified: cfe/trunk/lib/AST/DeclCXX.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=278763&r1=278762&r2=278763&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/AST/DeclCXX.cpp (original)
>> +++ cfe/trunk/lib/AST/DeclCXX.cpp Mon Aug 15 19:13:47 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/trunk/test/CXX/special/class.copy/p11.0x.move.cpp
>> URL:
>> 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
>>
>> ==============================================================================
>> --- cfe/trunk/test/CXX/special/class.copy/p11.0x.move.cpp (original)
>> +++ cfe/trunk/test/CXX/special/class.copy/p11.0x.move.cpp Mon Aug 15
>> 19:13:47 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
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>


More information about the cfe-commits mailing list