aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2023-08-21 10:34:30 +0200
committerRichard Biener <rguenther@suse.de>2024-06-21 11:21:19 +0200
commit80ded4e8f871c98481bab912997034b9d24b1c96 (patch)
treeb958b38d692e4014f85630f400a77602d7c019aa
parentce653fa683643d4e5a7146181954358f1060dfed (diff)
downloadgcc-80ded4e8f871c98481bab912997034b9d24b1c96.zip
gcc-80ded4e8f871c98481bab912997034b9d24b1c96.tar.gz
gcc-80ded4e8f871c98481bab912997034b9d24b1c96.tar.bz2
debug/111080 - avoid outputting debug info for unused restrict qualified type
The following applies some maintainance with respect to type qualifiers and kinds added by later DWARF standards to prune_unused_types_walk. The particular case in the bug is not handling (thus marking required) all restrict qualified type DIEs. I've found more DW_TAG_*_type that are unhandled, looked up the DWARF docs and added them as well based on common sense. PR debug/111080 * dwarf2out.c (prune_unused_types_walk): Handle DW_TAG_restrict_type, DW_TAG_shared_type, DW_TAG_atomic_type, DW_TAG_immutable_type, DW_TAG_coarray_type, DW_TAG_unspecified_type and DW_TAG_dynamic_type as to only output them when referenced. * gcc.dg/debug/dwarf2/pr111080.c: New testcase.
-rw-r--r--gcc/dwarf2out.c7
-rw-r--r--gcc/testsuite/gcc.dg/debug/dwarf2/pr111080.c18
2 files changed, 25 insertions, 0 deletions
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index b276665..3d8e0e6 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -29693,8 +29693,13 @@ prune_unused_types_walk (dw_die_ref die)
case DW_TAG_reference_type:
case DW_TAG_rvalue_reference_type:
case DW_TAG_volatile_type:
+ case DW_TAG_restrict_type:
+ case DW_TAG_shared_type:
+ case DW_TAG_atomic_type:
+ case DW_TAG_immutable_type:
case DW_TAG_typedef:
case DW_TAG_array_type:
+ case DW_TAG_coarray_type:
case DW_TAG_friend:
case DW_TAG_enumeration_type:
case DW_TAG_subroutine_type:
@@ -29703,6 +29708,8 @@ prune_unused_types_walk (dw_die_ref die)
case DW_TAG_subrange_type:
case DW_TAG_ptr_to_member_type:
case DW_TAG_file_type:
+ case DW_TAG_unspecified_type:
+ case DW_TAG_dynamic_type:
/* Type nodes are useful only when other DIEs reference them --- don't
mark them. */
/* FALLTHROUGH */
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/pr111080.c b/gcc/testsuite/gcc.dg/debug/dwarf2/pr111080.c
new file mode 100644
index 0000000..3949d7e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/pr111080.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-save-temps -gdwarf-3 -dA" } */
+
+struct foo {
+ int field_number_1;
+ int field_number_2;
+ int field_number_3;
+ int field_number_4;
+ int field_number_5;
+};
+
+typedef int fun_t(struct foo *restrict);
+
+int main() {
+ return 0;
+}
+
+/* { dg-final { scan-assembler-not "DW_TAG_structure_type" } } */