<rdar://problem/13140795> Transform the scope type of a pseudo-destructor expression within the object scope.
We were transforming the scope type of a pseudo-destructor expression
(e.g., the first T in x->T::~T()) as a freestanding type, which meant
that dependent template specialization types here would stay dependent
even when no template parameters were named. This would eventually
mean that a dependent expression would end up in what should be
fully-instantiated ASTs, causing IRgen to assert.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176723 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h
index 66bf4ce..c2dcf74 100644
--- a/lib/Sema/TreeTransform.h
+++ b/lib/Sema/TreeTransform.h
@@ -7459,7 +7459,9 @@
TypeSourceInfo *ScopeTypeInfo = 0;
if (E->getScopeTypeInfo()) {
- ScopeTypeInfo = getDerived().TransformType(E->getScopeTypeInfo());
+ CXXScopeSpec EmptySS;
+ ScopeTypeInfo = getDerived().TransformTypeInObjectScope(
+ E->getScopeTypeInfo(), ObjectType, 0, EmptySS);
if (!ScopeTypeInfo)
return ExprError();
}
diff --git a/test/SemaTemplate/destructor-template.cpp b/test/SemaTemplate/destructor-template.cpp
index 07beda4..6806c24 100644
--- a/test/SemaTemplate/destructor-template.cpp
+++ b/test/SemaTemplate/destructor-template.cpp
@@ -57,3 +57,22 @@
};
Foo f;
}
+
+namespace rdar13140795 {
+ template <class T> class shared_ptr {};
+
+ template <typename T> struct Marshal {
+ static int gc();
+ };
+
+
+ template <typename T> int Marshal<T>::gc() {
+ shared_ptr<T> *x;
+ x->template shared_ptr<T>::~shared_ptr();
+ return 0;
+ }
+
+ void test() {
+ Marshal<int>::gc();
+ }
+}