From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1314) id 6DCCD38582B0; Wed, 18 Oct 2023 22:35:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6DCCD38582B0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1697668504; bh=3n6RIp/OejTmXUDHjjTgVEAAS3m0Ep4XTrS+LZdBLjI=; h=From:To:Subject:Date:From; b=nS4FopHAkHj3hQu1ZmmeeoDz/MW+tF7xE5WP3r9GPGgLq5ndk3HBLcYxEm2GX2V05 QgxOQ2HRJJmU6wpZ1QCAwPwbZmrWLWbLnkOgRUDZ7KwYP5wKTybhXxp79plFSG7v+l g4LChf0734PEjKu6//cZ40DI8pqhfnQMd9HtFCoQ= 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 r14-4727] Fix ICE due to c_safe_arg_type_equiv_p not checking for error_mark node X-Act-Checkin: gcc X-Git-Author: Andrew Pinski X-Git-Refname: refs/heads/trunk X-Git-Oldrev: 3ec8ecb8e92faec889bc6f7aeac9ff59e82b4f7f X-Git-Newrev: 11e6bcedb41359c69ee790f38b04033d236336a8 Message-Id: <20231018223504.6DCCD38582B0@sourceware.org> Date: Wed, 18 Oct 2023 22:35:04 +0000 (GMT) List-Id: https://gcc.gnu.org/g:11e6bcedb41359c69ee790f38b04033d236336a8 commit r14-4727-g11e6bcedb41359c69ee790f38b04033d236336a8 Author: Andrew Pinski Date: Sat Oct 14 13:18:00 2023 -0700 Fix ICE due to c_safe_arg_type_equiv_p not checking for error_mark node This is a simple error recovery issue when c_safe_arg_type_equiv_p was added in r8-5312-gc65e18d3331aa999. The issue is that after an error, an argument type (of a function type) might turn into an error mark node and c_safe_arg_type_equiv_p was not ready for that. So this just adds a check for error operand for its arguments before getting the main variant. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. PR c/101285 gcc/c/ChangeLog: * c-typeck.cc (c_safe_arg_type_equiv_p): Return true for error operands early. gcc/testsuite/ChangeLog: * gcc.dg/pr101285-1.c: New test. Diff: --- gcc/c/c-typeck.cc | 3 +++ gcc/testsuite/gcc.dg/pr101285-1.c | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index e55e887da146..6e044b4afbc9 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -5960,6 +5960,9 @@ handle_warn_cast_qual (location_t loc, tree type, tree otype) static bool c_safe_arg_type_equiv_p (tree t1, tree t2) { + if (error_operand_p (t1) || error_operand_p (t2)) + return true; + t1 = TYPE_MAIN_VARIANT (t1); t2 = TYPE_MAIN_VARIANT (t2); diff --git a/gcc/testsuite/gcc.dg/pr101285-1.c b/gcc/testsuite/gcc.dg/pr101285-1.c new file mode 100644 index 000000000000..831e35f76629 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr101285-1.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-W -Wall" } */ +const int b; +typedef void (*ft1)(int[b++]); /* { dg-error "read-only variable" } */ +void bar(int * z); +void baz() +{ + (ft1) bar; /* { dg-warning "statement with no effect" } */ +} +