gdb/fortran: Add Fortran 'kind' intrinsic and keyword
authorAndrew Burgess <andrew.burgess@embecosm.com>
Wed, 16 Jan 2019 16:42:10 +0000 (16:42 +0000)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Wed, 6 Mar 2019 18:11:31 +0000 (18:11 +0000)
commit4d00f5d8f6c4a1c9f334b1abb45b9ce05fb45b0a
tree24f8cddb29a1036f7f0f23d6a2178f593a2daeef
parente454224fa82aa52a1288a3d6a2e26e8d224d732a
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/ChangeLog
gdb/expprint.c
gdb/f-exp.y
gdb/f-lang.c
gdb/parse.c
gdb/parser-defs.h
gdb/std-operator.def
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.fortran/intrinsics.exp [new file with mode: 0644]
gdb/testsuite/gdb.fortran/intrinsics.f90 [new file with mode: 0644]
gdb/testsuite/gdb.fortran/type-kinds.exp [new file with mode: 0644]