From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1314) id 1BDD83858428; Mon, 21 Nov 2022 07:47:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1BDD83858428 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669016844; bh=Z+y6kbFTJvKwjYqxFwdBdoyyr1EgNsC/acTw7/rfaQ4=; h=From:To:Subject:Date:From; b=ch7oo60JWhXLrVcjiJtKYYUnHFEFSLNOWVcNUc0qeHVMKkeGcnRTViFdYSn4CrZd4 iutR5XdhNgWlBP9/Mf3j2JikYBMk8dut2JcUC7FmRdlWIH7j18PxHwGzfaoBb2MkTY Nx7/bcnTXkcs12B1mIL9jfSweadOrAnNP68zTWNA= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Andrew Pinski To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4181] Fix PR 106560: Another ICE after conflicting types of redeclaration X-Act-Checkin: gcc X-Git-Author: Andrew Pinski X-Git-Refname: refs/heads/trunk X-Git-Oldrev: 183db4fb73a64bc4641604c30cdbbd9d9e8a6ed6 X-Git-Newrev: b03ad138a61f64d8a77876d6864aad5103fff498 Message-Id: <20221121074724.1BDD83858428@sourceware.org> Date: Mon, 21 Nov 2022 07:47:24 +0000 (GMT) List-Id: https://gcc.gnu.org/g:b03ad138a61f64d8a77876d6864aad5103fff498 commit r13-4181-gb03ad138a61f64d8a77876d6864aad5103fff498 Author: Andrew Pinski Date: Sat Nov 19 12:48:27 2022 -0800 Fix PR 106560: Another ICE after conflicting types of redeclaration This another one of these ICE after error issues with the gimplifier and a fallout from r12-3278-g823685221de986af. The problem here is gimplify_modify_expr does not check if either from or to was an error operand. This adds the check and fixes the ICE. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: * gimplify.cc (gimplify_modify_expr): If either *from_p or *to_p were error_operand return early. gcc/testsuite/ChangeLog: * gcc.dg/redecl-23.c: New test. * gcc.dg/redecl-24.c: New test. * gcc.dg/redecl-25.c: New test. Diff: --- gcc/gimplify.cc | 3 +++ gcc/testsuite/gcc.dg/redecl-23.c | 6 ++++++ gcc/testsuite/gcc.dg/redecl-24.c | 6 ++++++ gcc/testsuite/gcc.dg/redecl-25.c | 9 +++++++++ 4 files changed, 24 insertions(+) diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc index c62a966e918..02415cb1b5c 100644 --- a/gcc/gimplify.cc +++ b/gcc/gimplify.cc @@ -6054,6 +6054,9 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, location_t loc = EXPR_LOCATION (*expr_p); gimple_stmt_iterator gsi; + if (error_operand_p (*from_p) || error_operand_p (*to_p)) + return GS_ERROR; + gcc_assert (TREE_CODE (*expr_p) == MODIFY_EXPR || TREE_CODE (*expr_p) == INIT_EXPR); diff --git a/gcc/testsuite/gcc.dg/redecl-23.c b/gcc/testsuite/gcc.dg/redecl-23.c new file mode 100644 index 00000000000..425721df2ff --- /dev/null +++ b/gcc/testsuite/gcc.dg/redecl-23.c @@ -0,0 +1,6 @@ +/* We used to ICE in the gimplifier, PR 106560. */ +/* { dg-do compile } */ +/* { dg-options "-w" } */ +void **a; /* { dg-note "" } */ +void b() { void **c = a; } +a; /* { dg-error "" } */ diff --git a/gcc/testsuite/gcc.dg/redecl-24.c b/gcc/testsuite/gcc.dg/redecl-24.c new file mode 100644 index 00000000000..f0f7a723ab8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/redecl-24.c @@ -0,0 +1,6 @@ +/* We used to ICE in the gimplifier, PR 106560 */ +/* { dg-do compile } */ +/* { dg-options "-w" } */ +void **a, **b; /* { dg-note "" } */ +c(){b = a;} +a = /* { dg-error "" } */ diff --git a/gcc/testsuite/gcc.dg/redecl-25.c b/gcc/testsuite/gcc.dg/redecl-25.c new file mode 100644 index 00000000000..4232e19d9a7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/redecl-25.c @@ -0,0 +1,9 @@ +/* We used to ICE in the gimplifier, PR 106560 */ +/* { dg-do compile } */ +/* { dg-options "-w" } */ +void **a; /* { dg-note "" } */ +void b() { + void **c; + c = a /* { dg-error "" } */ +} +a; /* { dg-error "" } */