public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/97413] New: gcc-11 fails to typecheck VLA declarations on emacs-27.1: error: wrong number of arguments specified for 'access' attribute
@ 2020-10-13 22:32 slyfox at gcc dot gnu.org
  2020-10-13 22:43 ` [Bug c/97413] [11 Regression] " mpolacek at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: slyfox at gcc dot gnu.org @ 2020-10-13 22:32 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97413

            Bug ID: 97413
           Summary: gcc-11 fails to typecheck VLA declarations on
                    emacs-27.1: error: wrong number of arguments specified
                    for 'access' attribute
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: slyfox at gcc dot gnu.org
  Target Milestone: ---

Originally observer a s build failure of emacs-27.1 on gcc-11.

Minimal reproduces:

$ cat fns.c.c
int a(long b, const int a1[b], long c, const int a2[c], int a3[c]);

$ ./xgcc -B. -c fns.c.c
fns.c.c:1:1: error: wrong number of arguments specified for 'access' attribute
    1 | int a(long b, const int a1[b], long c, const int a2[c], int a3[c]);
      | ^~~
fns.c.c:1:1: note: expected between 1 and 3, found 4

gcc-10 builds it successfully. Original emacs code is at
https://git.savannah.gnu.org/cgit/emacs.git/tree/src/fns.c#n2004 (in case I
reduced it incorrectly).

$ ./xgcc -B. -v

Reading specs from /home/slyfox/dev/git/gcc-native-quick-ggdb3/gcc/specs
COLLECT_GCC=/home/slyfox/dev/git/gcc-native-quick-ggdb3/gcc/xgcc
COLLECT_LTO_WRAPPER=/home/slyfox/dev/git/gcc-native-quick-ggdb3/gcc/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --build=x86_64-pc-linux-gnu
--host=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu
--enable-languages=c,c++ --disable-bootstrap --with-multilib-list=m64
--prefix=/home/slyfox/dev/git/gcc-native-quick-ggdb3/../gcc-native-quick-installed-ggdb3
--disable-nls --without-isl --disable-libsanitizer --disable-libvtv
--disable-libgomp --disable-libstdcxx-pch --disable-libunwind-exceptions
CFLAGS='-O0 -ggdb3 ' CXXFLAGS='-O0 -ggdb3 ' --enable-valgrind-annotations
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.0.0 20201013 (experimental) (GCC)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [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
  2020-10-13 22:32 [Bug c/97413] New: gcc-11 fails to typecheck VLA declarations on emacs-27.1: error: wrong number of arguments specified for 'access' attribute slyfox at gcc dot gnu.org
@ 2020-10-13 22:43 ` mpolacek at gcc dot gnu.org
  2020-10-14  0:32 ` msebor at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-10-13 22:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97413

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org
   Target Milestone|---                         |11.0
            Summary|gcc-11 fails to typecheck   |[11 Regression] gcc-11
                   |VLA declarations on         |fails to typecheck VLA
                   |emacs-27.1: error: wrong    |declarations on emacs-27.1:
                   |number of arguments         |error: wrong number of
                   |specified for 'access'      |arguments specified for
                   |attribute                   |'access' attribute
   Last reconfirmed|                            |2020-10-13
           Keywords|                            |rejects-valid
           Priority|P3                          |P1
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Started with r11-3303.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [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
  2020-10-13 22:32 [Bug c/97413] New: gcc-11 fails to typecheck VLA declarations on emacs-27.1: error: wrong number of arguments specified for 'access' attribute 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
  2020-10-14 21:37 ` cvs-commit at gcc dot gnu.org
  2020-10-14 21:37 ` msebor at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-10-14  0:32 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [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
  2020-10-13 22:32 [Bug c/97413] New: gcc-11 fails to typecheck VLA declarations on emacs-27.1: error: wrong number of arguments specified for 'access' attribute 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
@ 2020-10-14 21:37 ` cvs-commit at gcc dot gnu.org
  2020-10-14 21:37 ` msebor at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-10-14 21:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97413

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Sebor <msebor@gcc.gnu.org>:

https://gcc.gnu.org/g:34efa5c2a84a8c7c7beb855dec24a321eebcbd6b

commit r11-3900-g34efa5c2a84a8c7c7beb855dec24a321eebcbd6b
Author: Martin Sebor <msebor@redhat.com>
Date:   Wed Oct 14 15:18:19 2020 -0600

    PR c/97413 - bogus error on function declaration with many VLA arguments

    gcc/ChangeLog:

            PR c/97413
            * attribs.c (init_attr_rdwr_indices): Unwrap extra list layer.

    gcc/c-family/ChangeLog:

            PR c/97413
            * c-attribs.c (build_attr_access_from_parms): Wrap chain of VLA
            bounds in an extra list.

    gcc/testsuite/ChangeLog:

            PR c/97413
            * gcc.dg/Wvla-parameter-8.c: New test.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [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
  2020-10-13 22:32 [Bug c/97413] New: gcc-11 fails to typecheck VLA declarations on emacs-27.1: error: wrong number of arguments specified for 'access' attribute slyfox at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2020-10-14 21:37 ` cvs-commit at gcc dot gnu.org
@ 2020-10-14 21:37 ` msebor at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-10-14 21:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97413

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
Fixed in r11-3900.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-10-14 21:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-13 22:32 [Bug c/97413] New: gcc-11 fails to typecheck VLA declarations on emacs-27.1: error: wrong number of arguments specified for 'access' attribute 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
2020-10-14 21:37 ` cvs-commit at gcc dot gnu.org
2020-10-14 21:37 ` msebor at gcc dot gnu.org

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).