diff options
author | Paul Thomas <pault@gcc.gnu.org> | 2014-03-06 21:45:31 +0000 |
---|---|---|
committer | Janus Weil <janus@gcc.gnu.org> | 2014-03-06 22:45:31 +0100 |
commit | 2b3dc0db6276666c03156b7b6c5081a87d6ac276 (patch) | |
tree | e830b99b5e9f97c58d66ed160cf4d9e10a6563dc /gcc/fortran/trans.h | |
parent | 4973b0f955150da76d0e46f64ebe430baa279a51 (diff) | |
download | gcc-2b3dc0db6276666c03156b7b6c5081a87d6ac276.zip gcc-2b3dc0db6276666c03156b7b6c5081a87d6ac276.tar.gz gcc-2b3dc0db6276666c03156b7b6c5081a87d6ac276.tar.bz2 |
re PR fortran/51976 ([F2003] Support deferred-length character components of derived types (allocatable string length))
2014-03-06 Paul Thomas <pault@gcc.gnu.org>
Janus Weil <janus@gcc.gnu.org>
PR fortran/51976
* gfortran.h (symbol_attribute): Add deferred_parameter attribute.
* primary.c (build_actual_constructor): It is not an error if
a missing component has the deferred_parameter attribute;
equally, if one is given a value, it is an error.
* resolve.c (resolve_fl_derived0): Remove error for deferred
character length components. Add the hidden string length
field to the structure. Give it the deferred_parameter
attribute.
* trans-array.c (duplicate_allocatable): Add a strlen field
which is used as the element size if it is non-null.
(gfc_duplicate_allocatable, gfc_copy_allocatable_data): Pass a
NULL to the new argument in duplicate_allocatable.
(structure_alloc_comps): Set the hidden string length as
appropriate. Use it in calls to duplicate_allocatable.
(gfc_alloc_allocatable_for_assignment): When a deferred length
backend declaration is variable, use that; otherwise use the
string length from the expression evaluation.
* trans-expr.c (gfc_conv_component_ref): If this is a deferred
character length component, the string length should have the
value of the hidden string length field.
(gfc_trans_subcomponent_assign): Set the hidden string length
field for deferred character length components. Allocate the
necessary memory for the string.
(alloc_scalar_allocatable_for_assignment): Same change as in
gfc_alloc_allocatable_for_assignment above.
* trans-stmt.c (gfc_trans_allocate): Likewise.
* trans-intrinsic (size_of_string_in_bytes): Make non-static.
* trans-types.c (gfc_get_derived_type): Set the tree type for
a deferred character length component.
* trans.c (gfc_deferred_strlen): New function.
* trans.h (size_of_string_in_bytes,gfc_deferred_strlen): New prototypes.
2014-03-06 Paul Thomas <pault@gcc.gnu.org>
Janus Weil <janus@gcc.gnu.org>
PR fortran/51976
* gfortran.dg/deferred_type_component_1.f90 : New test.
* gfortran.dg/deferred_type_component_2.f90 : New test.
Co-Authored-By: Janus Weil <janus@gcc.gnu.org>
From-SVN: r208386
Diffstat (limited to 'gcc/fortran/trans.h')
-rw-r--r-- | gcc/fortran/trans.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/fortran/trans.h b/gcc/fortran/trans.h index e05a375..5fb0cbf 100644 --- a/gcc/fortran/trans.h +++ b/gcc/fortran/trans.h @@ -422,6 +422,8 @@ tree gfc_evaluate_now (tree, stmtblock_t *); /* Find the appropriate variant of a math intrinsic. */ tree gfc_builtin_decl_for_float_kind (enum built_in_function, int); +tree size_of_string_in_bytes (int, tree); + /* Intrinsic procedure handling. */ tree gfc_conv_intrinsic_subroutine (gfc_code *); void gfc_conv_intrinsic_function (gfc_se *, gfc_expr *); @@ -581,6 +583,9 @@ bool get_array_ctor_strlen (stmtblock_t *, gfc_constructor_base, tree *); tree gfc_likely (tree); tree gfc_unlikely (tree); +/* Return the string length of a deferred character length component. */ +bool gfc_deferred_strlen (gfc_component *, tree *); + /* Generate a runtime error call. */ tree gfc_trans_runtime_error (bool, locus*, const char*, ...); |