Skip to content
This repository has been archived by the owner on Apr 23, 2020. It is now read-only.

Commit

Permalink
Add a missing ExpressionEvaluationContext for template default argume…
Browse files Browse the repository at this point in the history
…nts. Fixes PR12581.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155670 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
eefriedman committed Apr 26, 2012
1 parent 0538ad7 commit 9b94cd1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/Parse/ParseTemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
1 change: 1 addition & 0 deletions lib/Sema/SemaTemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
11 changes: 11 additions & 0 deletions test/SemaTemplate/default-expr-arguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
{
}
}

0 comments on commit 9b94cd1

Please sign in to comment.