]> git.ipfire.org Git - thirdparty/gcc.git/commit
c: Restore "originally defined" struct redefinition messages for C23
authorJoseph Myers <josmyers@redhat.com>
Wed, 23 Oct 2024 00:10:01 +0000 (00:10 +0000)
committerJoseph Myers <josmyers@redhat.com>
Wed, 23 Oct 2024 00:10:01 +0000 (00:10 +0000)
commitecb55d94738b1ed36fa76d02e3454cc4959a141d
treea3699287a1353ba0ac5b821208fc36194518ebfb
parent71e13ea134b04562f8f2cdd9c4a55dbb0905f96a
c: Restore "originally defined" struct redefinition messages for C23

One failure with a -std=gnu23 default that indicates a
quality-of-implementation regression in C23 mode is gcc.dg/pr39084.c,
which loses the expected "originally defined here" message on struct
redefinition errors (which occur in a different place in the front end
for C23 because it is necessary to see the members of the struct to
determine whether the redefinition is valid).  That message seems a
good thing to have both in and out of C23 mode, so add logic to
restore it in the C23 case.

Bootstrapped with no regressions for x86-64-pc-linux-gnu.

gcc/c/
* c-decl.cc (c_struct_parse_info): Add member refloc.
(start_struct): Store refloc in struct_parse_info.
(finish_struct): Give "originally defined" message for C23 struct
redefinition errors.

gcc/testsuite/
* gcc.dg/gnu17-tag-1.c, gcc.dg/gnu23-tag-5.c: New tests.
gcc/c/c-decl.cc
gcc/testsuite/gcc.dg/gnu17-tag-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/gnu23-tag-5.c [new file with mode: 0644]