ismailp created this revision.
ismailp added a reviewer: rsmith.
ismailp added a subscriber: cfe-commits.
C++1z 6.4.1/p2:
If the if statement is of the form if constexpr, the value of the
condition shall be a contextually converted constant expression of type
bool [...]
C++1z 5.20/p4:
[...] A
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.
Thanks, LGTM.
If you're looking for more issues in this area -- in passing I noticed that we
fail to apply the "contextually converted constant expression of type bool"
rules properly in the
rsmith added inline comments.
Comment at: test/CodeGenCXX/cxx1z-constexpr-if.cpp:26-29
@@ -17,2 +25,6 @@
}
+ if constexpr (A())
+should_be_used_3();
+ else
+should_not_be_used();
}
Please also add a test that we reject expressions that are contextual
ismailp updated this revision to Diff 70561.
ismailp added a comment.
- Added more tests
https://reviews.llvm.org/D24158
Files:
lib/Sema/SemaOverload.cpp
test/CodeGenCXX/cxx1z-constexpr-if.cpp
Index: test/CodeGenCXX/cxx1z-constexpr-if.cpp
===
ismailp added a comment.
Thank you for reviewing.
Sure, I'll try to look into those conversions as well.
Comment at: test/CodeGenCXX/cxx1z-constexpr-if.cpp:2
@@ -1,2 +1,3 @@
// RUN: %clang_cc1 -std=c++1z %s -emit-llvm -o - | FileCheck %s
--implicit-check-not=should_not_be_use
rsmith added inline comments.
Comment at: test/CodeGenCXX/cxx1z-constexpr-if.cpp:2
@@ -1,2 +1,3 @@
// RUN: %clang_cc1 -std=c++1z %s -emit-llvm -o - | FileCheck %s
--implicit-check-not=should_not_be_used
+// RUN: %clang_cc1 -std=c++1z %s -DCHECK_CONVERSION -verify %s
--
This revision was automatically updated to reflect the committed changes.
Closed by commit rL280838: Try contextually converting condition of constexpr
if to Boolean value (authored by ismailp).
Changed prior to commit:
https://reviews.llvm.org/D24158?vs=70561&id=70577#toc
Repository:
rL LLV
ismailp added inline comments.
Comment at: test/CodeGenCXX/cxx1z-constexpr-if.cpp:2
@@ -1,2 +1,3 @@
// RUN: %clang_cc1 -std=c++1z %s -emit-llvm -o - | FileCheck %s
--implicit-check-not=should_not_be_used
+// RUN: %clang_cc1 -std=c++1z %s -DCHECK_CONVERSION -verify %s
-