[pushed] dwarf2: use DW_ATE_UTF for C++ char8_t

Message ID 20220825210247.2217333-1-jason@redhat.com
State New, archived
Headers
Series [pushed] dwarf2: use DW_ATE_UTF for C++ char8_t |

Commit Message

Jason Merrill Aug. 25, 2022, 9:02 p.m. UTC
  While looking at the Rust changes to dwarf2out I noticed that this was
missing from the char8_t support.

gcc/ChangeLog:

	* dwarf2out.cc (base_type_die): Also use DW_ATE_UTF for char8_t.

gcc/testsuite/ChangeLog:

	* g++.dg/debug/dwarf2/utf-1.C: New test.
---
 gcc/dwarf2out.cc                          | 1 +
 gcc/testsuite/g++.dg/debug/dwarf2/utf-1.C | 9 +++++++++
 2 files changed, 10 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/utf-1.C


base-commit: 585a21bab3ec688c2039bff2922cc372d8558283
  

Patch

diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc
index e3920c898f5..28a4ae08fe4 100644
--- a/gcc/dwarf2out.cc
+++ b/gcc/dwarf2out.cc
@@ -13210,6 +13210,7 @@  base_type_die (tree type, bool reverse)
 	{
 	  const char *name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
 	  if (strcmp (name, "char16_t") == 0
+	      || strcmp (name, "char8_t") == 0
 	      || strcmp (name, "char32_t") == 0)
 	    {
 	      encoding = DW_ATE_UTF;
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/utf-1.C b/gcc/testsuite/g++.dg/debug/dwarf2/utf-1.C
new file mode 100644
index 00000000000..43b354f1bb5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/utf-1.C
@@ -0,0 +1,9 @@ 
+// { dg-do compile { target c++20 } }
+// { dg-options { -gdwarf -dA } }
+
+// Test that all three use DW_ATE_UTF.
+// { dg-final { scan-assembler-times {DW_AT_encoding \(0x10\)} 3 } }
+
+char8_t c8;
+char16_t c16;
+char32_t c32;