aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-06-18 13:13:01 -0600
committerTom Tromey <tom@tromey.com>2021-06-18 13:47:51 -0600
commit231de190d1c8666748eb1c346d22c73946aba743 (patch)
treeaf6862493d16f88c204951bbe2b4e785a6dd715a
parente200b89c0f62df1b1dd76c75ccfb90ea82fbb7e5 (diff)
downloadgcc-231de190d1c8666748eb1c346d22c73946aba743.zip
gcc-231de190d1c8666748eb1c346d22c73946aba743.tar.gz
gcc-231de190d1c8666748eb1c346d22c73946aba743.tar.bz2
Use correct DWARF encoding for i8 and u8 types
Currently, the i8 and u8 types use the DWARF character encoding, like: <1><113>: Abbrev Number: 3 (DW_TAG_base_type) <114> DW_AT_byte_size : 1 <115> DW_AT_encoding : 8 (unsigned char) <116> DW_AT_name : u8 This happens because gccrs uses signed_char_type_node and unsigned_char_type_node for i8 and u8, respectively. This patch fixes this problem by arranging to use a custom integer type instead. Another option is to clear TYPE_STRING_FLAG on these types, but it was unclear to me whether this would impact other parts of GCC.
-rw-r--r--gcc/rust/rust-gcc.cc6
-rw-r--r--gcc/testsuite/rust/debug/i8u8.rs12
2 files changed, 13 insertions, 5 deletions
diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
index ed89c94..e6c8858 100644
--- a/gcc/rust/rust-gcc.cc
+++ b/gcc/rust/rust-gcc.cc
@@ -1,5 +1,5 @@
// rust-gcc.cc -- Rust frontend to gcc IR.
-// Copyright (C) 2011-2020 Free Software Foundation, Inc.
+// Copyright (C) 2011-2021 Free Software Foundation, Inc.
// Contributed by Ian Lance Taylor, Google.
// forked from gccgo
@@ -867,8 +867,6 @@ Gcc_backend::integer_type (bool is_unsigned, int bits)
{
if (bits == INT_TYPE_SIZE)
type = unsigned_type_node;
- else if (bits == CHAR_TYPE_SIZE)
- type = unsigned_char_type_node;
else if (bits == SHORT_TYPE_SIZE)
type = short_unsigned_type_node;
else if (bits == LONG_TYPE_SIZE)
@@ -882,8 +880,6 @@ Gcc_backend::integer_type (bool is_unsigned, int bits)
{
if (bits == INT_TYPE_SIZE)
type = integer_type_node;
- else if (bits == CHAR_TYPE_SIZE)
- type = signed_char_type_node;
else if (bits == SHORT_TYPE_SIZE)
type = short_integer_type_node;
else if (bits == LONG_TYPE_SIZE)
diff --git a/gcc/testsuite/rust/debug/i8u8.rs b/gcc/testsuite/rust/debug/i8u8.rs
new file mode 100644
index 0000000..8f0dd19
--- /dev/null
+++ b/gcc/testsuite/rust/debug/i8u8.rs
@@ -0,0 +1,12 @@
+// i8 and u8 types should not have the DWARF 'char' encoding.
+fn main () {
+ let x : i8 = 5;
+ let y : u8 = 7;
+// { dg-do compile }
+// Use -w to avoid warnings about the unused variables
+// { dg-options "-w -g -dA" }
+// DW_ATE_signed_char = 6
+// { dg-final { scan-assembler-not "0x6\[^\n\r]* DW_AT_language" } } */
+// DW_ATE_unsigned_char = 8
+// { dg-final { scan-assembler-not "0x8\[^\n\r]* DW_AT_language" } } */
+}