[PATCH] D48322: [Sema] Discarded statment should be an evaluatable context
Phabricator via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 3 15:20:38 PDT 2018
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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48322.154002.patch
Type: text/x-patch
Size: 1528 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180703/d58d11bf/attachment-0001.bin>
More information about the cfe-commits
mailing list