From patchwork Tue Jun 18 15:19:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Uecker X-Patchwork-Id: 1949242 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=tugraz.at header.i=@tugraz.at header.a=rsa-sha256 header.s=mailrelay header.b=SSJsSJRq; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W3Vmz5vP5z20KL for ; Wed, 19 Jun 2024 01:20:19 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 49C0A3882AF7 for ; Tue, 18 Jun 2024 15:20:17 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mailrelay.tugraz.at (mailrelay.tugraz.at [129.27.2.202]) by sourceware.org (Postfix) with ESMTPS id 54EF23882AC6 for ; Tue, 18 Jun 2024 15:19:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 54EF23882AC6 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=tugraz.at Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tugraz.at ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 54EF23882AC6 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=129.27.2.202 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718723996; cv=none; b=EQVfW89Z1Xzpm4cDW5KvBjvQNNzuFbebG6OFw5q1zXUkSvysGEZixkYUA/1dS64DumxcUxCtPXcgS3zntJ9/YxZhxoBEEut7rvyiF4zE3BGRZ69VdIACiHOBxmCYae4FujHygAZxXRgzJiIY3H0Hzp2B+qBqopDJY/Ecw6Wy6XU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718723996; c=relaxed/simple; bh=9PJmYfNaU3aG9m7eAUMycLMRdiByZ5tzh+jBqJo4nrM=; h=DKIM-Signature:Message-ID:Subject:From:To:Date:MIME-Version; b=WZUtrVAcCss3EYBEvjY2dNSw4XH9ZbEF5QQkpe+NxbIM8QhJy1qwaaAg4ssSVm10DNCV6+g0+oBhVBv2cJXyuBwUGV16uOq10cnEmKUkiYlAFb445Pdqdvst2uZU/hf6Vcvu85lv/qErcaSX7ud4GOEfiN2JEhL9MrTLHWRLCiQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from vra-168-67.tugraz.at (vra-168-67.tugraz.at [129.27.168.67]) by mailrelay.tugraz.at (Postfix) with ESMTPSA id 4W3VmH4mwPz3wD1; Tue, 18 Jun 2024 17:19:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tugraz.at; s=mailrelay; t=1718723983; bh=jJZW4eU4oeqOthc+6cza6jB3AWdDLfYWdQyZGMJBBew=; h=Subject:From:To:Cc:Date; b=SSJsSJRq50BLDHJUBY1cUTrgLPupCNhs667ALECQjIhPTfIQS+6epSCY1Z8mZ3pvY 8v3wW5W3+aLibjHXfhG6jgN7WEnEdD0tT3J0bBX+CfDQpv2OBWCrMpRVQ9g2sv949d z5BNWHcvKG7J/Tavi/UlnzE55WlGrRpmNqhcq8Ms= Message-ID: <740a0212f71eb64732ae481f77952b68ab2e7ca8.camel@tugraz.at> Subject: [C PATCH] Fix ICE related to incomplete structures in C23 [PR114930,PR115502]. From: Martin Uecker To: gcc-patches@gcc.gnu.org Cc: Joseph Myers , Jakub Jelinek , Richard Biener Date: Tue, 18 Jun 2024 17:19:43 +0200 User-Agent: Evolution 3.46.4-2 MIME-Version: 1.0 X-TUG-Backscatter-control: G/VXY7/6zeyuAY/PU2/0qw X-Spam-Scanner: SpamAssassin 3.003001 X-Spam-Score-relay: -1.9 X-Scanned-By: MIMEDefang 2.74 on 129.27.10.116 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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+incoming=patchwork.ozlabs.org@gcc.gnu.org As discussed this replaces the use of check_qualified_type with a simple check for qualifiers as suggested by Jakub in c_update_type_canonical. Martin Bootstrapped and regression tested on x86_64. C23: Fix ICE related to incomplete structures [PR114930,PR115502]. The fix for PR114574 needs to be further revised because check_qualified_type makes decision based on TYPE_NAME which can be incorrect for C when there are TYPE_DECLS involved. gcc/c/: * c-decl.c (c_update_type_canonical): Do not use check_qualified_type. gcc/testsuite/: * gcc.dg/pr114930.c: New test. * gcc.dg/pr115502.c: New test. diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc index 01326570e2b..610061a07f8 100644 --- a/gcc/c/c-decl.cc +++ b/gcc/c/c-decl.cc @@ -9374,7 +9374,7 @@ c_update_type_canonical (tree t) if (TYPE_QUALS (x) == TYPE_QUALS (t)) TYPE_CANONICAL (x) = TYPE_CANONICAL (t); else if (TYPE_CANONICAL (t) != t - || check_qualified_type (x, t, TYPE_QUALS (x))) + || TYPE_QUALS (x) != TYPE_QUALS (TYPE_CANONICAL (t))) TYPE_CANONICAL (x) = build_qualified_type (TYPE_CANONICAL (t), TYPE_QUALS (x)); else diff --git a/gcc/testsuite/gcc.dg/pr114930.c b/gcc/testsuite/gcc.dg/pr114930.c new file mode 100644 index 00000000000..5e982fb8929 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr114930.c @@ -0,0 +1,9 @@ +/* { dg-do compile } + * { dg-options "-std=c23 -flto" } */ + +typedef struct WebPPicture WebPPicture; +typedef int (*WebPProgressHook)(const WebPPicture *); +WebPProgressHook progress_hook; +struct WebPPicture { +} WebPGetColorPalette(const struct WebPPicture *); + diff --git a/gcc/testsuite/gcc.dg/pr115502.c b/gcc/testsuite/gcc.dg/pr115502.c new file mode 100644 index 00000000000..02b52622c5a --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr115502.c @@ -0,0 +1,9 @@ +/* { dg-do compile } + * { dg-options "-std=c23 -flto" } */ + +typedef struct _OSet OSet; +typedef OSet AvlTree; +void vgPlain_OSetGen_Lookup(const OSet *); +struct _OSet {}; +void vgPlain_OSetGen_Lookup(const AvlTree *); +