From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1924) id 92D733860753; Wed, 31 Jan 2024 19:56:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 92D733860753 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706730973; bh=ZVkDJfM5nBQix7EATUyVRoVwVZGlMUJmoBK4WmdhZkU=; h=From:To:Subject:Date:From; b=exvefyiZWzS1+Y6O0UlCjHSC0AFS9RZSn4VGtrf/fp95S9BQ4CUbxb3wTer2By3oS ZmW45aN1mcTI6fcFJLAsFHc3p9Fgaj4tyierupwSoJDRnEj4noQMRKGiPm++V/n833 Qtifxx2HtlPtAqs2f2aXsSuwGaJxGCMkEB4KLYdM= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Martin Uecker To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-8666] Fix ICE with -g and -std=c23 when forming composite types [PR113438] X-Act-Checkin: gcc X-Git-Author: Martin Uecker X-Git-Refname: refs/heads/master X-Git-Oldrev: 3fed1609f61088c4e607d6987d86579f684bf4dc X-Git-Newrev: f6ba433d3c30c20fadd393eed31617a4da81789c Message-Id: <20240131195613.92D733860753@sourceware.org> Date: Wed, 31 Jan 2024 19:56:13 +0000 (GMT) List-Id: https://gcc.gnu.org/g:f6ba433d3c30c20fadd393eed31617a4da81789c commit r14-8666-gf6ba433d3c30c20fadd393eed31617a4da81789c Author: Martin Uecker Date: Tue Jan 23 13:33:34 2024 +0100 Fix ICE with -g and -std=c23 when forming composite types [PR113438] Set TYPE_STUB_DECL to an artificial decl when creating a new structure as a composite type. PR c/113438 gcc/c/ * c-typeck.cc (composite_type_internal): Set TYPE_STUB_DECL. gcc/testsuite/ * gcc.dg/pr113438.c: New test. Diff: --- gcc/c/c-typeck.cc | 5 +++++ gcc/testsuite/gcc.dg/pr113438.c | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index 12d1a5a5fa19..3b519c48ae0a 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -585,6 +585,11 @@ composite_type_internal (tree t1, tree t2, struct composite_cache* cache) /* Setup the struct/union type. Because we inherit all variably modified components, we can ignore the size expression. */ tree expr = NULL_TREE; + + /* Set TYPE_STUB_DECL for debugging symbols. */ + TYPE_STUB_DECL (n) = pushdecl (build_decl (input_location, TYPE_DECL, + NULL_TREE, n)); + n = finish_struct(input_location, n, fields, attributes, NULL, &expr); n = qualify_type (n, t1); diff --git a/gcc/testsuite/gcc.dg/pr113438.c b/gcc/testsuite/gcc.dg/pr113438.c new file mode 100644 index 000000000000..5612ee4fa385 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr113438.c @@ -0,0 +1,7 @@ +/* PR113438 + * { dg-do compile } + * { dg-options "-std=c23 -g" } */ + +void g(struct foo { int x; } a); +void g(struct foo { int x; } a); +