]> granicus.if.org Git - clang/commitdiff
PR12798: Don't drop part of the nested name specifier when instantiating a
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 15 May 2012 06:15:11 +0000 (06:15 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 15 May 2012 06:15:11 +0000 (06:15 +0000)
pseudo-destructor expression. This can affect whether virtual dispatch for
the destructor call is bypassed.

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

lib/Sema/TreeTransform.h
test/CodeGenCXX/virtual-destructor-calls.cpp

index 7387eac667ba25db736dbbd4e1c781e5c15f630d..01b82aa3d75de64d484f7ddd7beec9aed117cd3e 100644 (file)
@@ -9268,7 +9268,11 @@ TreeTransform<Derived>::RebuildCXXPseudoDestructorExpr(Expr *Base,
   DeclarationNameInfo NameInfo(Name, Destroyed.getLocation());
   NameInfo.setNamedTypeInfo(DestroyedType);
 
-  // FIXME: the ScopeType should be tacked onto SS.
+  // The scope type is now known to be a valid nested name specifier
+  // component. Tack it on to the end of the nested name specifier.
+  if (ScopeType)
+    SS.Extend(SemaRef.Context, SourceLocation(),
+              ScopeType->getTypeLoc(), CCLoc);
 
   SourceLocation TemplateKWLoc; // FIXME: retrieve it from caller.
   return getSema().BuildMemberReferenceExpr(Base, BaseType,
index 1cc8bcc7753ef4771bf624751396f9eb436abe25..7ef50b23fa7c037892a3ef1efb654dcc1dfbd889 100644 (file)
@@ -46,3 +46,14 @@ C::~C() { }
 // CHECK: call void @_ZdlPv
 
 // Base dtor: just an alias to B's base dtor.
+
+namespace PR12798 {
+  // A qualified call to a base class destructor should not undergo virtual
+  // dispatch. Template instantiation used to lose the qualifier.
+  struct A { virtual ~A(); };
+  template<typename T> void f(T *p) { p->A::~A(); }
+
+  // CHECK: define {{.*}} @_ZN7PR127981fINS_1AEEEvPT_(
+  // CHECK: call void @_ZN7PR127981AD1Ev(
+  template void f(A*);
+}