summaryrefslogtreecommitdiff
path: root/lib/Sema/SemaTemplate.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2019-08-24 02:30:00 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2019-08-24 02:30:00 +0000
commit3a4eadc9fc677db3fb3303c749e88315e9d658b7 (patch)
tree93b4cc4c9a5543a0365b421a2c4b8f3e731ff7e2 /lib/Sema/SemaTemplate.cpp
parentec57b202e7c266df2f81c8e37316d0564878c179 (diff)
downloadclang-3a4eadc9fc677db3fb3303c749e88315e9d658b7.tar.gz
PR42513: Enter the proper DeclContext before substituting into an
default template argument expression. We already did this for type template parameters and template template parameters, but apparently forgot to do so for non-type template parameters. This causes the substituted default argument expression to be substituted in the proper context, and in particular to properly mark its subexpressions as odr-used. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@369834 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplate.cpp')
-rw-r--r--lib/Sema/SemaTemplate.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index a73c5d3f9b..d230ec90d7 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -4693,6 +4693,7 @@ SubstDefaultTemplateArgument(Sema &SemaRef,
for (unsigned i = 0, e = Param->getDepth(); i != e; ++i)
TemplateArgLists.addOuterTemplateArguments(None);
+ Sema::ContextRAII SavedContext(SemaRef, Template->getDeclContext());
EnterExpressionEvaluationContext ConstantEvaluated(
SemaRef, Sema::ExpressionEvaluationContext::ConstantEvaluated);
return SemaRef.SubstExpr(Param->getDefaultArgument(), TemplateArgLists);