aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaTemplateDeduction.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-10-12 19:40:14 +0000
committerJohn McCall <rjmccall@apple.com>2010-10-12 19:40:14 +0000
commitdf41f18936693f7c62e457eefb9fad5b2d2fe3cd (patch)
tree7d6b4d82a188e9cef06bb28ac52e58be23b7422e /lib/Sema/SemaTemplateDeduction.cpp
parent3273b0cea879c7af345d6bf98502bbf73fc4fde1 (diff)
Enter the context of the declared function template when performing
deduction and the final substitution, but not while substituting the explicit template arguments. Fixes rdar://problem/8537391 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116332 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateDeduction.cpp')
-rw-r--r--lib/Sema/SemaTemplateDeduction.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp
index 6237610c09..ce3748b901 100644
--- a/lib/Sema/SemaTemplateDeduction.cpp
+++ b/lib/Sema/SemaTemplateDeduction.cpp
@@ -1218,8 +1218,6 @@ Sema::SubstituteExplicitTemplateArguments(
if (Inst)
return TDK_InstantiationDepth;
- ContextRAII SavedContext(*this, FunctionTemplate->getTemplatedDecl());
-
if (CheckTemplateArgumentList(FunctionTemplate,
SourceLocation(),
ExplicitTemplateArgs,
@@ -1238,6 +1236,12 @@ Sema::SubstituteExplicitTemplateArguments(
= new (Context) TemplateArgumentList(Context, Builder, /*TakeArgs=*/true);
Info.reset(ExplicitArgumentList);
+ // Template argument deduction and the final substitution should be
+ // done in the context of the templated declaration. Explicit
+ // argument substitution, on the other hand, needs to happen in the
+ // calling context.
+ ContextRAII SavedContext(*this, FunctionTemplate->getTemplatedDecl());
+
// Instantiate the types of each of the function parameters given the
// explicitly-specified template arguments.
for (FunctionDecl::param_iterator P = Function->param_begin(),