When substituting in for a template name, do not produce a qualified
template name as the result of substitution. The qualifier is handled
separately by the tree transformer, so we would end up in an
inconsistent state.
This is actually the last bit of PR9016, and possibly also fixes
PR8965. It takes Boost.Icl from "epic fail" down to a single failure.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127108 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp
index 4108e9f..6fb6ea2 100644
--- a/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/lib/Sema/SemaTemplateInstantiate.cpp
@@ -967,6 +967,13 @@
TemplateName Template = Arg.getAsTemplate();
assert(!Template.isNull() && Template.getAsTemplateDecl() &&
"Wrong kind of template template argument");
+
+ // We don't ever want to substitute for a qualified template name, since
+ // the qualifier is handled separately. So, look through the qualified
+ // template name to its underlying declaration.
+ if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName())
+ Template = TemplateName(QTN->getTemplateDecl());
+
return Template;
}
}
diff --git a/test/SemaTemplate/issue150.cpp b/test/SemaTemplate/issue150.cpp
index 6124d05..af3b93c 100644
--- a/test/SemaTemplate/issue150.cpp
+++ b/test/SemaTemplate/issue150.cpp
@@ -83,7 +83,7 @@
};
template <class T,
- template<class _T, template<class> class Compare = less,
+ template<class _T, template<class> class Compare = PR9016::less,
class = typename interval_type_default<_T,Compare>::type,
template<class> class = allocator> class IntervalSet>
struct ZZZ
@@ -92,7 +92,7 @@
};
template <class T,
- template<class _T, template<class> class Compare = less,
+ template<class _T, template<class> class Compare = PR9016::less,
class = typename interval_type_default<_T,Compare>::type,
template<class> class = allocator> class IntervalSet>
void int40()