Fix utf-1.C with -gdwarf-4

Resolves: #2217506
This commit is contained in:
Marek Polacek 2023-07-06 14:27:50 -04:00
parent 6277bd0049
commit 12d373f659
2 changed files with 56 additions and 1 deletions

View File

@ -149,7 +149,7 @@ BuildRequires: scl-utils-build
Summary: GCC version 13
Name: %{?scl_prefix}gcc
Version: %{gcc_version}
Release: %{gcc_release}.2%{?dist}
Release: %{gcc_release}.3%{?dist}
# libgcc, libgfortran, libgomp, libstdc++ and crtstuff have
# GCC Runtime Exception.
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD
@ -361,6 +361,7 @@ Patch3019: 0022-libstdc++-revert-behavior.patch
Patch3020: gcc13-testsuite-no-ssp.patch
Patch3021: gcc13-testsuite-p10.patch
Patch3022: gcc13-testsuite-plugin.patch
Patch3023: gcc13-testsuite-dwarf.patch
%if 0%{?rhel} == 9
%global nonsharedver 110
@ -742,6 +743,7 @@ rm -f libphobos/testsuite/libphobos.gc/forkgc2.d
%patch -P3020 -p1 -b .dts-test-20~
%patch -P3021 -p1 -b .dts-test-21~
%patch -P3022 -p1 -b .dts-test-22~
%patch -P3023 -p1 -b .dts-test-23~
find gcc/testsuite -name \*.pr96939~ | xargs rm -f
@ -2904,6 +2906,9 @@ fi
%endif
%changelog
* Thu Jul 6 2023 Marek Polacek <polacek@redhat.com> 13.1.1-4.3
- fix utf-1.C with -gdwarf-4 (#2217506)
* Tue Jun 27 2023 Marek Polacek <polacek@redhat.com> 13.1.1-4.2
- fix switch to -gdwarf-4 on RHEL 8 (#2217938)
- apply some testsuite fixes (#2217506)

View File

@ -0,0 +1,50 @@
commit b6532d0edd50a6086a84ca748fe49c5a9d28f155
Author: Marek Polacek <polacek@redhat.com>
Date: Wed Jul 5 17:43:31 2023 -0400
testsuite: fix dwarf2/utf-1.C with DWARF4
Running
$ make check-c++ RUNTESTFLAGS='--target_board=unix\{-gdwarf-5,-gdwarf-4\} dwarf2.exp=utf-1.C'
shows
FAIL: g++.dg/debug/dwarf2/utf-1.C -std=gnu++20 scan-assembler-times DW_AT_encoding \\(0x10\\) 3
because with -gdwarf-4 the output is:
.byte 0x10 # DW_AT_encoding
but with -gdwarf-5 the output is the expected:
# DW_AT_encoding (0x10)
The difference is caused by the DWARF5 optimize_implicit_const
optimization:
<https://gcc.gnu.org/pipermail/gcc-patches/2016-October/459762.html>
I suppose we could do what testsuite/rust/debug/chartype.rs does
and just run the test with -gdwarf-4.
gcc/testsuite/ChangeLog:
* g++.dg/debug/dwarf2/utf-1.C: Use -gdwarf-4. Adjust expected
output.
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/utf-1.C b/gcc/testsuite/g++.dg/debug/dwarf2/utf-1.C
index 43b354f1bb5..0ce4d8727d6 100644
--- a/gcc/testsuite/g++.dg/debug/dwarf2/utf-1.C
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/utf-1.C
@@ -1,8 +1,13 @@
// { dg-do compile { target c++20 } }
-// { dg-options { -gdwarf -dA } }
+// { dg-options { -gdwarf-4 -dA } }
// Test that all three use DW_ATE_UTF.
-// { dg-final { scan-assembler-times {DW_AT_encoding \(0x10\)} 3 } }
+// This test uses -gdwarf-4 since in DWARF5 optimize_implicit_const
+// would optimize the output from:
+// .byte 0x10 # DW_AT_encoding
+// into:
+// # DW_AT_encoding (0x10)
+// { dg-final { scan-assembler-times "0x10\[ \t]\[^\n\r]* DW_AT_encoding" 3 } }
char8_t c8;
char16_t c16;