aboutsummaryrefslogtreecommitdiff
path: root/gcc/c/c-decl.cc
diff options
context:
space:
mode:
authorMartin Uecker <uecker@tugraz.at>2023-08-20 14:08:23 +0200
committerMartin Uecker <uecker@tugraz.at>2023-12-22 21:12:21 +0100
commit8c8d4b565cd7e08c6ec9ca5a4369d8ec5619cad8 (patch)
treec1326e0c758bcd518b312a59431196c37fab548c /gcc/c/c-decl.cc
parent3dd45dee7f52f301f4bf8bec153b9c5c104294cc (diff)
downloadgcc-8c8d4b565cd7e08c6ec9ca5a4369d8ec5619cad8.zip
gcc-8c8d4b565cd7e08c6ec9ca5a4369d8ec5619cad8.tar.gz
gcc-8c8d4b565cd7e08c6ec9ca5a4369d8ec5619cad8.tar.bz2
c23: construct composite type for tagged types
Support for constructing composite types for structs and unions in C23. gcc/c: * c-typeck.cc (composite_type_internal): Adapted from composite_type to support structs and unions. (composite_type): New wrapper function. (build_conditional_operator): Return composite type. * c-decl.cc (finish_struct): Allow NULL for enclosing_struct_parse_info. gcc/testsuite: * gcc.dg/c23-tag-alias-6.c: New test. * gcc.dg/c23-tag-alias-7.c: New test. * gcc.dg/c23-tag-composite-1.c: New test. * gcc.dg/c23-tag-composite-2.c: New test. * gcc.dg/c23-tag-composite-3.c: New test. * gcc.dg/c23-tag-composite-4.c: New test. * gcc.dg/c23-tag-composite-5.c: New test. * gcc.dg/c23-tag-composite-6.c: New test. * gcc.dg/c23-tag-composite-7.c: New test. * gcc.dg/c23-tag-composite-8.c: New test. * gcc.dg/c23-tag-composite-9.c: New test. * gcc.dg/c23-tag-composite-10.c: New test. * gcc.dg/gnu23-tag-composite-1.c: New test. * gcc.dg/gnu23-tag-composite-2.c: New test. * gcc.dg/gnu23-tag-composite-3.c: New test. * gcc.dg/gnu23-tag-composite-4.c: New test. * gcc.dg/gnu23-tag-composite-5.c: New test.
Diffstat (limited to 'gcc/c/c-decl.cc')
-rw-r--r--gcc/c/c-decl.cc21
1 files changed, 12 insertions, 9 deletions
diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc
index 6639ec3..b72738e 100644
--- a/gcc/c/c-decl.cc
+++ b/gcc/c/c-decl.cc
@@ -9674,7 +9674,7 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,
}
/* Check for consistency with previous definition. */
- if (flag_isoc23)
+ if (flag_isoc23 && NULL != enclosing_struct_parse_info)
{
tree vistype = previous_tag (t);
if (vistype
@@ -9744,16 +9744,19 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,
if (warn_cxx_compat)
warn_cxx_compat_finish_struct (fieldlist, TREE_CODE (t), loc);
- delete struct_parse_info;
+ if (NULL != enclosing_struct_parse_info)
+ {
+ delete struct_parse_info;
- struct_parse_info = enclosing_struct_parse_info;
+ struct_parse_info = enclosing_struct_parse_info;
- /* If this struct is defined inside a struct, add it to
- struct_types. */
- if (warn_cxx_compat
- && struct_parse_info != NULL
- && !in_sizeof && !in_typeof && !in_alignof)
- struct_parse_info->struct_types.safe_push (t);
+ /* If this struct is defined inside a struct, add it to
+ struct_types. */
+ if (warn_cxx_compat
+ && struct_parse_info != NULL
+ && !in_sizeof && !in_typeof && !in_alignof)
+ struct_parse_info->struct_types.safe_push (t);
+ }
return t;
}