]> git.ipfire.org Git - thirdparty/gcc.git/commit
c23: tag compatibility rules for struct and unions
authorMartin Uecker <uecker@tugraz.at>
Tue, 15 Aug 2023 12:58:32 +0000 (14:58 +0200)
committerMartin Uecker <uecker@tugraz.at>
Thu, 21 Dec 2023 07:43:10 +0000 (08:43 +0100)
commit23fee88f84873b0b8b41c8e5a9b229d533fb4022
tree07d8a1dfd966671d648f7af84c230d231762ab13
parent514ea1df444ca7f64c3f504ced05d8fb5fbfd62d
c23: tag compatibility rules for struct and unions

Implement redeclaration and compatibility rules for
structures and unions in C23.

gcc/c/:
* c-decl.cc (previous_tag): New function.
(parser_xref_tag): Find earlier definition.
(get_parm_info): Turn off warning for C23.
(start_struct): Allow redefinitons.
(finish_struct): Diagnose conflicts.
* c-tree.h (comptypes_same_p): Add prototype.
* c-typeck.cc (comptypes_same_p): New function.
(comptypes_internal): Activate comparison of tagged types.
(convert_for_assignment): Ignore qualifiers.
(digest_init): Add error.
(initialized_elementwise_p): Allow compatible types.

gcc/testsuite/:
* gcc.dg/c23-enum-7.c: Remove warning.
* gcc.dg/c23-tag-1.c: New test.
* gcc.dg/c23-tag-2.c: New deactivated test.
* gcc.dg/c23-tag-3.c: New test.
* gcc.dg/c23-tag-4.c: New test.
* gcc.dg/c23-tag-5.c: New deactivated test.
* gcc.dg/c23-tag-6.c: New test.
* gcc.dg/c23-tag-7.c: New test.
* gcc.dg/c23-tag-8.c: New test.
* gcc.dg/gnu23-tag-1.c: New test.
* gcc.dg/gnu23-tag-2.c: New test.
* gcc.dg/gnu23-tag-3.c: New test.
* gcc.dg/gnu23-tag-4.c: New test.
* gcc.dg/pr112488-2.c: Remove warning.
17 files changed:
gcc/c/c-decl.cc
gcc/c/c-tree.h
gcc/c/c-typeck.cc
gcc/testsuite/gcc.dg/c23-enum-7.c
gcc/testsuite/gcc.dg/c23-tag-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c23-tag-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c23-tag-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c23-tag-4.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c23-tag-5.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c23-tag-6.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c23-tag-7.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c23-tag-8.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/gnu23-tag-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/gnu23-tag-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/gnu23-tag-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/gnu23-tag-4.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr112488-2.c