From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 171513861030; Wed, 14 Oct 2020 00:32:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 171513861030 From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/97413] [11 Regression] gcc-11 fails to typecheck VLA declarations on emacs-27.1: error: wrong number of arguments specified for 'access' attribute Date: Wed, 14 Oct 2020 00:32:41 +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: 11.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: msebor at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status assigned_to 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: Wed, 14 Oct 2020 00:32:42 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97413 Martin Sebor changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |msebor at gcc dot g= nu.org --- Comment #2 from Martin Sebor --- The explicit attribute access takes to two or three arguments. Array and V= LA arguments are represented as an implicit access attributes, with the VLA bo= unds chained on to the end of the attribute. The untested patch below fixes the problem by wrapping the arbitrarily long chain in a list with just a single value. diff --git a/gcc/attribs.c b/gcc/attribs.c index 94b9e02699f..325799f0442 100644 --- a/gcc/attribs.c +++ b/gcc/attribs.c @@ -2049,6 +2049,8 @@ init_attr_rdwr_indices (rdwr_map *rwm, tree attrs) /* The (optional) list of VLA bounds. */ tree vblist =3D TREE_CHAIN (mode); + if (vblist) + vblist =3D TREE_VALUE (vblist); mode =3D TREE_VALUE (mode); if (TREE_CODE (mode) !=3D STRING_CST) diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c index c779d13f023..8283e959c89 100644 --- a/gcc/c-family/c-attribs.c +++ b/gcc/c-family/c-attribs.c @@ -4547,10 +4547,11 @@ handle_access_attribute (tree node[3], tree name, t= ree args, result in the following attribute access: value: "+^2[*],$0$1^3[*],$1$1" - chain: <0, x> <1, y> + list: < <0, x> <1, y> > - where each on the chain corresponds to one VLA bound for each - of the two parameters. */ + where the list has a single value which itself is is a list each + of whose s corresponds to one VLA bound for each of the two + parameters. */ tree build_attr_access_from_parms (tree parms, bool skip_voidptr) @@ -4654,13 +4655,17 @@ build_attr_access_from_parms (tree parms, bool skip_voidptr) if (!spec.length ()) return NULL_TREE; + /* Attribute access takes a two or three arguments. Wrap VBLIST in + another list in case it has more nodes than would otherwise fit. */ + vblist =3D build_tree_list (NULL_TREE, vblist); + /* Build a single attribute access with the string describing all array arguments and an optional list of any non-parameter VLA bounds in order. */ tree str =3D build_string (spec.length (), spec.c_str ()); tree attrargs =3D tree_cons (NULL_TREE, str, vblist); tree name =3D get_identifier ("access"); - return tree_cons (name, attrargs, NULL_TREE); + return build_tree_list (name, attrargs); } /* Handle a "nothrow" attribute; arguments as in=