From ae6288981b77d6230bf62055d3bb6380580aa1e8 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Sat, 13 Feb 2010 06:05:33 +0000 Subject: [PATCH] Fix a fiendinshly fun little type-canonicalization bug, where we were rebuilding a typename type terminating in a template-id (with dependent template name, naturally) as a TypenameType when, because its context could be fully resolved, we should have been building it as a QualifiedNameType. Fixes PR6268. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96084 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/TreeTransform.h | 8 ++++++-- test/SemaTemplate/typename-specifier-4.cpp | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index 02dabbb2f5..fc069f7ba3 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -525,9 +525,13 @@ public: /// and the given type. Subclasses may override this routine to provide /// different behavior. QualType RebuildTypenameType(NestedNameSpecifier *NNS, QualType T) { - if (NNS->isDependent()) - return SemaRef.Context.getTypenameType(NNS, + if (NNS->isDependent()) { + CXXScopeSpec SS; + SS.setScopeRep(NNS); + if (!SemaRef.computeDeclContext(SS)) + return SemaRef.Context.getTypenameType(NNS, cast(T)); + } return SemaRef.Context.getQualifiedNameType(NNS, T); } diff --git a/test/SemaTemplate/typename-specifier-4.cpp b/test/SemaTemplate/typename-specifier-4.cpp index 9c757c5ad0..0a6fef74c3 100644 --- a/test/SemaTemplate/typename-specifier-4.cpp +++ b/test/SemaTemplate/typename-specifier-4.cpp @@ -80,3 +80,22 @@ namespace PR6236 { } }; } + +namespace PR6268 { + template + struct Outer { + template + struct Inner {}; + + template + typename Outer::template Inner + foo(typename Outer::template Inner); + }; + + template + template + typename Outer::template Inner + Outer::foo(typename Outer::template Inner) { + return Inner(); + } +} -- 2.40.0