]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c/110699: Defend against error_mark_node in gimplify.cc.
authorRoger Sayle <roger@nextmovesoftware.com>
Fri, 21 Jul 2023 19:37:59 +0000 (20:37 +0100)
committerRoger Sayle <roger@nextmovesoftware.com>
Fri, 21 Jul 2023 19:37:59 +0000 (20:37 +0100)
This patch resolves PR c/110669, an ICE-after-error regression, by adding
a check that the array type isn't error_mark_node in gimplify_compound_lval.

2023-07-21  Roger Sayle  <roger@nextmovesoftware.com>
    Richard Biener  <rguenther@suse.de>

gcc/ChangeLog
PR c/110699
* gimplify.cc (gimplify_compound_lval):  If the array's type
is error_mark_node then return GS_ERROR.

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

gcc/gimplify.cc
gcc/testsuite/gcc.dg/pr110699.c [new file with mode: 0644]

index 36e5df050b9cc5419591b0e9ff5d45141387fc9a..320920ed74c0a6469c65474e69987b2545da842f 100644 (file)
@@ -3209,6 +3209,9 @@ gimplify_compound_lval (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
     {
       tree t = expr_stack[i];
 
+      if (error_operand_p (TREE_OPERAND (t, 0)))
+       return GS_ERROR;
+
       if (TREE_CODE (t) == ARRAY_REF || TREE_CODE (t) == ARRAY_RANGE_REF)
        {
          /* Deal with the low bound and element type size and put them into
diff --git a/gcc/testsuite/gcc.dg/pr110699.c b/gcc/testsuite/gcc.dg/pr110699.c
new file mode 100644 (file)
index 0000000..be77613
--- /dev/null
@@ -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" } */
+}