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

Rajveer Singh Bharadwaj via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 5 01:37:11 PDT 2024


================
@@ -13367,6 +13367,8 @@ static void DiagnoseConstAssignment(Sema &S, const Expr *E,
         if (!DiagnosticEmitted) {
           S.Diag(Loc, diag::err_typecheck_assign_const)
               << ExprRange << ConstVariable << VD << VD->getType();
+          S.Diag(Loc, diag::note_typecheck_expression_not_modifiable_lvalue)
+              << E->getSourceRange();
----------------
Rajveer100 wrote:

Well, for cases such as these:

```C++
void dr108(void) {
#define const
  const int i = 12;
#undef const
  const int j = 12; /* expected-note {{variable 'j' declared const here}} */

  i = 100; /* Okay, the keyword was hidden by the macro. */
  j = 100; /* expected-error {{cannot assign to variable 'j' with const-qualified type 'const int'}} */
  ^^^^^
}
```

It doesn't make sense right.

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


More information about the cfe-commits mailing list