diff options
author | Martin Uecker <uecker@tugraz.at> | 2023-08-15 23:16:35 +0200 |
---|---|---|
committer | Martin Uecker <uecker@tugraz.at> | 2023-12-21 08:43:16 +0100 |
commit | ced651b7757e6ef7e7e309f022cd71b4b6ead295 (patch) | |
tree | ab0b4edd016dcb1f3942777bb3cc25c6f999e553 /gcc/c/c-tree.h | |
parent | 23fee88f84873b0b8b41c8e5a9b229d533fb4022 (diff) | |
download | gcc-ced651b7757e6ef7e7e309f022cd71b4b6ead295.zip gcc-ced651b7757e6ef7e7e309f022cd71b4b6ead295.tar.gz gcc-ced651b7757e6ef7e7e309f022cd71b4b6ead295.tar.bz2 |
c23: tag compatibility rules for enums
Allow redefinition of enum types and enumerators. Diagnose
nested redefinitions including redefinitions in the enum
specifier for enum types with fixed underlying type.
gcc/c:
* c-tree.h (c_parser_enum_specifier): Add parameter.
* c-decl.cc (start_enum): Allow redefinition.
(finish_enum): Diagnose conflicts.
(build_enumerator): Set context.
(diagnose_mismatched_decls): Diagnose conflicting enumerators.
(push_decl): Preserve context for enumerators.
* c-typeck.cc (tagged_types_tu_compatible_p): Adapt.
* c-parser.cc (c_parser_enum_specifier): Remember when
seen is from an enum type which is not yet defined.
gcc/testsuite:
* gcc.dg/c23-tag-enum-1.c: New test.
* gcc.dg/c23-tag-enum-2.c: New test.
* gcc.dg/c23-tag-enum-3.c: New test.
* gcc.dg/c23-tag-enum-4.c: New test.
* gcc.dg/c23-tag-enum-5.c: New test.
* gcc.dg/gnu23-tag-enum-1.c: Mew test.
Diffstat (limited to 'gcc/c/c-tree.h')
-rw-r--r-- | gcc/c/c-tree.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h index e53948f..54f1353 100644 --- a/gcc/c/c-tree.h +++ b/gcc/c/c-tree.h @@ -683,7 +683,8 @@ extern void c_warn_unused_attributes (tree); extern tree c_warn_type_attributes (tree); extern void shadow_tag (const struct c_declspecs *); extern void shadow_tag_warned (const struct c_declspecs *, int); -extern tree start_enum (location_t, struct c_enum_contents *, tree, tree); +extern tree start_enum (location_t, struct c_enum_contents *, tree, tree, + bool potential_nesting_p); extern bool start_function (struct c_declspecs *, struct c_declarator *, tree); extern tree start_decl (struct c_declarator *, struct c_declspecs *, bool, tree, bool = true, location_t * = NULL); |