[PATCH] D136554: Implement CWG2631

Corentin Jabot via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 31 06:28:43 PDT 2022


cor3ntin added inline comments.


================
Comment at: clang/test/CXX/class/class.local/p1-0x.cpp:14
       int& x2 = x; // expected-error{{reference to local variable 'x' declared in enclosing lambda expression}}
-    };
+    }c; // expected-note {{required here}}
   };
----------------
cor3ntin wrote:
> aaron.ballman wrote:
> > Double-checking: you did intend to name that local variable, right?
> Yes, that's actually the change I'm talking about,
> That specific warning only triggers when the initializer is ODR used, which now only happens when a constructor is defined, which, in the case of aggregate, only happens on use of said aggregate.
Note that i considered delaying that warning only in the presence of immediate invocations but I think this would be inconsistent and surprising - and also probably wrong to mark things odr used if they are not actually ever used.
And alternative would be to not tie that check with the odr-used marking, but that does seem like a pretty consequent change.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136554/new/

https://reviews.llvm.org/D136554



More information about the cfe-commits mailing list