summaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>2006-10-08 16:21:55 +0000
committerpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>2006-10-08 16:21:55 +0000
commit2294b6167ad8c2adbd54cdf0b69fe5a33809e129 (patch)
treefdb6be945aa00dac05524839d5b40aa79575f789 /libgfortran
parent73816ab17f5735ecadbafe8724bb3bdabce92d70 (diff)
downloadgcc-2294b6167ad8c2adbd54cdf0b69fe5a33809e129.tar.gz
2006-10-05 Erik Edelmann <edelmann@gcc.gnu.org>
Paul Thomas <pault@gcc.gnu.org> PR fortran/20541 * interface.c (gfc_compare_derived_types): Add comparison of the allocatable field. * intrinsic.c (add_subroutines): Add MOVE_ALLOC. * trans-expr.c (gfc_conv_aliased_arg, gfc_trans_subarray_assign, gfc_trans_subcomponent_assign, gfc_conv_string_parameter, gfc_trans_scalar_assign): Add extra arguments l_is_temp and r_is_var to references to latter function. (gfc_conv_function_call): Add enum for types of argument and an associated variable parm_kind. Deallocate components of INTENT(OUT) and non-variable arrays. (gfc_trans_subcomponent_assign): Add block to assign arrays to allocatable components. (gfc_trans_scalar_assign): Add block to handle assignments of derived types with allocatable components, using the above new arguments to control allocation/deallocation of memory and the copying of allocated arrays. * trans-array.c (gfc_array_allocate): Remove old identification of pointer and replace with that of an allocatable array. Add nullify of structures with allocatable components. (gfc_conv_array_initializer): Treat EXPR_NULL. (gfc_conv_array_parameter): Deallocate allocatable components of non-variable structures. (gfc_trans_dealloc_allocated): Use second argument of library deallocate to inhibit, without error, freeing NULL pointers. (get_full_array_size): New function to return the size of a full array. (gfc_duplicate_allocatable): New function to allocate and copy allocated data. (structure_alloc_comps): New recursive function to deallocate, nullify or copy allocatable components. (gfc_nullify_alloc_comp, gfc_deallocate_alloc_comp, gfc_copy_alloc_comp): New interface functions to call previous. (gfc_trans_deferred_array): Add the code to nullify allocatable components, when entering scope, and to deallocate them on leaving. Do not call gfc_trans_static_array_pointer and return for structures with allocatable components and default initializers. * symbol.c (gfc_set_component_attr): Set allocatable field. (gfc_get_component_attr): Set the allocatable attribute. * intrinsic.h : Prototype for gfc_check_move_alloc. * decl.c (build_struct): Apply TR15581 constraints for allocatable components. (variable_decl): Default initializer is always NULL for allocatable components. (match_attr_spec): Allow, or not, allocatable components, according to the standard in force. * trans-array.h : Prototypes for gfc_nullify_alloc_comp, gfc_deallocate_alloc_comp, gfc_copy_alloc_comp and gfc_duplicate_allocatable. * gfortran.texi : Add mention of TR15581 extensions. * gfortran.h : Add attribute alloc_comp, add gfc_components field allocatable and add the prototype for gfc_expr_to_initialize. * trans-stmt.c (generate_loop_for_temp_to_lhs, generate_loop_for_rhs_to_temp, gfc_trans_where_assign, gfc_trans_where_3): Add extra arguments to calls to gfc_trans_scalar_assign and set appropriately. (gfc_trans_allocate): Nullify allocatable components. (gfc_trans_deallocate): Deallocate to ultimate allocatable components but stop at ultimate pointer components. * module.c (mio_symbol_attribute, mio_symbol_attribute, mio_component): Add module support for allocatable components. * trans-types.c (gfc_get_derived_type): Treat allocatable components. * trans.h : Add two boolean arguments to gfc_trans_scalar_assign. * resolve.c (resolve_structure_cons): Check conformance of constructor element and the component. (resolve_allocate_expr): Add expression to nullify the constructor expression for allocatable components. (resolve_transfer): Inhibit I/O of derived types with allocatable components. (resolve_fl_derived): Skip check of bounds of allocatable components. * trans-decl.c (gfc_get_symbol_decl): Add derived types with allocatable components to deferred variable. (gfc_trans_deferred_vars): Make calls for derived types with allocatable components to gfc_trans_deferred_array. (gfc_generate_function_code): Nullify allocatable component function result on entry. * parse.c (parse_derived): Set symbol attr.allocatable if allocatable components are present. * check.c (gfc_check_allocated): Enforce attr.allocatable for intrinsic arguments. (gfc_check_move_alloc): Check arguments of move_alloc. * primary.c (gfc_variable_attr): Set allocatable attribute. * intrinsic.texi : Add index entry and section for for move_alloc. PR fortran/29115 * resolve.c (resolve_structure_cons): It is an error if the pointer component elements of a derived type constructor are not pointer or target. PR fortran/29211 * trans-stmt.c (generate_loop_for_temp_to_lhs, generate_loop_for_rhs_to_temp): Provide a string length for the temporary by copying that of the other side of the scalar assignment. 2006-10-05 Paul Thomas <pault@gcc.gnu.org> Erik Edelmann <edelmann@gcc.gnu.org> PR libgfortran/20541 * Makefile.in : Add move_alloc. * intrinsics/move_alloc.c: New function. * Makefile.am : Add move_alloc. 2006-10-05 Erik Edelmann <edelmann@gcc.gnu.org> Paul Thomas <pault@gcc.gnu.org> PR fortran/20541 * gfortran.dg/alloc_comp_basics_1.f90: New test. * gfortran.dg/alloc_comp_basics_2.f90: New test. * gfortran.dg/alloc_comp_assign_1.f90: New test. * gfortran.dg/alloc_comp_assign_2.f90: New test. * gfortran.dg/alloc_comp_assign_3.f90: New test. * gfortran.dg/alloc_comp_assign_4.f90: New test. * gfortran.dg/alloc_comp_constraint_1.f90: New test. * gfortran.dg/alloc_comp_constraint_2.f90: New test. * gfortran.dg/alloc_comp_constraint_3.f90: New test. * gfortran.dg/alloc_comp_constructor_1.f90: New test. * gfortran.dg/alloc_comp_constructor_2.f90: New test. * gfortran.dg/alloc_comp_initializer_1.f90: New test. * gfortran.dg/alloc_comp_std.f90: New test. * gfortran.dg/move_alloc.f90: New test. PR fortran/29115 * gfortran.dg/derived_constructor_comps_2.f90: New test. PR fortran/29211 * gfortran.dg/forall_char_dependencies_1.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@117558 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog8
-rw-r--r--libgfortran/Makefile.in16
-rw-r--r--libgfortran/intrinsics/move_alloc.c67
3 files changed, 85 insertions, 6 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index effc06e4879..42b35f4ed3f 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,11 @@
+2006-10-08 Paul Thomas <pault@gcc.gnu.org>
+ Erik Edelmann <edelmann@gcc.gnu.org>
+
+ PR libgfortran/20541
+ * Makefile.in : Add move_alloc.
+ * intrinsics/move_alloc.c: New function.
+ * Makefile.am : Add move_alloc.
+
2006-10-08 Francois-Xavier Coudert <coudert@clipper.ens.fr>
PR libfortran/26540
diff --git a/libgfortran/Makefile.in b/libgfortran/Makefile.in
index 77defb517a0..32cdf404816 100644
--- a/libgfortran/Makefile.in
+++ b/libgfortran/Makefile.in
@@ -169,12 +169,12 @@ am__objects_30 = associated.lo abort.lo access.lo args.lo bessel.lo \
eoshift2.lo etime.lo exit.lo fget.lo flush.lo fnum.lo ftell.lo \
gerror.lo getcwd.lo getlog.lo getXid.lo hyper.lo hostnm.lo \
kill.lo ierrno.lo ishftc.lo link.lo malloc.lo mvbits.lo \
- pack_generic.lo perror.lo signal.lo size.lo sleep.lo \
- spread_generic.lo string_intrinsics.lo system.lo rand.lo \
- random.lo rename.lo reshape_generic.lo reshape_packed.lo \
- selected_int_kind.lo selected_real_kind.lo stat.lo symlnk.lo \
- system_clock.lo time.lo transpose_generic.lo tty.lo umask.lo \
- unlink.lo unpack_generic.lo in_pack_generic.lo \
+ move_alloc.lo pack_generic.lo perror.lo signal.lo size.lo \
+ sleep.lo spread_generic.lo string_intrinsics.lo system.lo \
+ rand.lo random.lo rename.lo reshape_generic.lo \
+ reshape_packed.lo selected_int_kind.lo selected_real_kind.lo \
+ stat.lo symlnk.lo system_clock.lo time.lo transpose_generic.lo \
+ tty.lo umask.lo unlink.lo unpack_generic.lo in_pack_generic.lo \
in_unpack_generic.lo
am__objects_31 =
am__objects_32 = _abs_c4.lo _abs_c8.lo _abs_c10.lo _abs_c16.lo \
@@ -427,6 +427,7 @@ intrinsics/ishftc.c \
intrinsics/link.c \
intrinsics/malloc.c \
intrinsics/mvbits.c \
+intrinsics/move_alloc.c \
intrinsics/pack_generic.c \
intrinsics/perror.c \
intrinsics/signal.c \
@@ -2409,6 +2410,9 @@ malloc.lo: intrinsics/malloc.c
mvbits.lo: intrinsics/mvbits.c
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mvbits.lo `test -f 'intrinsics/mvbits.c' || echo '$(srcdir)/'`intrinsics/mvbits.c
+move_alloc.lo: intrinsics/move_alloc.c
+ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o move_alloc.lo `test -f 'intrinsics/move_alloc.c' || echo '$(srcdir)/'`intrinsics/move_alloc.c
+
pack_generic.lo: intrinsics/pack_generic.c
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o pack_generic.lo `test -f 'intrinsics/pack_generic.c' || echo '$(srcdir)/'`intrinsics/pack_generic.c
diff --git a/libgfortran/intrinsics/move_alloc.c b/libgfortran/intrinsics/move_alloc.c
new file mode 100644
index 00000000000..b73ef4b77a0
--- /dev/null
+++ b/libgfortran/intrinsics/move_alloc.c
@@ -0,0 +1,67 @@
+/* Generic implementation of the MOVE_ALLOC intrinsic
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ Contributed by Paul Thomas
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+In addition to the permissions in the GNU General Public License, the
+Free Software Foundation gives you unlimited permission to link the
+compiled version of this file into combinations with other programs,
+and to distribute those combinations without any restriction coming
+from the use of this file. (The General Public License restrictions
+do apply in other respects; for example, they cover modification of
+the file, and distribution when not linked into a combine
+executable.)
+
+Ligbfortran is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public
+License along with libgfortran; see the file COPYING. If not,
+write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA. */
+
+#include "libgfortran.h"
+
+extern void move_alloc (gfc_array_char *, gfc_array_char *);
+export_proto(move_alloc);
+
+void
+move_alloc (gfc_array_char * from, gfc_array_char * to)
+{
+ int i;
+
+ internal_free (to->data);
+
+ for (i = 0; i < GFC_DESCRIPTOR_RANK (from); i++)
+ {
+ to->dim[i].lbound = from->dim[i].lbound;
+ to->dim[i].ubound = from->dim[i].ubound;
+ to->dim[i].stride = from->dim[i].stride;
+ from->dim[i].stride = 0;
+ from->dim[i].ubound = from->dim[i].lbound;
+ }
+
+ to->offset = from->offset;
+ to->dtype = from->dtype;
+ to->data = from->data;
+ from->data = NULL;
+}
+
+extern void move_alloc_c (gfc_array_char *, GFC_INTEGER_4,
+ gfc_array_char *, GFC_INTEGER_4);
+export_proto(move_alloc_c);
+
+void
+move_alloc_c (gfc_array_char * from, GFC_INTEGER_4 from_length __attribute__((unused)),
+ gfc_array_char * to, GFC_INTEGER_4 to_length __attribute__((unused)))
+{
+ move_alloc (from, to);
+}