[cfe-commits] r89244 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/CXX/special/class.dtor/p2.cpp

Sebastian Redl sebastian.redl at getdesigned.at
Wed Nov 18 12:55:52 PST 2009


Author: cornedbee
Date: Wed Nov 18 14:55:52 2009
New Revision: 89244

URL: http://llvm.org/viewvc/llvm-project?rev=89244&view=rev
Log:
Pretend destructors are const and volatile. This allows calling them with const and/or volatile objects. Fixes PR5548.

Added:
    cfe/trunk/test/CXX/special/class.dtor/p2.cpp
Modified:
    cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=89244&r1=89243&r2=89244&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Nov 18 14:55:52 2009
@@ -2090,8 +2090,11 @@
 ImplicitConversionSequence
 Sema::TryObjectArgumentInitialization(Expr *From, CXXMethodDecl *Method) {
   QualType ClassType = Context.getTypeDeclType(Method->getParent());
-  QualType ImplicitParamType
-    = Context.getCVRQualifiedType(ClassType, Method->getTypeQualifiers());
+  // [class.dtor]p2: A destructor can be invoked for a const, volatile or
+  //                 const volatile object.
+  unsigned Quals = isa<CXXDestructorDecl>(Method) ?
+    Qualifiers::Const | Qualifiers::Volatile : Method->getTypeQualifiers();
+  QualType ImplicitParamType =  Context.getCVRQualifiedType(ClassType, Quals);
 
   // Set up the conversion sequence as a "bad" conversion, to allow us
   // to exit early.
@@ -2106,7 +2109,7 @@
 
   assert(FromType->isRecordType());
 
-  // The implicit object parmeter is has the type "reference to cv X",
+  // The implicit object parameter is has the type "reference to cv X",
   // where X is the class of which the function is a member
   // (C++ [over.match.funcs]p4). However, when finding an implicit
   // conversion sequence for the argument, we are not allowed to

Added: cfe/trunk/test/CXX/special/class.dtor/p2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/special/class.dtor/p2.cpp?rev=89244&view=auto

==============================================================================
--- cfe/trunk/test/CXX/special/class.dtor/p2.cpp (added)
+++ cfe/trunk/test/CXX/special/class.dtor/p2.cpp Wed Nov 18 14:55:52 2009
@@ -0,0 +1,7 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+// PR5548
+struct A {~A();};
+void a(const A* x) {
+  x->~A();
+}





More information about the cfe-commits mailing list