r261803 - Fix assertion failure on MaybeODRUseExprs.
Manman Ren via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 24 15:05:44 PST 2016
Author: mren
Date: Wed Feb 24 17:05:43 2016
New Revision: 261803
URL: http://llvm.org/viewvc/llvm-project?rev=261803&view=rev
Log:
Fix assertion failure on MaybeODRUseExprs.
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
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=261803&r1=261802&r2=261803&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Wed Feb 24 17:05:43 2016
@@ -2110,6 +2110,8 @@ Decl *TemplateDeclInstantiator::VisitNon
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());
Modified: cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp?rev=261803&r1=261802&r2=261803&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp (original)
+++ cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp Wed Feb 24 17:05:43 2016
@@ -75,3 +75,13 @@ namespace rdar23810407 {
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;
+ };
+}
More information about the cfe-commits
mailing list