Skip to content
Commit 54029484 authored by yronglin's avatar yronglin
Browse files

[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
parent 2c0e1524
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment