diff options
Diffstat (limited to 'clang/lib/Sema/SemaTemplateDeduction.cpp')
-rw-r--r-- | clang/lib/Sema/SemaTemplateDeduction.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp index 6237610c098..ce3748b901a 100644 --- a/clang/lib/Sema/SemaTemplateDeduction.cpp +++ b/clang/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(), |