[clang] [clang] Fix-it hint for `++this` -> `++*this` when deref is modifiable (PR #94159)

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 17 15:45:23 PDT 2024


zygoloid wrote:

Perhaps we can start by supplying `CheckForModifiableLvalue` with extra information about *why* we're doing the check. The current diagnostic we get for incrementing a non-modifiable lvalue:
```console
<source>:2:3: error: cannot assign to variable 'n' with const-qualified type 'const int'
    2 |   ++n;
      |   ^ ~
```
... is really bad -- this isn't an assignment, it's an increment. An enum of possible reasons why we're doing the check would let us significantly improve the diagnostic here.

https://github.com/llvm/llvm-project/pull/94159


More information about the cfe-commits mailing list