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] |
On 08/07/2018 07:12 AM, Ville Voutilainen wrote:
On 8 July 2018 at 02:08, Ville Voutilainen <ville.voutilainen@gmail.com> wrote:On 8 July 2018 at 01:54, Paolo Carlini <paolo.carlini@oracle.com> wrote:That would make this more consistent with such a shadow warning, but I don't want to use the shadowing wording (which would be easy to do; just set 'shadowed' and do a 'goto inform'), because this isn't shadowing in the precise sense; the shadowing cases are warnings, whereas this is more like the redeclaration errors in the same function.... indeed and that annoys me a bit. Not having studied at all c++/79133 so far (sorry) it seems a little weird to me that according to the standard we have to handle the two types of "shadowing" in different ways, one more strict, one less. Thus I would suggest double checking the details of that, eventually with Jason too in terms of the actual patch you would like to apply.Well. The PR is about DR 2211 which, in simple terms, says that lambda parameters and captures cannot have the same name. See http://open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#2211 That's stricter than -Wshadow, but otherwise equally strict as the other error cases already handled in check_local_shadow. So I'll make this error case more consistent with the others. We already handle redeclaration errors slightly differently from shadowing warnings in that function.Here's an updated patch. Tested on Linux-PPC64, OK for trunk? Backports? 2018-08-06 Ville Voutilainen <ville.voutilainen@gmail.com> gcc/cp/ PR c++/79133 * name-lookup.c (check_local_shadow): Reject captures and parameters with the same name.
if (DECL_CONTEXT (old) == current_function_decl && TREE_CODE (decl) != PARM_DECL - && TREE_CODE (old) == PARM_DECL) + && TREE_CODE (old) == PARM_DECL + && !is_capture_proxy (decl)) { /* Go to where the parms should be and see if we find them there. */ @@ -2665,6 +2667,21 @@ check_local_shadow (tree decl) return; } } + /* DR 2211: check that captures and parameters + do not have the same name. */ + else if (is_capture_proxy (decl))
Maybe put this block first rather than add !is_capture_proxy to the if condition?
Jason
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |