r280288 - Fix mishandling of deletedness for assignment operators of classes with

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 31 13:37:39 PDT 2016


Author: rsmith
Date: Wed Aug 31 15:37:39 2016
New Revision: 280288

URL: http://llvm.org/viewvc/llvm-project?rev=280288&view=rev
Log:
Fix mishandling of deletedness for assignment operators of classes with
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.

Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/test/CXX/special/class.copy/p20.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=280288&r1=280287&r2=280288&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Aug 31 15:37:39 2016
@@ -6765,13 +6765,14 @@ bool Sema::ShouldDeleteSpecialMember(CXX
   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;

Modified: cfe/trunk/test/CXX/special/class.copy/p20.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/special/class.copy/p20.cpp?rev=280288&r1=280287&r2=280288&view=diff
==============================================================================
--- cfe/trunk/test/CXX/special/class.copy/p20.cpp (original)
+++ cfe/trunk/test/CXX/special/class.copy/p20.cpp Wed Aug 31 15:37:39 2016
@@ -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();




More information about the cfe-commits mailing list