]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
dwarf2: use DW_ATE_UTF for char8_t
authorJason Merrill <jason@redhat.com>
Wed, 24 Aug 2022 20:31:04 +0000 (16:31 -0400)
committerJason Merrill <jason@redhat.com>
Thu, 25 Aug 2022 21:03:01 +0000 (17:03 -0400)
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
gcc/testsuite/g++.dg/debug/dwarf2/utf-1.C [new file with mode: 0644]

index e3920c898f5f7a1ace25cd44ed4cc30025fa35de..28a4ae08fe4c645f3ec2d4cf0af928c2cbb1a1ca 100644 (file)
@@ -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 (file)
index 0000000..43b354f
--- /dev/null
@@ -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;