From 4d00f5d8f6c4a1c9f334b1abb45b9ce05fb45b0a Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Wed, 16 Jan 2019 16:42:10 +0000 Subject: gdb/fortran: Add Fortran 'kind' intrinsic and keyword The 'kind' keyword has two uses in Fortran, it is the name of a builtin intrinsic function, and it is also a keyword used to create a type of a specific kind. This commit adds support for using kind as an intrinsic function, and also adds some initial support for using kind to create types of a specific kind. This commit only allows the creation of the type 'character(kind=1)', however, it will be easy enough to extend this in future to support more type kinds. The kind of any expression can be queried using the kind intrinsic function. At the moment the kind returned corresponds to the size of the type, this matches how gfortran handles kinds. However, the correspondence between kind and type size depends on the compiler and/or the specific target, so this might not be correct for everyone. If we want to support different compilers/targets in future the code to compute the kind from a type will need to be updated. gdb/ChangeLog: * expprint.c (dump_subexp_body_standard): Support UNOP_KIND. * f-exp.y: Define 'KIND' token. (exp): New pattern for KIND expressions. (ptype): Handle types with a kind extension. (direct_abs_decl): Extend to spot kind extensions. (f77_keywords): Add 'kind' to the list. (push_kind_type): New function. (convert_to_kind_type): New function. * f-lang.c (evaluate_subexp_f): Support UNOP_KIND. * parse.c (operator_length_standard): Likewise. * parser-defs.h (enum type_pieces): Add tp_kind. * std-operator.def: Add UNOP_KIND. gdb/testsuite/ChangeLog: * gdb.fortran/intrinsics.exp: New file. * gdb.fortran/intrinsics.f90: New file. * gdb.fortran/type-kinds.exp: New file. --- gdb/expprint.c | 1 + 1 file changed, 1 insertion(+) (limited to 'gdb/expprint.c') diff --git a/gdb/expprint.c b/gdb/expprint.c index d7ad1a7..a22499f 100644 --- a/gdb/expprint.c +++ b/gdb/expprint.c @@ -869,6 +869,7 @@ dump_subexp_body_standard (struct expression *exp, case UNOP_MIN: case UNOP_ODD: case UNOP_TRUNC: + case UNOP_KIND: elt = dump_subexp (exp, stream, elt); break; case OP_LONG: -- cgit v1.1