[08/11] gdb/fortran: Add builtin 8-byte integer type with (kind=8) support

Message ID f812096d60b67eb9a488129bd3cd5528f1bb2256.1549986233.git.andrew.burgess@embecosm.com
State New
Headers show
Series
  • Fortran Parser Cleanup, KIND Support, and Intrinsic Functions
Related show

Commit Message

Andrew Burgess Feb. 12, 2019, 4:10 p.m.
Add a new builtin type, an 8-byte integer, and allow GDB to parse
'integer (kind=8)', returning the new 8-byte integer.

gdb/ChangeLog:

	* f-exp.y (convert_to_kind_type): Handle integer (kind=8).
	* f-lang.c (build_fortran_types): Setup builtin_integer_s8.
	* f-lang.h (struct builtin_f_type): Add builtin_integer_s8 field.

gdb/testsuite/ChangeLog:

	* gdb.fortran/type-kinds.exp: Test new integer type kind.
---
 gdb/ChangeLog                            | 6 ++++++
 gdb/f-exp.y                              | 2 ++
 gdb/f-lang.c                             | 4 ++++
 gdb/f-lang.h                             | 1 +
 gdb/testsuite/ChangeLog                  | 4 ++++
 gdb/testsuite/gdb.fortran/type-kinds.exp | 1 +
 6 files changed, 18 insertions(+)

-- 
2.14.5

Patch

diff --git a/gdb/f-exp.y b/gdb/f-exp.y
index 980ee4b4adb..d256ff14c1e 100644
--- a/gdb/f-exp.y
+++ b/gdb/f-exp.y
@@ -865,6 +865,8 @@  convert_to_kind_type (struct type *basetype, int kind)
 	return parse_f_type (pstate)->builtin_integer_s2;
       else if (kind == 4)
 	return parse_f_type (pstate)->builtin_integer;
+      else if (kind == 8)
+	return parse_f_type (pstate)->builtin_integer_s8;
     }
 
   error (_("unsupported kind %d for type %s"),
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 72dafe6d66f..7bed3189283 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -374,6 +374,10 @@  build_fortran_types (struct gdbarch *gdbarch)
     = arch_integer_type (gdbarch, gdbarch_short_bit (gdbarch), 0,
 			 "integer*2");
 
+  builtin_f_type->builtin_integer_s8
+    = arch_integer_type (gdbarch, gdbarch_long_long_bit (gdbarch), 0,
+			 "integer*8");
+
   builtin_f_type->builtin_logical_s2
     = arch_boolean_type (gdbarch, gdbarch_short_bit (gdbarch), 1,
 			 "logical*2");
diff --git a/gdb/f-lang.h b/gdb/f-lang.h
index a4ae6a726d9..7164585f9ea 100644
--- a/gdb/f-lang.h
+++ b/gdb/f-lang.h
@@ -66,6 +66,7 @@  struct builtin_f_type
   struct type *builtin_character;
   struct type *builtin_integer;
   struct type *builtin_integer_s2;
+  struct type *builtin_integer_s8;
   struct type *builtin_logical;
   struct type *builtin_logical_s1;
   struct type *builtin_logical_s2;
diff --git a/gdb/testsuite/gdb.fortran/type-kinds.exp b/gdb/testsuite/gdb.fortran/type-kinds.exp
index b2e64d77081..129997e4f66 100644
--- a/gdb/testsuite/gdb.fortran/type-kinds.exp
+++ b/gdb/testsuite/gdb.fortran/type-kinds.exp
@@ -39,6 +39,7 @@  proc test_basic_parsing_of_type_kinds {} {
 
     gdb_test "p ((integer (kind=2)) 1)" " = 1"
     gdb_test "p ((integer (kind=4)) 1)" " = 1"
+    gdb_test "p ((integer (kind=8)) 1)" " = 1"
 }
 
 proc test_parsing_invalid_type_kinds {} {