gdb/fortran: Use TYPE_CODE_CHAR for character types
authorAndrew Burgess <andrew.burgess@embecosm.com>
Fri, 18 Jan 2019 11:24:24 +0000 (11:24 +0000)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Wed, 6 Mar 2019 18:11:31 +0000 (18:11 +0000)
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
gdb/f-lang.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.fortran/type-kinds.exp

index b0d0edb22c669db28e12b36379c5616aa0831ccf..e1fdda06aaa84c5922cf739d6a475b2462cd3af0 100644 (file)
@@ -1,3 +1,8 @@
+2019-03-06  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * f-lang.c (build_fortran_types): Use TYPE_CODE_CHAR for character
+       types.
+
 2019-03-06  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * f-exp.y (convert_to_kind_type): Handle integer (kind=8).
index f27eb0d45da1bf7a890d8b369774d1eb22170431..c329d602e24348189f0737373222fbf626ffe778 100644 (file)
@@ -366,7 +366,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");
index b5599e473e7319d43a6f66b4ddb16bf74d73fbc8..87c491fb1ce0dcee3d84e0dfd0c94f6df7cc5b0f 100644 (file)
@@ -1,3 +1,7 @@
+2019-03-06  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * gdb.fortran/type-kinds.exp: Update expected results.
+
 2019-03-06  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * gdb.fortran/type-kinds.exp: Test new integer type kind.
index 198ac58baf48b9e3fa209f5605f433091565e82c..b5d4e7b5816e6c19b0f35278ae79666b65a4089a 100644 (file)
@@ -38,7 +38,7 @@ proc test_cast_1_to_type_kind {base_type type_kind cast_result size_result} {
 
 # Test parsing of `(kind=N)` type modifiers.
 proc test_basic_parsing_of_type_kinds {} {
-    test_cast_1_to_type_kind "character" "1" "1" "1"
+    test_cast_1_to_type_kind "character" "1" "1 '\\\\001'" "1"
 
     test_cast_1_to_type_kind "complex" "4" "\\(1,0\\)" "8"
     test_cast_1_to_type_kind "complex" "8" "\\(1,0\\)" "16"