aboutsummaryrefslogtreecommitdiff
path: root/gcc/d
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2025-04-16 01:28:53 +0200
committerIain Buclaw <ibuclaw@gdcproject.org>2025-04-16 01:44:27 +0200
commitc5ffab99a5a962aa955310e74ca0a4be5c1acf30 (patch)
treed6477664e3768523d1e458c65dcc13a78145c2f1 /gcc/d
parenta6f4178d0d5a51c0de175d282f693f923ffefa27 (diff)
downloadgcc-c5ffab99a5a962aa955310e74ca0a4be5c1acf30.zip
gcc-c5ffab99a5a962aa955310e74ca0a4be5c1acf30.tar.gz
gcc-c5ffab99a5a962aa955310e74ca0a4be5c1acf30.tar.bz2
d: Fix ICE: type variant differs by TYPE_MAX_VALUE with -g [PR119826]
Forward referenced enum types were never fixed up after the main ENUMERAL_TYPE was finished. All flags set are now propagated to all variants after its mode, size, and alignment has been calculated. PR d/119826 gcc/d/ChangeLog: * types.cc (TypeVisitor::visit (TypeEnum *)): Propagate flags of main enum types to all forward-referenced variants. gcc/testsuite/ChangeLog: * gdc.dg/debug/imports/pr119826b.d: New test. * gdc.dg/debug/pr119826.d: New test.
Diffstat (limited to 'gcc/d')
-rw-r--r--gcc/d/types.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/d/types.cc b/gcc/d/types.cc
index e43fa88..1c74840 100644
--- a/gcc/d/types.cc
+++ b/gcc/d/types.cc
@@ -1179,6 +1179,26 @@ public:
layout_type (t->ctype);
+ /* Fix up all forward-referenced variants of this enum type. */
+ for (tree v = TYPE_MAIN_VARIANT (t->ctype); v;
+ v = TYPE_NEXT_VARIANT (v))
+ {
+ if (v == t->ctype)
+ continue;
+
+ TYPE_VALUES (v) = TYPE_VALUES (t->ctype);
+ TYPE_LANG_SPECIFIC (v) = TYPE_LANG_SPECIFIC (t->ctype);
+ TYPE_MIN_VALUE (v) = TYPE_MIN_VALUE (t->ctype);
+ TYPE_MAX_VALUE (v) = TYPE_MAX_VALUE (t->ctype);
+ TYPE_UNSIGNED (v) = TYPE_UNSIGNED (t->ctype);
+ TYPE_SIZE (v) = TYPE_SIZE (t->ctype);
+ TYPE_SIZE_UNIT (v) = TYPE_SIZE_UNIT (t->ctype);
+ SET_TYPE_MODE (v, TYPE_MODE (t->ctype));
+ TYPE_PRECISION (v) = TYPE_PRECISION (t->ctype);
+ SET_TYPE_ALIGN (v, TYPE_ALIGN (t->ctype));
+ TYPE_USER_ALIGN (v) = TYPE_USER_ALIGN (t->ctype);
+ }
+
/* Complete forward-referenced fields of this enum type. */
finish_incomplete_fields (t->ctype);
}