public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Roger Sayle" <roger@nextmovesoftware.com>
To: <gcc-patches@gcc.gnu.org>
Subject: [PATCH] PR c/110699: Defend against error_mark_node in gimplify.cc.
Date: Wed, 19 Jul 2023 23:10:57 +0100	[thread overview]
Message-ID: <003e01d9ba8d$e5cd4390$b167cab0$@nextmovesoftware.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 685 bytes --]


This patch resolves PR c/110699, an ICE-after-error regression, by adding
a check that the array type isn't error_mark_node in gimplify_compound_lval.

This patch has been tested on x86_64-pc-linux-gnu with make bootstrap
and make -k check, both with and without --target_board=unix{-m32}
with no new failures.  Ok for mainline?


2023-07-19  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
        PR c/110699
        * gimplify.cc (gimplify_compound_lval):  For ARRAY_REF and
        ARRAY_RANGE_REF return GS_ERROR if the array's type is
        error_mark_node.

gcc/testsuite/ChangeLog
        PR c/110699
        * gcc.dg/pr110699.c: New test case.


Cheers,
Roger
--


[-- Attachment #2: patcher.txt --]
[-- Type: text/plain, Size: 1088 bytes --]

diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 36e5df0..4f40b24 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -3211,6 +3211,9 @@ gimplify_compound_lval (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
 
       if (TREE_CODE (t) == ARRAY_REF || TREE_CODE (t) == ARRAY_RANGE_REF)
 	{
+	  if (TREE_TYPE (TREE_OPERAND (t, 0)) == error_mark_node)
+	    return GS_ERROR;
+
 	  /* Deal with the low bound and element type size and put them into
 	     the ARRAY_REF.  If these values are set, they have already been
 	     gimplified.  */
diff --git a/gcc/testsuite/gcc.dg/pr110699.c b/gcc/testsuite/gcc.dg/pr110699.c
new file mode 100644
index 0000000..be77613
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr110699.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+typedef __attribute__((__vector_size__(64))) int T;
+
+void f(void) {
+  extern char a[64], b[64];  /* { dg-message "previous" "note" } */
+  void *p = a;
+  T q = *(T *)&b[0];
+}
+
+void g() {
+  extern char b;  /* { dg-error "conflicting types" } */
+}

             reply	other threads:[~2023-07-19 22:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-19 22:10 Roger Sayle [this message]
2023-07-20  7:31 ` Richard Biener

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='003e01d9ba8d$e5cd4390$b167cab0$@nextmovesoftware.com' \
    --to=roger@nextmovesoftware.com \
    --cc=gcc-patches@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: link
Be 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).