This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH], c++] Fix PR30566 and PR41825


It looks like this patch would mean that we still warn about a decl in a lambda in a local class member function, i.e.

void f(int i, int j) {
  struct A {
    void g() { [](int i){ int j; }; } // shouldn't warn
  };
}

We do want to warn about shadowing by a local variable in a lambda, not just a parameter:

void f (int i) {
 [=]{
   i; // OK, refers to captured i
   int i; // shadows captured i
 };
}

Rather than handle this in two places, I think you should just walk from current_function_decl up to DECL_CONTEXT (oldlocal) and see if there's a non-lambda local class along the way; this doesn't depend on what 'x' is at all.

Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]