aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2024-03-11 09:24:50 +0100
committerEric Botcazou <ebotcazou@adacore.com>2024-03-11 09:30:05 +0100
commit0c4df2c3c38ca15c123e9a801b617e63256c83a3 (patch)
tree18dcf139e697360be464f6386b78d5a730140944
parent31ce2e993d09dcad1ce139a2848a28de5931056d (diff)
downloadgcc-0c4df2c3c38ca15c123e9a801b617e63256c83a3.zip
gcc-0c4df2c3c38ca15c123e9a801b617e63256c83a3.tar.gz
gcc-0c4df2c3c38ca15c123e9a801b617e63256c83a3.tar.bz2
Fix placement of recently implemented DIE
It's the DIE added for enumeration types with reverse scalar storage order. gcc/ PR debug/113519 PR debug/113777 * dwarf2out.cc (gen_enumeration_type_die): In the reverse case, generate the DIE with the same parent as in the regular case. gcc/testsuite/ * gcc.dg/sso-20.c: New test. * gcc.dg/sso-21.c: Likewise.
-rw-r--r--gcc/dwarf2out.cc7
-rw-r--r--gcc/testsuite/gcc.dg/sso-20.c19
-rw-r--r--gcc/testsuite/gcc.dg/sso-21.c19
3 files changed, 42 insertions, 3 deletions
diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc
index 87e4240..8f18bc4 100644
--- a/gcc/dwarf2out.cc
+++ b/gcc/dwarf2out.cc
@@ -22868,18 +22868,19 @@ gen_enumeration_type_die (tree type, dw_die_ref context_die, bool reverse)
if (type_die == NULL || reverse)
{
+ dw_die_ref scope_die = scope_die_for (type, context_die);
+
/* The DIE with DW_AT_endianity is placed right after the naked DIE. */
if (reverse)
{
gcc_assert (type_die);
dw_die_ref after_die = type_die;
type_die = new_die_raw (DW_TAG_enumeration_type);
- add_child_die_after (context_die, type_die, after_die);
+ add_child_die_after (scope_die, type_die, after_die);
}
else
{
- type_die = new_die (DW_TAG_enumeration_type,
- scope_die_for (type, context_die), type);
+ type_die = new_die (DW_TAG_enumeration_type, scope_die, type);
equate_type_number_to_die (type, type_die);
}
add_name_attribute (type_die, type_tag (type));
diff --git a/gcc/testsuite/gcc.dg/sso-20.c b/gcc/testsuite/gcc.dg/sso-20.c
new file mode 100644
index 0000000..3bea384
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/sso-20.c
@@ -0,0 +1,19 @@
+/* PR debug/113519 */
+/* Reported by Zdenek Sojka <zsojka@seznam.cz> */
+
+/* { dg-do compile } */
+/* { dg-options "-g -fdebug-types-section" } */
+
+enum E { X };
+
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+struct __attribute__((scalar_storage_order("big-endian")))
+{
+ enum E e;
+} S;
+#else
+struct __attribute__((scalar_storage_order("little-endian")))
+{
+ enum E e;
+} S;
+#endif
diff --git a/gcc/testsuite/gcc.dg/sso-21.c b/gcc/testsuite/gcc.dg/sso-21.c
new file mode 100644
index 0000000..4b5d76d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/sso-21.c
@@ -0,0 +1,19 @@
+/* PR debug/113777 */
+/* Reported by Zdenek Sojka <zsojka@seznam.cz> */
+
+/* { dg-do compile } */
+/* { dg-options "-g" } */
+
+typedef short __attribute__((__hardbool__)) hbool;
+
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+struct __attribute__((scalar_storage_order("big-endian")))
+{
+ hbool a[2];
+} S;
+#else
+struct __attribute__((scalar_storage_order("little-endian")))
+{
+ hbool a[2];
+} S;
+#endif