]> granicus.if.org Git - clang/commitdiff
Fix mishandling of deletedness for assignment operators of classes with
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 31 Aug 2016 20:37:39 +0000 (20:37 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 31 Aug 2016 20:37:39 +0000 (20:37 +0000)
indirect virtual bases. We don't need to be able to invoke such an assignment
operator from the derived class, and we shouldn't delete the derived assignment
op if we can't do so.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@280288 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp
test/CXX/special/class.copy/p20.cpp

index 585cd04d0649fc0c02f5fb81e916a4adf91a1c1b..eb8c3d2cc83795ea6e5e70b6b6ccef1dee440ee1 100644 (file)
@@ -6765,13 +6765,14 @@ bool Sema::ShouldDeleteSpecialMember(CXXMethodDecl *MD, CXXSpecialMember CSM,
   SpecialMemberDeletionInfo SMI(*this, MD, CSM, ICI, Diagnose);
 
   for (auto &BI : RD->bases())
-    if (!BI.isVirtual() &&
+    if ((SMI.IsAssignment || !BI.isVirtual()) &&
         SMI.shouldDeleteForBase(&BI))
       return true;
 
   // Per DR1611, do not consider virtual bases of constructors of abstract
-  // classes, since we are not going to construct them.
-  if (!RD->isAbstract() || !SMI.IsConstructor) {
+  // classes, since we are not going to construct them. For assignment
+  // operators, we only assign (and thus only consider) direct bases.
+  if ((!RD->isAbstract() || !SMI.IsConstructor) && !SMI.IsAssignment) {
     for (auto &BI : RD->vbases())
       if (SMI.shouldDeleteForBase(&BI))
         return true;
index 8dfb7ca8a068d2bc42100b313a4996969c6eba38..4f17879ecfb70fc0f46f20d10ff185b26ffac101 100644 (file)
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 
 struct ConstCopy {
   ConstCopy();