diff options
author | Andre Vehreschild <vehre@gmx.de> | 2015-03-24 11:28:48 +0100 |
---|---|---|
committer | Andre Vehreschild <vehre@gcc.gnu.org> | 2015-03-24 11:28:48 +0100 |
commit | 34d9d74996badd2b9ee315903f916ebb7a8d422f (patch) | |
tree | 4cda0798b6bf5a397dc8dfb57c00dd489206a269 /gcc/fortran/trans.h | |
parent | a9272fd04204ce8e1287a94b2d4fdacd32ef90a1 (diff) | |
download | gcc-34d9d74996badd2b9ee315903f916ebb7a8d422f.zip gcc-34d9d74996badd2b9ee315903f916ebb7a8d422f.tar.gz gcc-34d9d74996badd2b9ee315903f916ebb7a8d422f.tar.bz2 |
re PR fortran/64787 (Invalid code on sourced allocation of class(*) character string)
gcc/fortran/ChangeLog
2015-03-24 Andre Vehreschild <vehre@gmx.de>
PR fortran/64787
PR fortran/57456
PR fortran/63230
* class.c (gfc_add_component_ref): Free no longer needed
ref-chains to prevent memory loss.
(find_intrinsic_vtab): For deferred length char arrays or
unlimited polymorphic objects, store the size in bytes of one
character in the size component of the vtab.
* gfortran.h: Added gfc_add_len_component () define.
* trans-array.c (gfc_trans_create_temp_array): Switched to new
function name for getting a class' vtab's field.
(build_class_array_ref): Likewise.
(gfc_array_init_size): Using the size information from allocate
more consequently now, i.e., the typespec of the entity to
allocate is no longer needed. This is to address the last open
comment in PR fortran/57456.
(gfc_array_allocate): Likewise.
(structure_alloc_comps): gfc_copy_class_to_class () needs to
know whether the class is unlimited polymorphic.
* trans-array.h: Changed interface of gfc_array_allocate () to
reflect the no longer needed typespec.
* trans-expr.c (gfc_find_and_cut_at_last_class_ref): New.
(gfc_reset_len): New.
(gfc_get_class_array_ref): Switch to new function name for
getting a class' vtab's field.
(gfc_copy_class_to_class): Added flag to know whether the class
to copy is unlimited polymorphic. Adding _len dependent code
then, which calls ->vptr->copy () with four arguments adding
the length information ->vptr->copy(from, to, from_len, to_cap).
(gfc_conv_procedure_call): Switch to new function name for
getting a class' vtab's field.
(alloc_scalar_allocatable_for_assignment): Use the string_length
as computed by gfc_conv_expr and not the statically backend_decl
which may be incorrect when ref-ing.
(gfc_trans_assignment_1): Use the string_length variable and
not the rse.string_length. The former has been computed more
generally.
* trans-intrinsic.c (gfc_conv_intrinsic_sizeof): Switch to new
function name for getting a class' vtab's field.
(gfc_conv_intrinsic_storage_size): Likewise.
(gfc_conv_intrinsic_transfer): Likewise.
* trans-stmt.c (gfc_trans_allocate): Restructured to evaluate
source=expr3 only once before the loop over the objects to
allocate, when the objects are not arrays. Doing correct _len
initialization and calling of vptr->copy () fixing PR 64787.
(gfc_trans_deallocate): Reseting _len to 0, preventing future
errors.
* trans.c (gfc_build_array_ref): Switch to new function name
for getting a class' vtab's field.
(gfc_add_comp_finalizer_call): Likewise.
* trans.h: Define the prototypes for the gfc_class_vtab_*_get ()
and gfc_vptr_*_get () functions.
Added gfc_find_and_cut_at_last_class_ref () and
gfc_reset_len () routine prototype. Added flag to
gfc_copy_class_to_class () prototype to signal an unlimited
polymorphic entity to copy.
gcc/testsuite/ChangeLog
2015-03-24 Andre Vehreschild <vehre@gmx.de>
* gfortran.dg/allocate_alloc_opt_13.f90: Added tests for
source= and mold= expressions functionality.
* gfortran.dg/allocate_class_4.f90: New test.
* gfortran.dg/unlimited_polymorphic_20.f90: Added test whether
copying an unlimited polymorhpic object containing a char array
to another unlimited polymorphic object respects the _len
component.
* gfortran.dg/unlimited_polymorphic_22.f90: Extended to check
whether deferred length char array allocate works, unlimited
polymorphic object allocation from a string works and if
allocating an array of deferred length strings works.
* gfortran.dg/unlimited_polymorphic_24.f03: New test.
From-SVN: r221621
Diffstat (limited to 'gcc/fortran/trans.h')
-rw-r--r-- | gcc/fortran/trans.h | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/gcc/fortran/trans.h b/gcc/fortran/trans.h index be11363..1998358 100644 --- a/gcc/fortran/trans.h +++ b/gcc/fortran/trans.h @@ -350,20 +350,31 @@ typedef struct gfc_wrapped_block; /* Class API functions. */ +tree gfc_class_set_static_fields (tree, tree, tree); tree gfc_class_data_get (tree); tree gfc_class_vptr_get (tree); tree gfc_class_len_get (tree); +gfc_expr * gfc_find_and_cut_at_last_class_ref (gfc_expr *); +/* Get an accessor to the class' vtab's * field, when a class handle is + available. */ +tree gfc_class_vtab_hash_get (tree); +tree gfc_class_vtab_size_get (tree); +tree gfc_class_vtab_extends_get (tree); +tree gfc_class_vtab_def_init_get (tree); +tree gfc_class_vtab_copy_get (tree); +tree gfc_class_vtab_final_get (tree); +/* Get an accessor to the vtab's * field, when a vptr handle is present. */ +tree gfc_vtpr_hash_get (tree); +tree gfc_vptr_size_get (tree); +tree gfc_vptr_extends_get (tree); +tree gfc_vptr_def_init_get (tree); +tree gfc_vptr_copy_get (tree); +tree gfc_vptr_final_get (tree); void gfc_reset_vptr (stmtblock_t *, gfc_expr *); -tree gfc_class_set_static_fields (tree, tree, tree); -tree gfc_vtable_hash_get (tree); -tree gfc_vtable_size_get (tree); -tree gfc_vtable_extends_get (tree); -tree gfc_vtable_def_init_get (tree); -tree gfc_vtable_copy_get (tree); -tree gfc_vtable_final_get (tree); +void gfc_reset_len (stmtblock_t *, gfc_expr *); tree gfc_get_vptr_from_expr (tree); tree gfc_get_class_array_ref (tree, tree); -tree gfc_copy_class_to_class (tree, tree, tree); +tree gfc_copy_class_to_class (tree, tree, tree, bool); bool gfc_add_finalizer_call (stmtblock_t *, gfc_expr *); bool gfc_add_comp_finalizer_call (stmtblock_t *, tree, gfc_component *, bool); |