public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Martin Sebor <msebor@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-8410] PR c/100550 - ICE: in fold_convert_loc with function call VLA argument Date: Thu, 13 May 2021 16:46:11 +0000 (GMT) [thread overview] Message-ID: <20210513164611.5CD143898527@sourceware.org> (raw) https://gcc.gnu.org/g:4415051422690e6eda2ff6644b4f35432fcd7707 commit r11-8410-g4415051422690e6eda2ff6644b4f35432fcd7707 Author: Martin Sebor <msebor@redhat.com> Date: Thu May 13 10:45:32 2021 -0600 PR c/100550 - ICE: in fold_convert_loc with function call VLA argument gcc/c/ChangeLog: PR c/100550 * c-decl.c (get_parm_array_spec): Avoid erroneous VLA bounds. gcc/testsuite/ChangeLog: PR c/100550 * gcc.dg/Wvla-parameter-9.c: New test. Diff: --- gcc/c/c-decl.c | 3 +++ gcc/testsuite/gcc.dg/Wvla-parameter-9.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 3ea4708c507..53b2b5b637d 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -5856,6 +5856,9 @@ get_parm_array_spec (const struct c_parm *parm, tree attrs) spec += buf; break; } + else if (!INTEGRAL_TYPE_P (TREE_TYPE (nelts))) + /* Avoid invalid NELTS. */ + return attrs; /* Each variable VLA bound is represented by a dollar sign. */ spec += "$"; diff --git a/gcc/testsuite/gcc.dg/Wvla-parameter-9.c b/gcc/testsuite/gcc.dg/Wvla-parameter-9.c new file mode 100644 index 00000000000..6c8987a34eb --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wvla-parameter-9.c @@ -0,0 +1,30 @@ +/* PR c/100550 - ICE: in fold_convert_loc with function call VLA argument + { dg-do compile } + { dg-options "-Wall" } */ + +struct S { int i; }; + +extern void v; +extern void *pv; +extern struct S s; +void vf (void); + +/* Verify that a function redeclaration with an invalid VLA doesn't ICE. */ + +void f0 (int[]); +void f0 (int[undeclared]); // { dg-error "undeclared" } + +void f1 (int[]); +void f1 (int[-1]); // { dg-error "size" } + +void f2 (int[]); +void f2 (int[v]); // { dg-error "size" } + +void f3 (int[]); +void f3 (int b[s]); // { dg-error "size" } + +void f4 (int[]); +void f4 (int c[pv]); // { dg-error "size" } + +void f5 (int[]); +void f5 (int d[vf ()]); // { dg-error "size" }
reply other threads:[~2021-05-13 16:46 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210513164611.5CD143898527@sourceware.org \ --to=msebor@gcc.gnu.org \ --cc=gcc-cvs@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).