This revision was automatically updated to reflect the committed changes. Closed by commit rL336233: [Sema] Discarded statment should be an evaluatable context. (authored by epilk, committed by ). Herald added a subscriber: llvm-commits.
Changed prior to commit: https://reviews.llvm.org/D48322?vs=151910&id=154002#toc Repository: rL LLVM https://reviews.llvm.org/D48322 Files: cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/test/SemaCXX/constant-expression-cxx1z.cpp Index: cfe/trunk/test/SemaCXX/constant-expression-cxx1z.cpp =================================================================== --- cfe/trunk/test/SemaCXX/constant-expression-cxx1z.cpp +++ cfe/trunk/test/SemaCXX/constant-expression-cxx1z.cpp @@ -46,3 +46,16 @@ const int &r = 0; constexpr int n = r; } + +namespace PR37585 { +template <class T> struct S { static constexpr bool value = true; }; +template <class T> constexpr bool f() { return true; } +template <class T> constexpr bool v = true; + +void test() { + if constexpr (true) {} + else if constexpr (f<int>()) {} + else if constexpr (S<int>::value) {} + else if constexpr (v<int>) {} +} +} Index: cfe/trunk/lib/Sema/SemaExpr.cpp =================================================================== --- cfe/trunk/lib/Sema/SemaExpr.cpp +++ cfe/trunk/lib/Sema/SemaExpr.cpp @@ -14237,13 +14237,13 @@ switch (SemaRef.ExprEvalContexts.back().Context) { case Sema::ExpressionEvaluationContext::Unevaluated: case Sema::ExpressionEvaluationContext::UnevaluatedAbstract: - case Sema::ExpressionEvaluationContext::DiscardedStatement: // Expressions in this context are never evaluated. return false; case Sema::ExpressionEvaluationContext::UnevaluatedList: case Sema::ExpressionEvaluationContext::ConstantEvaluated: case Sema::ExpressionEvaluationContext::PotentiallyEvaluated: + case Sema::ExpressionEvaluationContext::DiscardedStatement: // Expressions in this context could be evaluated. return true;
Index: cfe/trunk/test/SemaCXX/constant-expression-cxx1z.cpp =================================================================== --- cfe/trunk/test/SemaCXX/constant-expression-cxx1z.cpp +++ cfe/trunk/test/SemaCXX/constant-expression-cxx1z.cpp @@ -46,3 +46,16 @@ const int &r = 0; constexpr int n = r; } + +namespace PR37585 { +template <class T> struct S { static constexpr bool value = true; }; +template <class T> constexpr bool f() { return true; } +template <class T> constexpr bool v = true; + +void test() { + if constexpr (true) {} + else if constexpr (f<int>()) {} + else if constexpr (S<int>::value) {} + else if constexpr (v<int>) {} +} +} Index: cfe/trunk/lib/Sema/SemaExpr.cpp =================================================================== --- cfe/trunk/lib/Sema/SemaExpr.cpp +++ cfe/trunk/lib/Sema/SemaExpr.cpp @@ -14237,13 +14237,13 @@ switch (SemaRef.ExprEvalContexts.back().Context) { case Sema::ExpressionEvaluationContext::Unevaluated: case Sema::ExpressionEvaluationContext::UnevaluatedAbstract: - case Sema::ExpressionEvaluationContext::DiscardedStatement: // Expressions in this context are never evaluated. return false; case Sema::ExpressionEvaluationContext::UnevaluatedList: case Sema::ExpressionEvaluationContext::ConstantEvaluated: case Sema::ExpressionEvaluationContext::PotentiallyEvaluated: + case Sema::ExpressionEvaluationContext::DiscardedStatement: // Expressions in this context could be evaluated. return true;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits