]> git.ipfire.org Git - thirdparty/gcc.git/commit
c: Fix ICE with -g and -std=c23 related to incomplete types [PR114361]
authorJakub Jelinek <jakub@redhat.com>
Fri, 19 Apr 2024 22:05:21 +0000 (00:05 +0200)
committerJakub Jelinek <jakub@redhat.com>
Fri, 19 Apr 2024 22:05:21 +0000 (00:05 +0200)
commita39983bf58d3097c472252f6989d19b60909dd9a
treedad65b4b2d5eab51977f75e08b3831bdbc6cd6ff
parentd86472a6f041ccf3d1be0cf6bb15d1e0ad8f6dbe
c: Fix ICE with -g and -std=c23 related to incomplete types [PR114361]

We did not update TYPE_CANONICAL for incomplete variants when
completing a structure.  We now set for flag_isoc23 TYPE_STRUCTURAL_EQUALITY_P
for incomplete structure and union types and then update TYPE_CANONICAL
later, though update it only for the variants and derived pointer types
which can be easily discovered.  Other derived types created while
the type was still incomplete will remain TYPE_STRUCTURAL_EQUALITY_P.
See PR114574 for discussion.

2024-04-20  Martin Uecker  <uecker@tugraz.at>
    Jakub Jelinek  <jakub@redhat.com>

PR lto/114574
PR c/114361
gcc/c/
* c-decl.cc (shadow_tag_warned): For flag_isoc23 and code not
ENUMERAL_TYPE use SET_TYPE_STRUCTURAL_EQUALITY.
(parser_xref_tag): Likewise.
(start_struct): For flag_isoc23 use SET_TYPE_STRUCTURAL_EQUALITY.
(c_update_type_canonical): New function.
(finish_struct): Put NULL as second == operand rather than first.
Assert TYPE_STRUCTURAL_EQUALITY_P.  Call c_update_type_canonical.
* c-typeck.cc (composite_type_internal): Use
SET_TYPE_STRUCTURAL_EQUALITY.  Formatting fix.
gcc/testsuite/
* gcc.dg/pr114574-1.c: New test.
* gcc.dg/pr114574-2.c: New test.
* gcc.dg/pr114361.c: New test.
* gcc.dg/c23-tag-incomplete-1.c: New test.
* gcc.dg/c23-tag-incomplete-2.c: New test.
gcc/c/c-decl.cc
gcc/c/c-typeck.cc
gcc/testsuite/gcc.dg/c23-tag-incomplete-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c23-tag-incomplete-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr114361.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr114574-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr114574-2.c [new file with mode: 0644]