llvm-project/clang/test/CXX
Ismail Pazarbasi 4a00774e59 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

llvm-svn: 280838
2016-09-07 18:24:54 +00:00
..
basic Don't diagnoes a mismatch between implicit and explicit exception 2016-08-31 20:38:32 +00:00
class Fix all tests under test/CXX (and test/Analysis) to pass if clang's default 2016-08-31 23:24:08 +00:00
class.access Fix all tests under test/CXX (and test/Analysis) to pass if clang's default 2016-08-31 23:24:08 +00:00
class.derived PR6037 2015-01-19 01:44:02 +00:00
concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept [Concepts] Implement subsection [dcl.spec.concept]p7 of the Concepts TS 2016-04-09 02:55:27 +00:00
conv PR6037 2015-01-19 01:44:02 +00:00
dcl.dcl Push alias-declarations and alias-template declarations into scope even if 2016-07-15 20:53:25 +00:00
dcl.decl Fix clang's handling of the copy performed in the second phase of class 2016-09-07 02:14:33 +00:00
drs Fix clang's handling of the copy performed in the second phase of class 2016-09-07 02:14:33 +00:00
except P0136R1, DR1573, DR1645, DR1715, DR1736, DR1903, DR1941, DR1959, DR1991: 2016-06-28 19:03:57 +00:00
expr Warn when a reference is bound to an empty l-value (dereferenced null pointer). 2016-05-14 17:44:14 +00:00
lex Convert test/CXX/lex/lex.literal/lex.string/p4.cpp back to DOS line 2016-01-04 10:17:48 +00:00
over Improve diagnostics for ill-formed literal operator declarations. 2016-02-17 00:04:04 +00:00
special Fix all tests under test/CXX (and test/Analysis) to pass if clang's default 2016-08-31 23:24:08 +00:00
stmt.stmt Try contextually converting condition of constexpr if to Boolean value 2016-09-07 18:24:54 +00:00
temp Fix all tests under test/CXX (and test/Analysis) to pass if clang's default 2016-08-31 23:24:08 +00:00