4 Commits

Author SHA1 Message Date
Timm Bäder
7645823564 [clang][Interp] Don't require StmtExpr result to be an expression
It can be a statement containing an expression.
2024-07-14 07:28:02 +02:00
Akira Hatanaka
cda4a0e918 [Sema] Relax a failing assertion in TransformBlockExpr
The assertion fails when the expression causing the this pointer to be
captured is part of a constexpr if statement's branch and the branch
gets discarded when the enclosing method is instantiated.

Note that the test case is added to CodeGen instead of Sema since the
translation unit has to be free of errors in order for the assertion to
be checked.

Differential Revision: https://reviews.llvm.org/D144016
2023-02-16 18:40:26 -08:00
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
Richard Smith
b130fe7d31 Implement p0292r2 (constexpr if), a likely C++1z feature.
llvm-svn: 273602
2016-06-23 19:16:49 +00:00