[clang] [Clang] eliminate shadowing warnings for parameters using deducing this (PR #114813)

via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 5 23:09:14 PST 2024


================
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -std=c++2b -Wshadow-all %s
+
+namespace GH95707 {
+struct Foo {
+  int a; // expected-note {{previous declaration is here}}
+
+  void f1(this auto &self, int a) { self.a = a; }
+  void f2(int a) { } // expected-warning {{declaration shadows a field of 'GH95707::Foo'}}
+  void f3() {
+    [&](this auto &self, int x) { }; // expected-warning {{expression result unused}}
----------------
Sirraide wrote:

```suggestion
    (void) [&](this auto &self, int a) { };
```
Typo, and add `(void)` so we don’t get a warning we don’t care about in this case ;þ

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


More information about the cfe-commits mailing list