[cfe-commits] r148373 - in /cfe/trunk: lib/Sema/TreeTransform.h test/SemaCXX/constant-expression-cxx11.cpp
Eli Friedman
eli.friedman at gmail.com
Tue Jan 17 18:54:10 PST 2012
Author: efriedma
Date: Tue Jan 17 20:54:10 2012
New Revision: 148373
URL: http://llvm.org/viewvc/llvm-project?rev=148373&view=rev
Log:
The value of a case statement is a potentially evaluated context. Found by inspection.
Modified:
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=148373&r1=148372&r2=148373&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Tue Jan 17 20:54:10 2012
@@ -4984,8 +4984,8 @@
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());
Modified: cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp?rev=148373&r1=148372&r2=148373&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp (original)
+++ cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp Tue Jan 17 20:54:10 2012
@@ -1022,3 +1022,9 @@
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); }
+}
More information about the cfe-commits
mailing list