forked from Imagelibrary/binutils-gdb
gdb, testsuite, fortran: Fix sizeof intrinsic for Fortran pointers
For Fortran pointers gfortran/ifx emits DW_TAG_pointer_types like <2><17d>: Abbrev Number: 22 (DW_TAG_variable) <180> DW_AT_name : (indirect string, offset: 0x1f1): fptr <184> DW_AT_type : <0x214> ... <1><219>: Abbrev Number: 27 (DW_TAG_array_type) <21a> DW_AT_type : <0x10e> <216> DW_AT_associated : ... The 'pointer property' in Fortran is implicitly modeled by adding a DW_AT_associated to the type of the variable (see also the DW_AT_associated description in DWARF 5). A Fortran pointer is more than an address and thus different from a C pointer. It is a self contained type having additional fields such as, e.g., the rank of its underlying array. This motivates the intended DWARF modeling of Fortran pointers via the DW_AT_associated attribute. This patch adds support for the sizeof intrinsic by simply dereferencing pointer types when encountered during a sizeof evaluation. The patch also adds a test for the sizeof intrinsic which was not tested before. Tested-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org> Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
committed by
Ijaz, Abdul B
parent
f18fc7e56f
commit
6a67441983
@@ -2708,6 +2708,13 @@ evaluate_subexp_for_sizeof_base (struct expression *exp, struct type *type)
|
||||
if (exp->language_defn->la_language == language_cplus
|
||||
&& (TYPE_IS_REFERENCE (type)))
|
||||
type = check_typedef (type->target_type ());
|
||||
else if (exp->language_defn->la_language == language_fortran
|
||||
&& type->code () == TYPE_CODE_PTR)
|
||||
{
|
||||
/* Dereference Fortran pointer types to allow them for the Fortran
|
||||
sizeof intrinsic. */
|
||||
type = check_typedef (type->target_type ());
|
||||
}
|
||||
return value_from_longest (size_type, (LONGEST) type->length ());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user