PR c/110699: Defend against error_mark_node in gimplify.cc.
Checks
Commit Message
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
--
Comments
On Thu, Jul 20, 2023 at 12:11 AM Roger Sayle <roger@nextmovesoftware.com> wrote:
>
>
> 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?
Can you change it to
if (error_operand_p (TREE_OPERAND (t, 0))
return GS_ERROR;
and do that unconditionally for each 't' on the expr_stack? It seems we only
ever push handled_component_p to it.
OK with that change.
Richard.
>
>
> 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
> --
>
@@ -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. */
new file mode 100644
@@ -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" } */
+}