Commit Graph

123 Commits

Author SHA1 Message Date
Kazu Hirata
65de695fa5 * simplify.c, trans-array.c: Fix comment typos.
From-SVN: r121373
2007-01-31 03:35:59 +00:00
Roger Sayle
b01e2f88ef dependency.c (gfc_full_array_ref_p): Check that ref->next is NULL, i.e.
* dependency.c (gfc_full_array_ref_p): Check that ref->next is NULL,
	i.e. that the ARRAY_REF doesn't mention components.
	* trans-array.c (gfc_constant_array_constructor_p): Export external
	function renamed from constant_array_constructor_p.
	(gfc_build_constant_array_constructor): Export.
	(gfc_trans_array_constructor): Update call to the renamed function
	constant_array_constructor_p.
	* trans-array.h (gfc_constant_array_constructor_p): Prototype here.
	(gfc_build_constant_array_constructor): Likewise.
	* trans-expr.c (gfc_build_memcpy_call): New helper function split
	out from gfc_trans_array_copy.
	(gfc_trans_array_copy): Use gfc_build_memcpy_call.
	(gfc_trans_array_constructor_copy): New function to optimize
	assigning an entire array from a constant array constructor.
	(gfc_trans_assignment): Call gfc_trans_array_constructor_copy
	when appropriate.

	* gfortran.dg/array_memcpy_3.f90: New test case.
	* gfortran.dg/vect/vect-5.f90: Update vectorized loop count.

From-SVN: r121010
2007-01-20 20:12:44 +00:00
Roger Sayle
62511fb1ea trans-array.c (constant_array_constructor_p): New function to determine whether an array constructor consists only of...
* trans-array.c (constant_array_constructor_p): New function to
	determine whether an array constructor consists only of constant
	elements, and if so return it's size.
	(gfc_build_constant_array_constructor): Construct a statically
	initialized gfortran array for a given EXPR_ARRAY.
	(gfc_trans_constant_array_constructor): Efficiently scalarize
	a constant array constructor.
	(gfc_trans_array_constructor):  Tidy up use of CONST_STRING.
	Special case scalarization of constant array constructors, all of
	whose elements are specified, using constant_array_constructor_p 
	and gfc_trans_constant_array_constructor.
	(gfc_conv_scalarized_array_ref): Check whetger info->offset is zero
	before adding it to index, to avoid creating a NON_LVALUE_EXPR.

	* gfortran.dg/array_constructor_14.f90: New test case.
	* gfortran.dg/vect/vect-5.f90: Update test for improved alignment.

From-SVN: r120584
2007-01-08 17:56:37 +00:00
Bernhard Fischer
dbfd1e0108 trans-array.c (gfc_trans_create_temp_array, [...]): Commentary typo fix.
fortran/ChangeLog

2007-01-07  Bernhard Fischer  <aldot@gcc.gnu.org>

        * trans-array.c (gfc_trans_create_temp_array, gfc_array_init_size):
        Commentary typo fix.

From-SVN: r120550
2007-01-07 17:40:42 +01:00
Roger Sayle
0f0707d106 trans-array.c (gfc_trans_array_constructor_value): Make the static const "data" array as TREE_READONLY.
* trans-array.c (gfc_trans_array_constructor_value): Make the
	static const "data" array as TREE_READONLY.
	* trans-stmt.c (gfc_trans_character_select): Likewise.

From-SVN: r120501
2007-01-05 21:23:05 +00:00
Roger Sayle
c96111c00d trans-array.c (gfc_conv_loop_setup): Test whether the loop stride is one...
* trans-array.c (gfc_conv_loop_setup):  Test whether the loop
	stride is one, to avoid fold_build2 introducing a useless
	NON_LVALUE_EXPR node.

From-SVN: r120500
2007-01-05 21:22:05 +00:00
Paul Thomas
54129a64cd re PR fortran/25818 ([4.1 only] Problem with handling optional and entry master arguments)
2006-12-22  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/25818
	* trans-array.c (gfc_trans_g77_array): If the variable is
	optional or not always present, make the statement conditional
	on presence of the argument.
	* gfortran.h : Add symbol_attribute not_always_present.
	* resolve.c (check_argument_lists): New function to check if
	arguments are not present in all entries.

	PR fortran/30084
	* module.c (mio_component_ref): Move treatment of unique name
	variables, during output, to fix_mio_expr.
	(fix_mio_expr): New function that fixes defective expressions
	before they are written to the module file.
	(mio_expr): Call the new function.
	(resolve_entries): Call check_argument_lists.

2006-12-22  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/25818
	* gfortran.dg/entry_array_specs_2.f: New test.

	PR fortran/30084
	* gfortran.dg/nested_modules_6.f90: New test.

From-SVN: r120155
2006-12-22 20:49:00 +00:00
Roger Sayle
fcac922973 trans-array.c (gfc_trans_create_temp_array): When the size is known at compile-time, avoid an unnecessary conditional assignment.
* trans-array.c (gfc_trans_create_temp_array): When the size is known
	at compile-time, avoid an unnecessary conditional assignment.
	(gfc_array_init_size): Likewise.

From-SVN: r120141
2006-12-22 03:56:43 +00:00
Paul Thomas
6a14cf131e re PR fortran/30190 ([4.1 only] Bounds check generates wrong code for associated(p1(i)%p2,p1(i)%p2))
2006-12-20  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/30190
	* trans-array.c (gfc_conv_array_ref): Remove gfc_evaluate_now
	from the -fbounds-check branch.

2006-12-20  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/30190
	* gfortran.dg/bounds_check_5.f90: New test.

From-SVN: r120084
2006-12-20 21:10:51 +00:00
Roger Sayle
ecc54e6eab trans-array.c (gfc_conv_array_index_offset): Avoid multiplying index by one, or adding zero to it.
* trans-array.c (gfc_conv_array_index_offset): Avoid multiplying
	index by one, or adding zero to it.

From-SVN: r120011
2006-12-18 19:34:23 +00:00
Roger Sayle
fcd443200b re PR fortran/30207 (ICE in gfc_dep_resolver with where (a < 0) a(:) = 1)
2006-12-17  Roger Sayle  <roger@eyesopen.com>
	    Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/30207
	* dependency.c (gfc_full_array_ref_p): New function to test whether
	the given array ref specifies the entire array.
	(gfc_dep_resolver): Use gfc_full_array_ref_p to analyze AR_FULL
	array refs against AR_SECTION array refs, and vice versa.
	* dependency.h (gfc_full_array_ref_p): Prototype here.
	* trans-array.c (gfc_conv_expr_descriptor): Use gfc_full_array_ref_p.

	* gfortran.fortran-torture/execute/where21.f90: New test.

From-SVN: r119990
2006-12-17 18:28:07 +00:00
Richard Guenther
54200abb68 re PR fortran/30115 (allocate() interface pessimizes aliasing)
2006-12-13  Richard Guenther  <rguenther@suse.de>

	PR fortran/30115
	* runtime/memory.c (allocate_size): Change interface to
	void *()(size_t, GFC_INTEGER_4 *).
	(allocate): Likewise.
	(allocate64): Likewise.
	(allocate_array): Change interface to
	void *()(void *, size_t, GFC_INTEGER_4 *).
	(allocate64_array): Likewise.
	(deallocate): Change interface to
	void ()(void *, GFC_INTEGER_4 *).

	* trans-array.c (gfc_array_allocate): Adjust for changed
	library interface.
	(gfc_array_deallocate): Likewise.
	(gfc_trans_dealloc_allocated): Likewise.
	* trans-stmt.c (gfc_trans_allocate): Likewise.
	(gfc_trans_deallocate): Likewise.
	* trans-decl.c (gfc_build_builtin_function_decls): Adjust
	function declarations to match the library changes.  Mark
	allocation functions with DECL_IS_MALLOC.

From-SVN: r119822
2006-12-13 09:57:56 +00:00
Paul Thomas
8424e0d8b1 re PR fortran/30003 ([4.1 only] Expressions with side effects in array references)
2006-12-05  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/30003
	* trans-array.c (gfc_trans_create_temp_array): Set the section
	ends to zero.
	(gfc_conv_array_transpose): Likewise.
	(gfc_conv_section_startstride): Declare an expression for end,
	set it from a the array reference and evaluate it for the info
	structure. Zero the ends in the ss structure and set end, used
	in the bounds check, from the info structure.
	trans.h: Add and end array to the gfc_ss_info structure.

2006-12-05  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/30003
	* gfortran.dg/allocatable_function_1.f90: Increase the number
	of expected calls of free to 10; the lhs section reference is
	now evaluated so there is another call to bar.  Change the
	comment appropriately.
	* gfortran.dg/array_section_1.f90: New test.

From-SVN: r119556
2006-12-05 19:45:25 +00:00
Aldy Hernandez
07beea0df3 Merge gimple-tuples-branch into mainline.
From-SVN: r119546
2006-12-05 17:26:05 +00:00
Francois-Xavier Coudert
d19c0f4fa6 re PR fortran/29892 (substring out of bounds: Missing variable name for variables with parameter attribute)
PR fortran/29892
	* trans-intrinsic.c (gfc_conv_intrinsic_bound): Use a locus in
	the call to gfc_trans_runtime_check.
	* trans-array.c (gfc_trans_array_bound_check): Try harder to find
	the variable or function name for the runtime error message.
	(gfc_trans_dummy_array_bias): Use a locus in the call to
	gfc_trans_runtime_check

From-SVN: r119223
2006-11-26 12:25:50 +00:00
Paul Thomas
012019922e re PR fortran/29431 (Not Implemented: complex character array constructors)
2006-11-09 Paul Thomas <pault@gcc.gnu.org>

	PR fortran/29431
	* trans-array.c    (get_array_ctor_strlen): If we fall through to
	default, use a constant character length if it is available.

2006-11-09 Paul Thomas <pault@gcc.gnu.org>

	PR fortran/29431
	* gfortran.dg/array_constructor_13.f90: New test.

From-SVN: r118631
2006-11-09 22:49:12 +00:00
Paul Thomas
7114edca02 re PR fortran/29699 (ICE in trans-decl.c)
2006-11-09 Paul Thomas <pault@gcc.gnu.org>

	PR fortran/29699
	* trans-array.c (structure_alloc_comps): Detect pointers to
	arrays and use indirect reference to declaration.
	* resolve.c (resolve_fl_variable): Tidy up condition.
	(resolve_symbol): The same and only add initialization code if
	the symbol is referenced.
	* trans-decl.c (gfc_trans_deferred_vars): Call gfc_trans_
	deferred_array before gfc_trans_auto_array_allocation.

	PR fortran/21730
	* symbol.c (check_done): Remove.
	(gfc_add_attribute): Remove reference to check_done and remove
	the argument attr_intent.
	(gfc_add_allocatable, gfc_add_dimension, gfc_add_external,
	gfc_add_intrinsic, gfc_add_optional, gfc_add_pointer,
	gfc_add_cray_pointer, gfc_add_cray_pointee, gfc_add_result,
	gfc_add_target, gfc_add_in_common, gfc_add_elemental,
	gfc_add_pure, gfc_add_recursive, gfc_add_procedure,
	gfc_add_type): Remove references to check_done.
	* decl.c (attr_decl1): Eliminate third argument in call to
	gfc_add_attribute.
	* gfortran.h : Change prototype for gfc_add_attribute.



2006-11-09 Paul Thomas <pault@gcc.gnu.org>

	PR fortran/29699
	* gfortran.dg/alloc_comp_auto_array_1.f90: New test.

	PR fortran/21730
	* gfortran.dg/change_symbol_attributes_1.f90: New test.

From-SVN: r118624
2006-11-09 18:42:28 +00:00
Paul Thomas
5b440a1cf4 [multiple changes]
2006-10-17  Paul Thomas <pault@gcc.gnu.org>

	PR fortran/20541
	* trans-array.c (gfc_trans_array_bounds): Test for and set
	negative stride of a non-constant bound array to zero.

	PR fortran/29392
	* data.c (create_character_intializer): Copy and simplify
	the expressions for the start and end of a sub-string
	reference.

2006-10-17  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/29392
	* gfortran.dg/data_char_3.f90: New test.

	PR fortran/20541
	* gfortran.dg/negative_automatic_size.f90: New test.

From-SVN: r117797
2006-10-16 22:29:46 +00:00
Kazu Hirata
b2a433730c intrinsic.texi: Fix typos.
* intrinsic.texi: Fix typos.
	* trans-array.c: Fix a comment typo.

From-SVN: r117722
2006-10-14 01:48:07 +00:00
Paul Thomas
5046aff56b [multiple changes]
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.

From-SVN: r117558
2006-10-08 16:21:55 +00:00
Paul Thomas
bfa7a1e994 re PR fortran/28914 (Code inside loop hangs; outside loop runs normally; runs OK on other compilers)
2006-09-09  Paul Thomas <pault@gcc.gnu.org>

	PR fortran/28914
	* trans-array.c (gfc_trans_array_constructor_value): Create a temporary
	loop variable to hold the current loop variable in case it is modified
	by the array constructor.

From-SVN: r116808
2006-09-10 04:53:18 +00:00
Erik Edelmann
7f0d6da9e8 re PR fortran/28416 (ICE on allocatable codes)
fortran/
2006-07-24  Erik Edelmann  <eedelman@gcc.gnu.org>

        PR fortran/28416
        * trans-array.c (gfc_conv_array_parameter): Give special treatment
        for ALLOCATABLEs if they are themselves dummy variables.

testsuite/
2006-07-24  Erik Edelmann  <eedelman@gcc.gnu.org>

        PR fortran/28416
        * gfortran.dg/allocatable_dummy_3.f90: New.

From-SVN: r115721
2006-07-24 20:15:59 +00:00
Francois-Xavier Coudert
d16b57dfef re PR fortran/28129 (gfortran -fbounds-check: Shows invalid array out of bounds error)
PR fortran/28129

	* trans-array.c (gfc_trans_array_bound_check): Add a locus
	argument, and use it in the error messages.
	(gfc_conv_array_index_offset): Donc perform bounds checking on
	the last dimension of assumed-size arrays.

	* gfortran.dg/bounds_check_4.f90: New test.

From-SVN: r115231
2006-07-06 20:37:36 +00:00
Paul Thomas
1855915abe re PR fortran/28174 (Corruption of multiple character arrays when passing array sections)
2006-07-04  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/28174
	* trans-array.c (gfc_conv_expr_descriptor): When building temp,
	ensure that the substring reference uses a new charlen.
	* trans-expr.c (gfc_conv_aliased_arg): Add the formal intent to
	the argument list, lift the treatment of missing string lengths
	from the above and implement the use of the intent.
	(gfc_conv_function_call): Add the extra argument to the call to
	the above.

	PR fortran/28167
	* trans-array.c (get_array_ctor_var_strlen): Treat a constant
	substring reference.
	* array.c (gfc_resolve_character_array_constructor): Remove 
	static attribute and add the gfc_ prefix, make use of element
	charlens for the expression and pick up constant string lengths
	for expressions that are not themselves constant.
	* gfortran.h : resolve_character_array_constructor prototype
	added.
	* resolve.c (gfc_resolve_expr): Call resolve_character_array_
	constructor again after expanding the constructor, to ensure
	that the character length is passed to the expression.

2006-07-04  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/28174
	* gfortran.dg/actual_array_substr_2.f90: New test.

	PR fortran/28167
	* gfortran.dg/actual_array_constructor_2.f90: New test.

From-SVN: r115182
2006-07-04 20:15:52 +00:00
Paul Thomas
32fdfa2dfa re PR fortran/28118 (ICE calling subroutine defined via explicit interface)
2006-06-24  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/28118
	* trans-array.c (gfc_conv_expr_descriptor): When building temp,
	use the substring reference to calculate the length if the
	expression does not have a charlen.

2006-06-24  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/28118
	* gfortran.dg/actual_array_substr_1.f90: New test.

From-SVN: r114964
2006-06-24 13:04:37 +00:00
Francois-Xavier Coudert
ef31fe6257 re PR fortran/27965 (invalid "Array bound mismatch" runtime error)
PR fortran/27965
	* trans-array.c (gfc_conv_ss_startstride): Correct the runtime
	conditions for bounds-checking. Check for nonzero stride.
	Don't check the last dimension of assumed-size arrays. Fix the
	dimension displayed in the error message.

From-SVN: r114724
2006-06-16 17:03:43 +00:00
Thomas Koenig
da4340a1ac trans-array.h (gfc_trans_create_temp_array): Add bool argument.
2006-06-15  Thomas Koenig <Thomas.Koenig@online.de>

	* trans-array.h (gfc_trans_create_temp_array):  Add bool
	argument.
	* trans-arrray.c (gfc_trans_create_temp_array): Add extra
	argument "function" to show if we are translating a function.
	If we are translating a function, perform checks whether
	the size along any argument is negative.  In that case,
	allocate size 0.
	(gfc_trans_allocate_storage):  Add function argument (as
	false) to gfc_trans_create_temp_array call.
	* trans-expr.c (gfc_conv_function_call):  Add function
	argument (as true) to gfc_trans_create_temp_array call.
	* trans-stmt.c (gfc_conv_elemental_dependencies): Add
	function argument (as false) to gfc_trans_create_temp_array
	call.
	* trans-intrinsic.c:  Likewise.

2006-06-15  Thomas Koenig <Thomas.Koenig@online.de>

	* gfortran.dg/allocate_zerosize_2.f90:  New test case.

From-SVN: r114677
2006-06-15 10:30:09 +00:00
Asher Langton
f6cf0340b9 re PR fortran/27786 ([4.1 only] Bad interaction between Cray pointer, assumed-size array and bounds checking)
* cray_pointers_2.f90: Add -fbounds-check compile flag.

	PR fortran/27786
	* trans-array.c (gfc_conv_array_ref): Eliminate bounds checking
	for assumed-size Cray pointees.

From-SVN: r114495
2006-06-08 21:00:26 +00:00
Francois-Xavier Coudert
dd18a33bd9 trans.c (gfc_msg_bounds, [...]): Add strings for common runtime error messages.
* trans.c (gfc_msg_bounds, gfc_msg_fault, gfc_msg_wrong_return):
	Add strings for common runtime error messages.
	(gfc_trans_runtime_check): Add a locus argument, use a string
	and not a string tree for the message.
	* trans.h (gfc_trans_runtime_check): Change prototype accordingly.
	(gfc_msg_bounds, gfc_msg_fault, gfc_msg_wrong_return): Add proto.
	* trans-const.c (gfc_strconst_bounds, gfc_strconst_fault,
	gfc_strconst_wrong_return, gfc_strconst_current_filename): Remove.
	(gfc_init_constants): Likewise.
	* trans-const.h: Likewise.
	* trans-decl.c (gfc_build_builtin_function_decls): Call to
	_gfortran_runtime_error has only one argument, the message string.
	* trans-array.h (gfc_conv_array_ref): Add a symbol argument and a
	locus.
	* trans-array.c (gfc_trans_array_bound_check): Build precise
	error messages.
	(gfc_conv_array_ref): Use the new symbol argument and the locus
	to build more precise error messages.
	(gfc_conv_ss_startstride): More precise error messages.
	* trans-expr.c (gfc_conv_variable): Give symbol reference and
	locus to gfc_conv_array_ref.
	(gfc_conv_function_call): Use the new prototype for
	gfc_trans_runtime_check.
	* trans-stmt.c (gfc_trans_goto): Build more precise error message.
	* trans-io.c (set_string): Likewise.
	* trans-intrinsic.c (gfc_conv_intrinsic_bound): Use new prototype
	for gfc_trans_runtime_check.

From-SVN: r114346
2006-06-03 17:28:33 +00:00
François-Xavier Coudert
ae73e07642 trans-array.c: Fix previous commit, which included parts of patches in preparation.
* trans-array.c: Fix previous commit, which included parts of
	patches in preparation.

From-SVN: r114219
2006-05-29 22:23:29 +00:00
Francois-Xavier Coudert
a64a81baf6 re PR fortran/19777 (-fbounds-check catches non-existent bounds violation)
PR fortran/19777

	* trans-array.c (gfc_conv_array_ref): Perform out-of-bounds
	checking for assumed-size arrrays for all but the last dimension.

	* gfortran.dg/bounds_check_2.f: Add new check for multidimensional
	arrays.

From-SVN: r114210
2006-05-29 19:21:27 +00:00
Francois-Xavier Coudert
7936f3e337 re PR fortran/19777 (-fbounds-check catches non-existent bounds violation)
PR fortran/19777

	* trans-array.c (gfc_conv_array_ref): Don't perform out-of-bounds
	checking for assumed-size arrrays.

	* gfortran.dg/bounds_check_2.f: New test.

From-SVN: r114153
2006-05-27 09:41:42 +00:00
Francois-Xavier Coudert
e8300d6eaf re PR libfortran/27524 (-fbounds-check interacts with array function)
PR fortran/27524

	* trans-array.c (gfc_trans_dummy_array_bias): Don't use stride as
	a temporary variable when -fbounds-check is enabled, since its
	value will be needed later.

	* gfortran.dg/bounds_check_1.f90: New test.

From-SVN: r114142
2006-05-26 21:18:45 +00:00
H.J. Lu
a635db3deb re PR fortran/27662 ([4.1 only]: Transpose doesn't work on function return)
gcc/fortran/

2006-05-19  H.J. Lu  <hongjiu.lu@intel.com>

	PR fortran/27662
	* trans-array.c (gfc_conv_expr_descriptor): Don't zere the
	first stride to indicate a temporary.
	* trans-expr.c (gfc_conv_function_call): Likewise.

gcc/testsuite/

2006-05-19  H.J. Lu  <hongjiu.lu@intel.com>

	PR fortran/27662
	* gfortran.dg/temporary_1.f90: New file.

From-SVN: r113922
2006-05-19 17:28:14 -07:00
Thomas Koenig
3a7e3b6994 re PR fortran/27470 (wrong memory allocator for derived types)
2005-05-10  Thomas Koenig  <Thomas.Koenig@online.de>

	PR fortran/27470
	* trans-array.c(gfc_array_allocate):  If ref->next exists
	that is if there is a statement like ALLOCATE(foo%bar(2)),
	F95 rules require that bar should be a pointer.

2005-05-10  Thomas Koenig  <Thomas.Koenig@online.de>

	PR fortran/27470
	* gfortran.dg/multiple_allocation_2.f90:  New test case.

From-SVN: r113680
2006-05-10 18:26:51 +00:00
Paul Thomas
636da744bb re PR fortran/24813 (ICE with scalarization LEN of character types)
2006-05-07  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/24813
	* trans-array.c (get_array_ctor_strlen): Remove static attribute.
	* trans.h: Add prototype for get_array_ctor_strlen.
	* trans-intrinsic.c (gfc_conv_intrinsic_len): Switch on EXPR_ARRAY
	and call get_array_ctor_strlen.

2006-05-07  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/24813
	* gfortran.dg/char_cons_len_1.f90: New test.

From-SVN: r113594
2006-05-07 05:46:26 +00:00
H.J. Lu
c69a7fb7a6 re PR fortran/27351 (Use variable after free in gfc_conv_array_transpose)
2006-04-29  H.J. Lu  <hongjiu.lu@intel.com>

	PR fortran/27351
	* trans-array.c (gfc_conv_array_transpose): Move gcc_assert
	before gfc_conv_expr_descriptor.

From-SVN: r113375
2006-04-29 07:25:42 -07:00
Paul Thomas
0e3e65bc57 re PR fortran/27122 (binary operator functions should require intent(in))
2006-04-21 Paul Thomas <pault@gcc.gnu.org>

	PR fortran/27122
	* resolve.c (resolve_function): Remove general restriction on auto
	character length function interfaces.
	(gfc_resolve_uops): Check restrictions on defined operator
	procedures.
	(resolve_types): Call the check for defined operators.

	PR fortran/27113
	* trans-array.c (gfc_trans_array_constructor_subarray): Remove
	redundant gfc_todo_error.
	(get_array_ctor_var_strlen): Remove typo in enum.

2006-04-21 Paul Thomas <pault@gcc.gnu.org>

	PR fortran/27122
	* gfortran.dg/defined_operators_1.f90: New test.
	* gfortran.dg/assumed_charlen_function_1.f90: Add new error and
	remove old ones associated, incorrectly, with Note 5.46.

	PR fortran/27113
	* gfortran.dg/character_array_constructor_1.f90: New test.

From-SVN: r113133
2006-04-21 05:10:22 +00:00
Thomas Koenig
3c86fb4e17 re PR fortran/26017 (allocate (a(1:-1)) should yield zero-sized array)
2006-04-16  Thomas Koenig  <Thomas.Koenig@online.de>

	PR fortran/26017
	* trans-array.c(gfc_array_init_size):  Introduce or_expr
	which is true if the size along any dimension
	is negative.  Create a temporary variable with base
	name size.  If or_expr is true, set the temporary to 0,
	to the normal size otherwise.

2006-04-16  Thomas Koenig  <Thomas.Koenig@online.de>

        * gfortran.dg/allocate_zerosize_1.f90:  New test.

From-SVN: r112988
2006-04-16 20:29:24 +00:00
Paul Thomas
f5f701ad00 re PR fortran/26822 (Scalarization of non-elemental intrinsic: __logical_4_l4)
2006-04-16  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/26822
	* intrinsic.c (add_functions): Mark LOGICAL as elemental.

	PR fortran/26787
	* expr.c (gfc_check_assign): Extend scope of error to include
	assignments to a procedure in the main program or, from a
	module or internal procedure that is not that represented by
	the lhs symbol. Use VARIABLE rather than l-value in message.

	PR fortran/27096
	* trans-array.c (gfc_trans_deferred_array): If the backend_decl
	is not a descriptor, dereference and then test and use the type.

	PR fortran/25597
	* trans-decl.c (gfc_trans_deferred_vars): Check if an array
	result, is also automatic character length.  If so, process
	the character length.

	PR fortran/18803
	PR fortran/25669
	PR fortran/26834
	* trans_intrinsic.c (gfc_walk_intrinsic_bound): Set
	data.info.dimen for bound intrinsics.
	* trans_array.c (gfc_conv_ss_startstride): Pick out LBOUND and
	UBOUND intrinsics and supply their shape information to the ss
	and the loop.

	PR fortran/27124
	* trans_expr.c (gfc_trans_function_call):  Add a new block, post,
	in to which all the argument post blocks are put.  Add this block
	to se->pre after a byref call or to se->post, otherwise.

2006-04-16  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/26787
	* gfortran.dg/proc_assign_1.f90: New test.
	* gfortran.dg/procedure_lvalue.f90: Change message.
	* gfortran.dg/namelist_4.f90: Add new error.

	PR fortran/27096
	* gfortran.dg/auto_pointer_array_result_1.f90

	PR fortran/27089
	* gfortran.dg/specification_type_resolution_1.f90

	PR fortran/18803
	PR fortran/25669
	PR fortran/26834
	* gfortran.dg/bounds_temporaries_1.f90: New test.

	PR fortran/27124
	* gfortran.dg/array_return_value_1.f90: New test.

From-SVN: r112981
2006-04-16 03:45:24 +00:00
H.J. Lu
20b1cbc33f re PR fortran/25619 (temporary array of constant size character type goes wrong)
gcc/fortran/

2006-04-04  H.J. Lu  <hongjiu.lu@intel.com>

	PR fortran/25619
	* trans-array.c (gfc_conv_expr_descriptor): Only dereference
	character pointer when copying temporary.

	PR fortran/23634
	* trans-array.c (gfc_conv_expr_descriptor): Properly copy
	temporary character with non constant size.

gcc/testsuite/

2006-04-04  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/23634
	PR fortran/25619
	* gfortran.dg/actual_array_constructor_1.f90: New testcase.

From-SVN: r112695
2006-04-04 21:47:51 -07:00
Erik Edelmann
763ccd4537 trans-array.c (gfc_trans_dealloc_allocated): Take a tree representation of the array to be deallocated as argument instead...
2006-04-02  Erik Edelmann  <eedelman@gcc.gnu.org>

        * trans-array.c (gfc_trans_dealloc_allocated): Take a
        tree representation of the array to be deallocated as argument
        instead of its gfc_symbol.
        (gfc_trans_deferred_array): Update call to
        gfc_trans_dealloc_allocated.
        * trans-array.h (gfc_trans_dealloc_allocated): Update prototype.
        * trans-expr.c (gfc_conv_function_call): Update call to
        gfc_trans_dealloc_allocated, get indirect reference to dummy
        arguments.


2006-04-02  Erik Edelmann  <eedelman@gcc.gnu.org>

        * gfortran.dg/allocatable_dummy_1.f90: Also check that allocatable
        dummy arguments work when the actual argument is itself a dummy
        argument of the caller.

From-SVN: r112625
2006-04-02 17:00:39 +00:00
Roger Sayle
37da9343f5 re PR fortran/25270 (testcases fail with a type mismatch)
PR fortran/25270
	* trans-array.c (gfc_trans_allocate_array_storage): In array index
	calculations use gfc_index_zero_node and gfc_index_one_node instead
	of integer_zero_node and integer_one_node respectively.
	(gfc_conv_array_transpose): Likewise.
	(gfc_conv_ss_startstride): Likewise.
	(gfc_trans_dummy_array_bias): Likewise.

From-SVN: r112608
2006-04-01 19:19:22 +00:00
Erik Edelmann
8e119f1b63 symbol.c (check_conflict): Allow allocatable function results, except for elemental functions.
fortran/
2006-03-11  Erik Edelmann  <eedelman@gcc.gnu.org>

        * symbol.c (check_conflict): Allow allocatable function results,
        except for elemental functions.
        * trans-array.c (gfc_trans_allocate_temp_array): Rename to ...
        (gfc_trans_create_temp_array): ... this, and add new argument callee_alloc.
        (gfc_trans_array_constructor, gfc_conv_loop_setup): Update call
        to gfc_trans_allocate_temp_array.
        * trans-array.h (gfc_trans_allocate_temp_array): Update prototype.
        * trans-expr.c (gfc_conv_function_call): Use new arg of
        gfc_trans_create_temp_array avoid pre-allocation of temporary
        result variables of pointer AND allocatable functions.
        (gfc_trans_arrayfunc_assign): Return NULL for allocatable functions.
        * resolve.c (resolve_symbol): Copy value of 'allocatable' attribute
        from sym->result to sym.

testsuite/
2006-03-08  Paul Thomas  <pault@gcc.gnu.org>
            Erik Edelmann  <eedelman@gcc.gnu.org>

        * gfortran.dg/allocatable_function_1.f90: New.
        * gfortran.dg/allocatable_function_2.f90: New.

From-SVN: r111951
2006-03-10 23:28:38 +00:00
Paul Thomas
ad5dd90de0 re PR fortran/26257 (internal compiler error: Segmentation fault, on function call with assumed shape array parameter)
2006-03-09 Paul Thomas <pault@gcc.gnu.org>

	PR fortran/26257
	* trans-array.c (gfc_conv_expr_descriptor): Exclude calculation of
	the offset and data when se->data_not_needed is set.
	* trans.h: Include the data_not_need bit in gfc_se.
	* trans-intrinsic.c (gfc_conv_intrinsic_size): Set it for SIZE.

2006-03-09 Paul Thomas <pault@gcc.gnu.org>

	* PR fortran/26257
	gfortran.dg/auto_char_len_3.f90: New test

From-SVN: r111860
2006-03-09 05:52:06 +00:00
Paul Thomas
42a0e16c2d trans-array.c (gfc_trans_dealloc_allocated): New function.
fortran/
2005-03-06  Paul Thomas  <pault@gcc.gnu.org>
            Erik Edelmann  <eedelman@gcc.gnu.org>

        * trans-array.c (gfc_trans_dealloc_allocated): New function.
        (gfc_trans_deferred_array): Use it, instead of inline code.
        * trans-array.h: Prototype for gfc_trans_dealloc_allocated().
        * trans-expr.c (gfc_conv_function_call): Deallocate allocated
        ALLOCATABLE, INTENT(OUT) arguments upon procedure entry.


testsuite/
2005-03-06  Paul Thomas  <pault@gcc.gnu.org>
            Erik Edelmann  <eedelman@gcc.gnu.org>

        * gfortran.dg/allocatable_dummy_1.f90: Take into account that
        INTENT(OUT) arguments shall be deallocated upon procedure entry.


Co-Authored-By: Erik Edelmann <eedelman@gcc.gnu.org>

From-SVN: r111795
2006-03-06 23:12:41 +00:00
Thomas Koenig
5b725b8d04 re PR fortran/25031 ([4.1 only] Allocatable array can be reallocated.)
2006-03-03  Thomas Koenig  <Thomas.Koenig@online.de>

	PR fortran/25031
	* trans-array.h:  Adjust gfc_array_allocate prototype.
	* trans-array.c (gfc_array_allocate):  Change type of
	gfc_array_allocatate to bool.  Function returns true if
	it operates on an array.  Change second argument to gfc_expr.
	Find last reference in chain.
	If the function operates on an allocatable array, emit call to
	allocate_array() or allocate64_array().
	* trans-stmt.c (gfc_trans_allocate):  Code to follow to last
	reference has been moved to gfc_array_allocate.
	* trans.h:  Add declaration for gfor_fndecl_allocate_array and
	gfor_fndecl_allocate64_array.
	(gfc_build_builtin_function_decls):  Add gfor_fndecl_allocate_array
	and gfor_fndecl_allocate64_array.

2006-03-03  Thomas Koenig  <Thomas.Koenig@online.de>

	PR fortran/25031
	* runtime/memory.c:  Adjust copyright years.
	(allocate_array):  New function.
	(allocate64_array):  New function.
	* libgfortran.h (error_codes):  Add ERROR_ALLOCATION.

2006-03-03  Thomas Koenig  <Thomas.Koenig@online.de>

	PR fortran/25031
	* multiple_allocation_1.f90:  New test.

From-SVN: r111677
2006-03-03 16:18:46 +00:00
Paul Thomas
61321991ff re PR fortran/26393 (ICE with function returning variable lenght array)
2006-03-01  Paul Thomas  <pault@gcc.gnu.org>

	* iresolve.c (gfc_resolve_dot_product):  Remove any difference in
	treatment of logical types.
	* trans-intrinsic.c (gfc_conv_intrinsic_dot_product):  New function. 

	PR fortran/26393
	* trans-decl.c (gfc_get_symbol_decl): Extend condition that symbols
	must be referenced to include unreferenced symbols in an interface
	body. 

	PR fortran/20938
	* trans-array.c (gfc_conv_resolve_dependencies): Add call to
	gfc_are_equivalenced_arrays.
	* symbol.c (gfc_free_equiv_infos, gfc_free_equiv_lists): New
	functions. (gfc_free_namespace): Call them.
	* trans-common.c (copy_equiv_list_to_ns): New function.
	(add_equivalences): Call it.
	* gfortran.h: Add equiv_lists to gfc_namespace and define
	gfc_equiv_list and gfc_equiv_info.
	* dependency.c (gfc_are_equivalenced_arrays): New function.
	(gfc_check_dependency): Call it.
	* dependency.h: Prototype for gfc_are_equivalenced_arrays.

2006-03-01  Paul Thomas  <pault@gcc.gnu.org>

	* gfortran.dg/logical_dot_product.f90: New test. 

	PR fortran/26393
	* gfortran.dg/used_interface_ref.f90: New test.

	PR fortran/20938
	* gfortran.dg/dependency_2.f90: New test.
	* gfortran.fortran-torture/execute/where17.f90: New test.
	* gfortran.fortran-torture/execute/where18.f90: New test.
	* gfortran.fortran-torture/execute/where19.f90: New test.
	* gfortran.fortran-torture/execute/where20.f90: New test.

From-SVN: r111616
2006-03-01 22:24:19 +00:00
Erik Edelmann
5b0b72518b re PR fortran/25806 (problems with functions returning array pointers?)
fortran/
2006-02-12  Erik Edelmann  <eedelman@gcc.gnu.org>

        PR fortran/25806
        * trans-array.c (gfc_trans_allocate_array_storage): New argument
        dealloc; free the temporary only if dealloc is true.
        (gfc_trans_allocate_temp_array): New argument bool dealloc, to be 
        passed onwards to gfc_trans_allocate_array_storage.
        (gfc_trans_array_constructor, gfc_conv_loop_setup): Update call to
        gfc_trans_allocate_temp_array.
        * trans-array.h (gfc_trans_allocate_temp_array): Update function
        prototype.
        * trans-expr.c (gfc_conv_function_call): Set new argument 'dealloc'
        to gfc_trans_allocate_temp_array to false in case of functions
        returning pointers.
        (gfc_trans_arrayfunc_assign): Return NULL for functions returning
        pointers.


testsuite/
2006-02-12  Erik Edelmann  <eedelman@gcc.gnu.org>

        PR fortran/25806
        * gfortran.dg/ret_pointer_2.f90: New test.

From-SVN: r110893
2006-02-12 17:34:15 +00:00
Jakub Jelinek
417ab240ee backport: trans-decl.c (create_function_arglist): Handle dummy functions.
Backport from gomp-20050608-branch
	* trans-decl.c (create_function_arglist): Handle dummy functions.

	* trans-decl.c (gfc_get_symbol_decl): Revert explicit setting of
	TYPE_SIZE_UNIT.
	(gfc_trans_vla_type_sizes): Also "gimplify"
	GFC_TYPE_ARRAY_DATAPTR_TYPE for GFC_DESCRIPTOR_TYPE_P types.
	* trans-array.c (gfc_trans_deferred_array): Call
	gfc_trans_vla_type_sizes.

	* trans-decl.c (saved_function_decls, saved_parent_function_decls):
	Remove unnecessary initialization.
	(create_function_arglist): Make sure __result has complete type.
	(gfc_get_fake_result_decl): Change current_fake_result_decl into
	a tree chain.  For entry master, create a separate variable
	for each result name.  For BT_CHARACTER results, call
	gfc_finish_var_decl on length even if it has been already created,
	but not pushdecl'ed.
	(gfc_trans_vla_type_sizes): For function/entry result, adjust
	result value type, not the FUNCTION_TYPE.
	(gfc_generate_function_code): Adjust for current_fake_result_decl
	changes.
	(gfc_trans_deferred_vars): Likewise.  Call gfc_trans_vla_type_sizes
	even on result if it is assumed-length character.

	* trans-decl.c (gfc_trans_dummy_character): Add SYM argument.
	Call gfc_trans_vla_type_sizes.
	(gfc_trans_auto_character_variable): Call gfc_trans_vla_type_sizes.
	(gfc_trans_vla_one_sizepos, gfc_trans_vla_type_sizes_1,
	gfc_trans_vla_type_sizes): New functions.
	(gfc_trans_deferred_vars): Adjust gfc_trans_dummy_character
	callers.  Call gfc_trans_vla_type_sizes on assumed-length
	character parameters.
	* trans-array.c (gfc_trans_array_bounds,
	gfc_trans_auto_array_allocation, gfc_trans_dummy_array_bias): Call
	gfc_trans_vla_type_sizes.
	* trans.h (gfc_trans_vla_type_sizes): New prototype.

	* trans-decl.c (gfc_build_qualified_array): For non-assumed-size
	arrays without constant size, create also an index var for
	GFC_TYPE_ARRAY_SIZE (type).  If the type is incomplete, complete
	it as 0..size-1.
	(gfc_create_string_length): Don't call gfc_defer_symbol_init
	if just creating DECL_ARGUMENTS.
	(gfc_get_symbol_decl): Call gfc_finish_var_decl and
	gfc_defer_symbol_init even if ts.cl->backend_decl is already
	set to a VAR_DECL that doesn't have DECL_CONTEXT yet.
	(create_function_arglist): Rework, so that hidden length
	arguments for CHARACTER parameters are created together with
	the parameters.  Resolve ts.cl->backend_decl for CHARACTER
	parameters.  If the argument is a non-constant length array
	or CHARACTER, ensure PARM_DECL has different type than
	its DECL_ARG_TYPE.
	(generate_local_decl): Call gfc_get_symbol_decl even
	for non-referenced non-constant length CHARACTER parameters
	after optionally issuing warnings.
	* trans-array.c (gfc_trans_array_bounds): Set last stride
	to GFC_TYPE_ARRAY_SIZE (type) to initialize it as well.
	(gfc_trans_dummy_array_bias): Initialize GFC_TYPE_ARRAY_SIZE (type)
	variable as well.

	* trans-expr.c (gfc_conv_expr_val): Fix comment typo.

	* trans-stmt.c (gfc_trans_simple_do): Fix comment.

From-SVN: r110653
2006-02-06 18:15:51 +01:00