[all-commits] [llvm/llvm-project] 540294: [Clang] Reject increment of bool value in unevalua...
yronglin via All-commits
all-commits at lists.llvm.org
Tue Jun 6 08:58:59 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 540294845babbb2be909ea456323d7bc8a1763df
https://github.com/llvm/llvm-project/commit/540294845babbb2be909ea456323d7bc8a1763df
Author: yronglin <yronglin777 at gmail.com>
Date: 2023-06-06 (Tue, 06 Jun 2023)
Changed paths:
M clang/docs/ReleaseNotes.rst
M clang/include/clang/Basic/DiagnosticSemaKinds.td
A clang/test/SemaCXX/bool-increment-SFINAE.cpp
Log Message:
-----------
[Clang] Reject increment of bool value in unevaluated contexts after C++17
Clang now incorrectly allowed increment of bool in unevaluated contexts, we set `diagnostic::ext_increment_bool` to be SFINAEFailure to fix this issue.
```
template<class T> auto f(T t) -> decltype(++t);
auto f(...) -> void;
void g() {
f(true); // Clang wrongly makes this a hard error
}
```
```
template <class T>
concept can_increment = requires(T t) { ++t; };
template <class T> void f() {
static_assert(requires(T t) { ++t; }); // Incorrectly allowed
}
int main() {
f<bool>();
static_assert(!can_increment<bool>); // Incorrectly fails
bool b = false;
++b; // Correctly rejected
}
```
Fix issue: https://github.com/llvm/llvm-project/issues/47517
Reviewed By: erichkeane
Differential Revision: https://reviews.llvm.org/D152259
More information about the All-commits
mailing list