зеркало из https://github.com/microsoft/clang-1.git
The value of a case statement is a potentially evaluated context. Found by inspection.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148373 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
7cdfe298ae
Коммит
6b3014b07c
|
@ -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());
|
||||
|
|
|
@ -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); }
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче