The value of a case statement is a potentially evaluated context. Found by inspection.

llvm-svn: 148373
This commit is contained in:
Eli Friedman 2012-01-18 02:54:10 +00:00
parent 7f6a6b7507
commit 1f4f9ddee8
2 changed files with 8 additions and 2 deletions

View File

@ -4984,8 +4984,8 @@ StmtResult
TreeTransform<Derived>::TransformCaseStmt(CaseStmt *S) {
ExprResult LHS, RHS;
{
// The case value expressions are not potentially evaluated.
EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::Unevaluated);
EnterExpressionEvaluationContext Unevaluated(SemaRef,
Sema::ConstantEvaluated);
// Transform the left-hand case value.
LHS = getDerived().TransformExpr(S->getLHS());

View File

@ -1022,3 +1022,9 @@ namespace ComplexConstexpr {
typedef _Complex float fcomplex;
constexpr fcomplex test7 = fcomplex();
}
namespace InstantiateCaseStmt {
template<int x> constexpr int f() { return x; }
template<int x> int g(int c) { switch(c) { case f<x>(): return 1; } return 0; }
int gg(int c) { return g<4>(c); }
}