]> granicus.if.org Git - clang/commit
Try contextually converting condition of constexpr if to Boolean value
authorIsmail Pazarbasi <ismail.pazarbasi@gmail.com>
Wed, 7 Sep 2016 18:24:54 +0000 (18:24 +0000)
committerIsmail Pazarbasi <ismail.pazarbasi@gmail.com>
Wed, 7 Sep 2016 18:24:54 +0000 (18:24 +0000)
commit8a4ab9f7f73f68949bb7095bf2322c51d94fd36c
tree371dc94198e1a4e3159269fed35ea71ad6643bbe
parentf86c1678e6c72fb142b4e122327dfb059fe4e479
Try contextually converting condition of constexpr if to Boolean value

Summary:
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 contextually converted constant expression of type bool is an
 expression, contextually converted to bool (Clause4), where the
 converted expression is a constant expression and the conversion
 sequence contains only the conversions above. [...]

Contextually converting result of an expression `e` to a Boolean value
requires `bool t(e)` to be well-formed.

An explicit conversion function is only considered as a user-defined
conversion for direct-initialization, which is essentially what
//contextually converted to bool// requires.

Also, fixes PR28470.

Reviewers: rsmith

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D24158

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@280838 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Sema/SemaOverload.cpp
test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
test/CodeGenCXX/cxx1z-constexpr-if.cpp