public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "msebor at gcc dot gnu.org" <gcc-bugzilla@gcc.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 [thread overview] Message-ID: <bug-97413-4-kr0fCQPEi8@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-97413-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97413 Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |msebor at gcc dot gnu.org --- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> --- The explicit attribute access takes to two or three arguments. Array and VLA arguments are represented as an implicit access attributes, with the VLA bounds 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 = TREE_CHAIN (mode); + if (vblist) + vblist = TREE_VALUE (vblist); mode = TREE_VALUE (mode); if (TREE_CODE (mode) != 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, tree 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 <node> 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 <node>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 = 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 = build_string (spec.length (), spec.c_str ()); tree attrargs = tree_cons (NULL_TREE, str, vblist); tree name = get_identifier ("access"); - return tree_cons (name, attrargs, NULL_TREE); + return build_tree_list (name, attrargs); } /* Handle a "nothrow" attribute; arguments as in
next prev parent reply other threads:[~2020-10-14 0:32 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-10-13 22:32 [Bug c/97413] New: " slyfox at gcc dot gnu.org 2020-10-13 22:43 ` [Bug c/97413] [11 Regression] " mpolacek at gcc dot gnu.org 2020-10-14 0:32 ` msebor at gcc dot gnu.org [this message] 2020-10-14 21:37 ` cvs-commit at gcc dot gnu.org 2020-10-14 21:37 ` msebor at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-97413-4-kr0fCQPEi8@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).