From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 080B4385B835; Fri, 10 Apr 2020 23:18:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 080B4385B835 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1586560736; bh=7Qo/tNirlCW8GSVFs++K5MiVpb5xZgeCrErnw1dEoFQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=xEyABUnNVlm3Q9HzXdd+A0Ghv+mBbUY9dJ5d5gzkNdmpKZ5sEXng9iRhVdD2POH7X dGVo84y69M8qN7e1dHbU2zw6af2YxOsTAZYmJ9tNyixHPINZdZAJqklPiUtsuaRv0W kfLBr9PYeiQ/FWrtVYdddQkD9XY5/Xvhre1aKDM0= From: "mpolacek at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/94553] Revisit [basic.scope.declarative]/4.2 Date: Fri, 10 Apr 2020 23:18:55 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: accepts-invalid X-Bugzilla-Severity: normal X-Bugzilla-Who: mpolacek at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Apr 2020 23:18:56 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94553 --- Comment #2 from Marek Polacek --- To fix CWG 2289, we need this: --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -1705,6 +1705,9 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) inform (olddecl_loc, "previous declaration %q#D", olddecl); return error_mark_node; } + else if ((VAR_P (olddecl) && DECL_DECOMPOSITION_P (olddecl)) + || (VAR_P (newdecl) && DECL_DECOMPOSITION_P (newdecl))) + /* A structured binding must be unique in its declarative region. */; else if (DECL_IMPLICIT_TYPEDEF_P (olddecl) || DECL_IMPLICIT_TYPEDEF_P (newdecl)) /* One is an implicit typedef, that's ok. */ but that's not enough to detect the 'A' case: cp_parser_decomposition_declaration uses 13968 tree decl2 =3D start_decl (declarator, &decl_specs, SD_INITIALI= ZED, 13969 NULL_TREE, NULL_TREE, &elt_pushed_scop= e); to create the 'A' VAR_DECL but in this start_decl's grokdeclarator we don't= do fit_decomposition_lang_decl because the declarator kind is not cdk_decomp, = so then when start_decl calls maybe_push_decl, the decl 'A' isn't DECL_DECOMPOSITION_P and we don't detect this case. So we need a way to si= gnal to start_decl that it should fit_decomposition_lang_decl.=