diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc index 5d64100b95c..03d73f9eecd 100644 --- a/gcc/dwarf2out.cc +++ b/gcc/dwarf2out.cc @@ -8215,6 +8215,15 @@ should_move_die_to_comdat (dw_die_ref die) || is_nested_in_subprogram (die) || contains_subprogram_definition (die)) return false; + if (die->die_tag != DW_TAG_enumeration_type) + { + /* Don't move non-constant size aggregates. */ + dw_attr_node *sz = get_AT (die, DW_AT_byte_size); + if (sz == NULL + || (AT_class (sz) != dw_val_class_unsigned_const + && AT_class (sz) != dw_val_class_unsigned_const_implicit)) + return false; + } return true; case DW_TAG_array_type: case DW_TAG_interface_type: diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/pr114015.c b/gcc/testsuite/gcc.dg/debug/dwarf2/pr114015.c new file mode 100644 index 00000000000..a184ab5d392 --- /dev/null +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/pr114015.c @@ -0,0 +1,14 @@ +/* PR debug/114015 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-g -fvar-tracking-assignments -fdebug-types-section -w" } */ + +#if __BITINT_MAXWIDTH__ >= 236 +typedef _BitInt(236) B; +#else +typedef _BitInt(63) B; +#endif + +int +foo (B n, struct { char a[n]; } o) +{ +}