Index: clang/lib/Sema/SemaExpr.cpp =================================================================== --- clang/lib/Sema/SemaExpr.cpp +++ clang/lib/Sema/SemaExpr.cpp @@ -14143,13 +14143,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: clang/test/SemaCXX/constant-expression-cxx1z.cpp =================================================================== --- clang/test/SemaCXX/constant-expression-cxx1z.cpp +++ clang/test/SemaCXX/constant-expression-cxx1z.cpp @@ -46,3 +46,16 @@ const int &r = 0; constexpr int n = r; } + +namespace PR37585 { +template struct S { static constexpr bool value = true; }; +template constexpr bool f() { return true; } +template constexpr bool v = true; + +void test() { + if constexpr (true) {} + else if constexpr (f()) {} + else if constexpr (S::value) {} + else if constexpr (v) {} +} +}