aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2012-04-26 22:43:24 +0000
committerEli Friedman <eli.friedman@gmail.com>2012-04-26 22:43:24 +0000
commit9b94cd1b2527c8dc9ec19a8608f2313010e721b5 (patch)
tree697bb2c1849ba03cf0c4722ee5a7cc86d386c54a
parent0538ad754437e2cfb8b03b94dc6f3d1046f240f2 (diff)
Add a missing ExpressionEvaluationContext for template default arguments. Fixes PR12581.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155670 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Parse/ParseTemplate.cpp1
-rw-r--r--lib/Sema/SemaTemplate.cpp1
-rw-r--r--test/SemaTemplate/default-expr-arguments.cpp11
3 files changed, 13 insertions, 0 deletions
diff --git a/lib/Parse/ParseTemplate.cpp b/lib/Parse/ParseTemplate.cpp
index f8204d9cda..5c3e2ba589 100644
--- a/lib/Parse/ParseTemplate.cpp
+++ b/lib/Parse/ParseTemplate.cpp
@@ -652,6 +652,7 @@ Parser::ParseNonTypeTemplateParameter(unsigned Depth, unsigned Position) {
// end of the template-parameter-list rather than a greater-than
// operator.
GreaterThanIsOperatorScope G(GreaterThanIsOperator, false);
+ EnterExpressionEvaluationContext Unevaluated(Actions, Sema::Unevaluated);
DefaultArg = ParseAssignmentExpression();
if (DefaultArg.isInvalid())
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index be59068649..b5b99f978e 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -2562,6 +2562,7 @@ SubstDefaultTemplateArgument(Sema &SemaRef,
SourceRange(TemplateLoc, RAngleLoc));
Sema::ContextRAII SavedContext(SemaRef, Template->getDeclContext());
+ EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::Unevaluated);
return SemaRef.SubstExpr(Param->getDefaultArgument(), AllTemplateArgs);
}
diff --git a/test/SemaTemplate/default-expr-arguments.cpp b/test/SemaTemplate/default-expr-arguments.cpp
index 5d301be2fb..1eefa9f895 100644
--- a/test/SemaTemplate/default-expr-arguments.cpp
+++ b/test/SemaTemplate/default-expr-arguments.cpp
@@ -292,3 +292,14 @@ namespace PR8401 {
f();
}
}
+
+namespace PR12581 {
+ const int a = 0;
+ template < typename > struct A;
+ template < typename MatrixType, int =
+ A < MatrixType >::Flags ? : A < MatrixType >::Flags & a > class B;
+ void
+ fn1 ()
+ {
+ }
+}