This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH], c++] Fix PR30566 and PR41825
- From: Jason Merrill <jason at redhat dot com>
- To: Shujing Zhao <pearly dot zhao at oracle dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Gabriel Dos Reis <gdr at integrable-solutions dot net>, Paolo Carlini <paolo dot carlini at oracle dot com>
- Date: Fri, 07 May 2010 10:35:06 -0400
- Subject: Re: [PATCH], c++] Fix PR30566 and PR41825
- References: <4BE3DA38.8010807@oracle.com>
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