From patchwork Sun Oct 15 01:16:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 152981 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp2724234vqb; Sat, 14 Oct 2023 18:18:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHMdkmI0soeef+Kx1ZOUFaXQ2VzTEVJekbt6/f/7qzeFkOsNJ3vk5+kWz6Ybo8V8rp+3dDz X-Received: by 2002:a05:620a:191c:b0:775:9bb1:9ac4 with SMTP id bj28-20020a05620a191c00b007759bb19ac4mr37905707qkb.61.1697332695625; Sat, 14 Oct 2023 18:18:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697332695; cv=pass; d=google.com; s=arc-20160816; b=Qy5eg1OaOVP3SbOGX0GLO1FoGq3uAtF8UB1JBrIGYRpTCzQ7zAhtvUjhvNY1ovbts2 mn+HzDCv5uxoN7t/4oVzDL9rR3o3MmJzxidxTh4rADA5dQHOXIccjcNvsf4MqqQc+m+T o0NR84YolWJK0Q2sXcWFW4ohyIr9twfLx7D6iBdhJyH1ZwFyotWqy6BC7qM3jZLlkv/C HC6G1ccpB05ftCbCQoSGqZx5hrvCLd3KljL+/rvz9PRHbA2Kuo13t4HOfgD8m8dEBMfi nA9Cmt1qikXtl0vp7gU22M+C1CsFKJXLoouFxxmMgXXCpWQm05YWF4XvUwzIPWSKKAEZ U9fA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dmarc-filter:arc-filter:delivered-to; bh=xVZLtylaWOiuogT9W/G5ZpQsy3KEAVtqOW+uHEKfnZU=; fh=6xfd3IYC8Zt5CA4TsXZHhPmGMhO9cjo3oiHaQc5bSUI=; b=F37svwk0uHikvfTmHCGQrQM5jmxDtiv9z++xiD9RFDUAfd913YmyLdzxF+sis6lKN/ tAkmN4GON2IqyeXmwTjSzRF69Q5Qh65JdtxJ8x7Wv/jrv5XUvByfhrBlLs9I7b1B0SVv 9xBe4XMHb2mIhafIT9L0/pR/EwFLs13sroRox1mTBl25tDRBCci11gSeCDvrh76w81zg YJS+2xnpcIzWJ7TS5hONzl5fr6KEHCa1Tv5KqxeWWXCQ/AvC8UYDyf82MRcUwNkhNvS/ 7ME6pST5CYH5V4udrmCEzInQJ7osvX+7ff40NK13bM/cnG6FrourQ6dPtNwFMrnoL8Bz Sr+Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="mIrNz/kH"; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id qj19-20020a05620a881300b007742b023d3esi3408543qkn.99.2023.10.14.18.18.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Oct 2023 18:18:15 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="mIrNz/kH"; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 65C64385842C for ; Sun, 15 Oct 2023 01:18:15 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-oo1-xc2f.google.com (mail-oo1-xc2f.google.com [IPv6:2607:f8b0:4864:20::c2f]) by sourceware.org (Postfix) with ESMTPS id B6DBD3858413 for ; Sun, 15 Oct 2023 01:16:55 +0000 (GMT) ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B6DBD3858413 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::c2f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697332618; cv=none; b=LlVOpgslavniO3jbZQVjbJGuM8AfoXgvEc6+UBGczXeX8rZHdUob/VWnH9WIfSspx1U5YGapIyTlXoX3yELGvC6gKjgjFZnK10tw9Y2gMX38uyRMS3IDWryUcXd5rdd3SLL36ZWT1tOyNMhuz50S05yIVOUbMKU6crYckxlXh1g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697332618; c=relaxed/simple; bh=Trv86ylUbrxYFRJlkmLXNMPy1iB0KfrUHQJgp5wGODM=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=bIWXzDeAffMwWFJLcoRx2AjuDOMbPoB4WHGdppCQS3W5gAyFiKXJRnNaL/Bj6x2L4bBDyQLDbSFmRSV2Tsjf6Bv/9ZTjMDbj11HdPoKeGBmfm5hvpMZX8u444Kjwf51kIFsEPwtxBGlPdB9zCwywXX5HzC4ux7CM979QCp0p33k= ARC-Authentication-Results: i=1; server2.sourceware.org DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B6DBD3858413 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oo1-xc2f.google.com with SMTP id 006d021491bc7-5815818406dso1937558eaf.2 for ; Sat, 14 Oct 2023 18:16:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697332613; x=1697937413; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=xVZLtylaWOiuogT9W/G5ZpQsy3KEAVtqOW+uHEKfnZU=; b=mIrNz/kHMGEQVY6aR90ch/GPhyEl5czODioaQabvNM8QWnWkr3k8PdGdQX2VkwLB+A 86880ejAuhmBLUHnwXybC1DYhRa0XVL8ExV/NTgZZlAnjswrTqaf+sK/AIdwNcRY9b1W uuWfunde+DS8+HrM8YMboBPAUfa/jxjBaUqGTzWlnySzOoFo1Gg4tqxMlDey+cxg8/uh CdlZbmMY/+ImVk6i9Xltzcvvnww78ZC1krvDCVdayEefhFiguL03mYsEEr90EHWhPU21 oAzaqFPGkfNDQ/2Wlx6DXWqtxTK299MNnNM7V3gSFBF7gI/GNARbRQXeOFFZmqGy0VBx zVDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697332613; x=1697937413; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=xVZLtylaWOiuogT9W/G5ZpQsy3KEAVtqOW+uHEKfnZU=; b=lAuPmqydyMo4Pg8l249oL/Mju4wfJeVGKGIjpku2LYlZYjGyvxsSlVMHP8E5wRE6/B HBmokVoAIiXoQwFV3F5Z/LMv9ct73GVJYUldOz7M3vF6ZCqYFx0vlTZ19LncCttN1dJt 5+oPrup/bzrXjKrlCI/tIMk7ZV9pQ3Qm47VFXij6VG6pBDcdBnNUCD47EH5L9wyGvOv6 1WrSGS9XjT4gsFIg4tllwNuDkWvvddjm1bJFmTqB5PB17CnInvYOXfKN5Wc2TP9WgIEN hFICzrQ10JmYEZQPZHq+bRpcvIRguSZGnE5TW4BTfw1aMGiworu6uT8gARCEPUII5UwL VaaQ== X-Gm-Message-State: AOJu0YyP/DgLsMPbxCSdh+N1jR3wEPW49FFArYDO2d87w17dVChzp03W 0z8hernZy6TN1deoyLJsVzLglzz/v/2d7Q== X-Received: by 2002:a05:6358:99a8:b0:141:d2d:6da7 with SMTP id j40-20020a05635899a800b001410d2d6da7mr32816323rwb.17.1697332612946; Sat, 14 Oct 2023 18:16:52 -0700 (PDT) Received: from xeond2.wrightpinski.org ([98.97.114.173]) by smtp.gmail.com with ESMTPSA id w24-20020aa79558000000b006b65b0f903csm2468477pfq.192.2023.10.14.18.16.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Oct 2023 18:16:52 -0700 (PDT) From: Andrew Pinski To: gcc-patches@gcc.gnu.org Cc: Andrew Pinski Subject: [PATCH 1/2] Fix ICE due to c_safe_arg_type_equiv_p not checking for error_mark node Date: Sat, 14 Oct 2023 18:16:47 -0700 Message-Id: <20231015011648.1608638-1-pinskia@gmail.com> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779782328693755878 X-GMAIL-MSGID: 1779782328693755878 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. --- gcc/c/c-typeck.cc | 3 +++ gcc/testsuite/gcc.dg/pr101285-1.c | 10 ++++++++++ 2 files changed, 13 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/pr101285-1.c diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index e55e887da14..6e044b4afbc 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 00000000000..831e35f7662 --- /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" } */ +} +