diff mbox

[09/11] gdb/fortran: Use TYPE_CODE_CHAR for character types

Message ID 7b2f5773c3e241e4140c39acddc9abf2d5e6a57e.1549986233.git.andrew.burgess@embecosm.com
State New
Headers show

Commit Message

Andrew Burgess Feb. 12, 2019, 4:11 p.m. UTC
Switch to using TYPE_CODE_CHAR for character types.  This appears to
have little impact on the test results as gFortran uses the
DW_TAG_string_type to represent all character variables (as far as I
can see).  The only place this has an impact is when the user casts a
variable to a character type, in which case GDB does now use the CHAR
type, and prints the variable as both a value and a character, for
example, before:

    (gdb) p ((character) 97)
    $1 = 97

and after:

    (gdb) p ((character) 97)
    $1 = 97 'a'

gdb/ChangeLog:

	* f-lang.c (build_fortran_types): Use TYPE_CODE_CHAR for character
	types.

gdb/testsuite/ChangeLog:

	* gdb.fortran/type-kinds.exp: Update expected results.
---
 gdb/ChangeLog                            | 5 +++++
 gdb/f-lang.c                             | 2 +-
 gdb/testsuite/ChangeLog                  | 4 ++++
 gdb/testsuite/gdb.fortran/type-kinds.exp | 2 +-
 4 files changed, 11 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 7bed3189283..cbb3ad0f8a6 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -365,7 +365,7 @@  build_fortran_types (struct gdbarch *gdbarch)
     = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "VOID");
 
   builtin_f_type->builtin_character
-    = arch_integer_type (gdbarch, TARGET_CHAR_BIT, 0, "character");
+    = arch_type (gdbarch, TYPE_CODE_CHAR, TARGET_CHAR_BIT, "character");
 
   builtin_f_type->builtin_logical_s1
     = arch_boolean_type (gdbarch, TARGET_CHAR_BIT, 1, "logical*1");
diff --git a/gdb/testsuite/gdb.fortran/type-kinds.exp b/gdb/testsuite/gdb.fortran/type-kinds.exp
index 129997e4f66..0daa1ec6b12 100644
--- a/gdb/testsuite/gdb.fortran/type-kinds.exp
+++ b/gdb/testsuite/gdb.fortran/type-kinds.exp
@@ -23,7 +23,7 @@  if { [skip_fortran_tests] } { continue }
 
 # Test parsing of `(kind=N)` type modifiers.
 proc test_basic_parsing_of_type_kinds {} {
-    gdb_test "p ((character (kind=1)) 1)" " = 1"
+    gdb_test "p ((character (kind=1)) 1)" " = 1 '\\\\001'"
 
     gdb_test "p ((complex (kind=4)) 1)" " = \\(1,0\\)"
     gdb_test "p ((complex (kind=8)) 1)" " = \\(1,0\\)"