In VisitNonTypeTemplateParamDecl, before SubstExpr with the default argument,
we should create a ConstantEvaluated ExpressionEvaluationContext. Without this,
it is possible to use a PotentiallyEvaluated ExpressionEvaluationContext; and
MaybeODRUseExprs will not be cleared when popping the context, causing
assertion failure.
This is similar to how we handle the context before SubstExpr with the
default argument, in SubstDefaultTemplateArgument.
Part of PR13986.
rdar://
24480205
Differential Revision: http://reviews.llvm.org/D17576
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@261803
91177308-0d34-0410-b5e6-
96231b3b80d8
Param->setInvalidDecl();
if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited()) {
+ EnterExpressionEvaluationContext ConstantEvaluated(SemaRef,
+ Sema::ConstantEvaluated);
ExprResult Value = SemaRef.SubstExpr(D->getDefaultArgument(), TemplateArgs);
if (!Value.isInvalid())
Param->setDefaultArgument(Value.get());
g<int>();
}
}
+
+// rdar://problem/24480205
+namespace PR13986 {
+ constexpr unsigned Dynamic = 0;
+ template <unsigned> class A { template <unsigned = Dynamic> void m_fn1(); };
+ class Test {
+ ~Test() {}
+ A<1> m_target;
+ };
+}