Commit Graph

323 Commits

Author SHA1 Message Date
Jerry DeLisle 899583cb40 re PR libfortran/32702 (crash when printing big character variable)
2007-07-09  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/32702
	* io/unix.c (unix_stream): Restore buffer pointer and small_buffer.
	(fd_alloc): If the number of bytes needed is greater than the default
	BUFFER_SIZE, allocate a new buffer large enough.  Free the old buffer if
	necessary. (fd_sfree): Restore use of buffer pointer.
	(fd_close): Likewise. (fd_open): Likewise.
	(init_error_stream): Likewise.

From-SVN: r126510
2007-07-10 05:37:29 +00:00
Jerry DeLisle 8d917a24a7 re PR fortran/32678 ([4.2, 4.1]GFortan works incorrectly when writing with FORMAT Tx)
2007-07-08  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/32678
	* io/transfer.c (formatted_transfer_scalar): Don't allow pending_spaces
	to go negative.

From-SVN: r126473
2007-07-09 00:15:15 +00:00
Steven G. Kargl 8eacc23d94 [multiple changes]
2007-07-02  Steven G. Kargl  <kargl@gcc.gnu.org>

	Restore collateral damage from ISO C Binding merge.

        2007-06-29  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/32456
	* io/unit.c (filename_from_unit): Don't use find_unit, instead search
	for unit directly.

From-SVN: r126238
2007-07-02 23:29:27 +00:00
Christopher D. Rickett a8b3b0b633 [multiple changes]
2007-07-01  Christopher D. Rickett  <crickett@lanl.gov>

	* interface.c (gfc_compare_derived_types): Special case for comparing
	derived types across namespaces.
	(gfc_compare_types): Deal with BT_VOID.
	(compare_parameter): Use BT_VOID to accept ISO C Binding pointers.
	* trans-expr.c (gfc_conv_function_call): Remove setting parm_kind
	to SCALAR
	(gfc_conv_initializer): Deal with ISO C Binding NULL_PTR and 
	NULL_FUNPTR.
	(gfc_conv_expr): Convert expressions for ISO C Binding derived types.
	* symbol.c (gfc_set_default_type): BIND(C) variables should not be
	implicitly declared.
	(check_conflict): Add BIND(C) and check for conflicts.
	(gfc_add_explicit_interface): Whitespace.	
	(gfc_add_is_bind_c): New function.  
	(gfc_copy_attr): Use it.
	(gfc_new_symbol): Initialize ISO C Binding objects.
	(get_iso_c_binding_dt):  New function.
	(verify_bind_c_derived_type): Ditto.
	(gen_special_c_interop_ptr): Ditto.
	(add_formal_arg): Ditto.
	(gen_cptr_param): Ditto.
	(gen_fptr_param): Ditto.
	(gen_shape_param): Ditto.
	(add_proc_interface): Ditto.
	(build_formal_args): Ditto.
	(generate_isocbinding_symbol):  Ditto.
	(get_iso_c_sym):  Ditto.
	* decl.c (num_idents_on_line, has_name_equals): New variables.
	(verify_c_interop_param): New function.
	(build_sym): Finish binding labels and deal with COMMON blocks.
	(add_init_expr_to_sym): Check if the initialized expression is
	an iso_c_binding named constants
	(variable_decl): Set ISO C Binding type_spec components.
	(gfc_match_kind_spec): Check match for C interoperable kind.
	(match_char_spec): Fix comment. Chnage gfc_match_small_int
	to gfc_match_small_int_expr.  Check for C interoperable kind.
	(match_type_spec): Clear the current binding label.
	(match_attr_spec): Add DECL_IS_BIND_C.  If BIND(C) is found, use it
	to set attributes.
	(set_binding_label): New function.
	(set_com_block_bind_c): Ditto.
	(verify_c_interop): Ditto.
	(verify_com_block_vars_c_interop): Ditto.
	(verify_bind_c_sym): Ditto.
	(set_verify_bind_c_sym): Ditto.
	(set_verify_bind_c_com_block): Ditto.
	(get_bind_c_idents): Ditto.
	(gfc_match_bind_c_stmt): Ditto.
	(gfc_match_data_decl): Use num_idents_on_line.
	(match_result): Deal with right paren in BIND(C).
	(gfc_match_suffix): New function.
	(gfc_match_function_decl): Use it.  Code is re-arranged to deal with
	ISO C Binding result clauses.
	(gfc_match_subroutine):  Deal with BIND(C).
 	(gfc_match_bind_c): New function.
	(gfc_get_type_attr_spec): New function.  Code is re-arranged in and
	taken from gfc_match_derived_decl.
	(gfc_match_derived_decl): Add check for BIND(C).
	* trans-common.c: Forward declare gfc_get_common.
	(gfc_sym_mangled_common_id): Change arg from 'const char *name' to
	'gfc_common_head *com'.  Check for ISO C Binding of the common block.
	(build_common_decl): 'com->name' to 'com in SET_DECL_ASSEMBLER_NAME.
	* gfortran.h: Add GFC_MAX_BINDING_LABEL_LEN
	(bt): Add BT_VOID
	(sym_flavor): Add FL_VOID.
 	(iso_fortran_env_symbol, iso_c_binding_symbol, intmod_id): New enum
	(CInteropKind_t): New struct.
	(c_interop_kinds_table): Use it.  Declare an array of structs.
	(symbol_attribute): Add is_bind_c, is_c_interop, and is_iso_c
	bitfields.
	(gfc_typespec): Add is_c_interop; is_iso_c, and f90_type members.
	(gfc_symbol): Add from_intmod, intmod_sym_id, binding_label, and
	common_block members.
	(gfc_common_head): Add binding_label and is_bind_c members.
	(gfc_gsymbol): Add sym_name, mod_name, and binding_label members.
	Add prototypes for get_c_kind, gfc_validate_c_kind, 
	gfc_check_any_c_kind, gfc_add_is_bind_c, gfc_add_value,
	verify_c_interop, verify_c_interop_param, verify_bind_c_sym,
	verify_bind_c_derived_type, verify_com_block_vars_c_interop,
	generate_isocbinding_symbol, get_iso_c_sym, gfc_iso_c_sub_interface
	* iso-c-binding.def: New file. This file contains the definitions
	of the types provided by the Fortran 2003 ISO_C_BINDING intrinsic
	module.
	* trans-const.c (gfc_conv_constant_to_tree): Deal with C_NULL_PTR
	 or C_NULL_FUNPTR expressions.
	* expr.c (gfc_copy_expr): Add BT_VOID case.  For BT_CHARACTER, the
	ISO C Binding requires a minimum string length of 1 for '\0'.  
	* module.c (intmod_sym): New struct.
	(pointer_info): Add binding_label member.
	(write_atom): Set len to 0 for NULL pointers. Check for NULL p and *p.
	(ab_attribute): Add AB_IS_BIND_C, AB_IS_C_INTEROP and AB_IS_ISO_C.
	(attr_bits): Add "IS_BIND_C", "IS_C_INTEROP", and "IS_ISO_C".
	(mio_symbol_attribute): Deal with ISO C Binding attributes.
	(bt_types): Add "VOID".
	(mio_typespec): Deal with ISO C Binding components.
	(mio_namespace_ref): Add intmod variable. 
	(mio_symbol): Check for symbols from an intrinsic module.
	(load_commons): Check for BIND(C) common block.
	(read_module): Read binding_label and use it.
	(write_common): Add label.  Write BIND(C) info.
	(write_blank_common): Blank commons are not BIND(C).  Explicitly
	set is_bind_c=0.
	(write_symbol): Deal with binding_label.
	(sort_iso_c_rename_list): New function.
	(import_iso_c_binding_module): Ditto.
	(create_int_parameter): Add to args.
	(use_iso_fortran_env_module): Adjust to deal with iso_c_binding
	intrinsic module.
	* trans-types.c (c_interop_kinds_table): new array of structs. 
	(gfc_validate_c_kind): New function.
	(gfc_check_any_c_kind): Ditto.
	(get_real_kind_from_node): Ditto.
	(get_int_kind_from_node): Ditto.
	(get_int_kind_from_width): Ditto.
	(get_int_kind_from_minimal_width): Ditto.
	(init_c_interop_kinds): Ditto.
	(gfc_init_kinds): call init_c_interop_kinds.
	(gfc_typenode_for_spec): Adjust for BT_VOID and ISO C Binding pointers.
	Adjust handling of BT_DERIVED.
	(gfc_sym_type): Whitespace.
	(gfc_get_derived_type):  Account for iso_c_binding derived types
	* resolve.c (is_scalar_expr_ptr): New function.
	(gfc_iso_c_func_interface): Ditto.
	(resolve_function): Use gfc_iso_c_func_interface. 
	(set_name_and_label): New function.
	(gfc_iso_c_sub_interface): Ditto.
	(resolve_specific_s0): Use gfc_iso_c_sub_interface.
	(resolve_bind_c_comms): New function.
	(resolve_bind_c_derived_types): Ditto.
	(gfc_verify_binding_labels): Ditto.
	(resolve_fl_procedure): Check for ISO C interoperability.
	(resolve_symbol): Check C interoperability.
	(resolve_types): Walk the namespace.  Check COMMON blocks.
	* trans-decl.c (gfc_sym_mangled_identifier):  Prevent the mangling
	of identifiers that have an assigned binding label.
	(gfc_sym_mangled_function_id): Use the binding label rather than
	the mangled name.
	(gfc_finish_var_decl): Put variables that are BIND(C) into a common
	segment of the object file, because this is what C would do.
	(gfc_create_module_variable): Conver to proper types
	(set_tree_decl_type_code): New function.
	(generate_local_decl): Check dummy variables and derived types for
	ISO C Binding attributes.
	* match.c (gfc_match_small_int_expr): New function.
	(gfc_match_name_C): Ditto.
	(match_common_name): Deal with ISO C Binding in COMMON blocks
	* trans-io.c (transfer_expr):  Deal with C_NULL_PTR or C_NULL_FUNPTR
	expressions
	* match.h: Add prototypes for gfc_match_small_int_expr,
	gfc_match_name_C, match_common_name, set_com_block_bind_c,
	set_binding_label, set_verify_bind_c_sym,
	set_verify_bind_c_com_block, get_bind_c_idents,
	gfc_match_bind_c_stmt, gfc_match_suffix, gfc_match_bind_c,
	gfc_get_type_attr_spec
	* parse.c (decode_statement): Use gfc_match_bind_c_stmt
	(parse_derived): Init *derived_sym = NULL, and gfc_current_block
	later for valiadation.
	* primary.c (got_delim): Set ISO C Binding components of ts.
	(match_logical_constant): Ditto.
	(match_complex_constant): Ditto.
	(match_complex_constant): Ditto.
	(gfc_match_rvalue): Check for existence of at least one arg for
	C_LOC, C_FUNLOC, and C_ASSOCIATED.
	* misc.c (gfc_clear_ts): Clear ISO C Bindoing components in ts.
	(get_c_kind): New function.

2007-07-01  Christopher D. Rickett  <crickett@lanl.gov>

	* Makefile.in: Add support for iso_c_generated_procs.c and
	iso_c_binding.c.
	* Makefile.am: Ditto.
	* intrinsics/iso_c_generated_procs.c: New file containing helper
	functions.
	* intrinsics/iso_c_binding.c: Ditto.
	* intrinsics/iso_c_binding.h: New file
	* gfortran.map: Include the __iso_c_binding_c_* functions.
	* libgfortran.h: define GFC_NUM_RANK_BITS.

2007-06-23  Christopher D. Rickett  <crickett@lanl.gov>

	* bind_c_array_params.f03: New files for Fortran 2003 ISO C Binding.
	* bind_c_coms.f90: Ditto.
	* bind_c_coms_driver.c: Ditto.
	* bind_c_dts.f90: Ditto.
	* bind_c_dts_2.f03: Ditto.
	* bind_c_dts_2_driver.c: Ditto.
	* bind_c_dts_3.f03: Ditto.
	* bind_c_dts_4.f03: Ditto.
	* bind_c_dts_driver.c: Ditto.
	* bind_c_implicit_vars.f03: Ditto.
	* bind_c_procs.f03: Ditto.
	* bind_c_usage_2.f03: Ditto.
	* bind_c_usage_3.f03: Ditto.
	* bind_c_usage_5.f03: Ditto.
	* bind_c_usage_6.f03: Ditto.
	* bind_c_usage_7.f03: Ditto.
	* bind_c_vars.f90: Ditto.
	* bind_c_vars_driver.c: Ditto.
	* binding_c_table_15_1.f03: Ditto.
	* binding_label_tests.f03: Ditto.
	* binding_label_tests_10.f03: Ditto.
	* binding_label_tests_10_main.f03: Ditto.
	* binding_label_tests_11.f03: Ditto.
	* binding_label_tests_11_main.f03: Ditto.
	* binding_label_tests_12.f03: Ditto.
	* binding_label_tests_13.f03: Ditto.
	* binding_label_tests_13_main.f03: Ditto.
	* binding_label_tests_14.f03: Ditto.
	* binding_label_tests_2.f03: Ditto.
	* binding_label_tests_3.f03: Ditto.
	* binding_label_tests_4.f03: Ditto.
	* binding_label_tests_5.f03: Ditto.
	* binding_label_tests_6.f03: Ditto.
	* binding_label_tests_7.f03: Ditto.
	* binding_label_tests_8.f03: Ditto.
	* binding_label_tests_9.f03: Ditto.
	* c_assoc.f90: Ditto.
	* c_assoc_2.f03: Ditto.
	* c_f_pointer_shape_test.f90: Ditto.
	* c_f_pointer_tests.f90: Ditto.
	* c_f_tests_driver.c: Ditto.
	* c_funloc_tests.f03: Ditto.
	* c_funloc_tests_2.f03: Ditto.
	* c_funloc_tests_3.f03: Ditto.
	* c_funloc_tests_3_funcs.c: Ditto.
	* c_kind_params.f90: Ditto.
	* c_kind_tests_2.f03: Ditto.
	* c_kinds.c: Ditto.
	* c_loc_driver.c: Ditto.
	* c_loc_test.f90: Ditto.
	* c_loc_tests_2.f03: Ditto.
	* c_loc_tests_2_funcs.c: Ditto.
	* c_loc_tests_3.f03: Ditto.
	* c_loc_tests_4.f03: Ditto.
	* c_loc_tests_5.f03: Ditto.
	* c_loc_tests_6.f03: Ditto.
	* c_loc_tests_7.f03: Ditto.
	* c_loc_tests_8.f03: Ditto.
	* c_ptr_tests.f03: Ditto.
	* c_ptr_tests_10.f03: Ditto.
	* c_ptr_tests_5.f03: Ditto.
	* c_ptr_tests_7.f03: Ditto.
	* c_ptr_tests_7_driver.c: Ditto.
	* c_ptr_tests_8.f03: Ditto.
	* c_ptr_tests_8_funcs.c: Ditto.
	* c_ptr_tests_9.f03: Ditto.
	* c_ptr_tests_driver.c: Ditto.
	* c_size_t_driver.c: Ditto.
	* c_size_t_test.f03: Ditto.
	* com_block_driver.f90: Ditto.
	* global_vars_c_init.f90: Ditto.
	* global_vars_c_init_driver.c: Ditto.
	* global_vars_f90_init.f90: Ditto.
	* global_vars_f90_init_driver.c: Ditto.
	* interop_params.f03: Ditto.
	* iso_c_binding_only.f03: Ditto.
	* iso_c_binding_rename_1.f03: Ditto.
	* iso_c_binding_rename_1_driver.c: Ditto.
	* iso_c_binding_rename_2.f03: Ditto.
	* iso_c_binding_rename_2_driver.c: Ditto.
	* kind_tests_2.f03: Ditto.
	* kind_tests_3.f03: Ditto.
	* module_md5_1.f90: Ditto.
	* only_clause_main.c: Ditto.
	* print_c_kinds.f90: Ditto.
	* test_bind_c_parens.f03: Ditto.
	* test_c_assoc.c: Ditto.
	* test_com_block.f90: Ditto.
	* test_common_binding_labels.f03: Ditto.
	* test_common_binding_labels_2.f03: Ditto.
	* test_common_binding_labels_2_main.f03: Ditto.
	* test_common_binding_labels_3.f03: Ditto.
	* test_common_binding_labels_3_main.f03: Ditto.
	* test_only_clause.f90: Ditto.
	* use_iso_c_binding.f90: Ditto.
	* value_5.f90: Ditto.
	* value_test.f90: Ditto.
	* value_tests_f03.f90: Ditto.

From-SVN: r126185
2007-07-02 02:47:21 +00:00
Jerry DeLisle c767280aa7 re PR fortran/32554 ([4.2 Only] Bug in P formatting)
2007-07-01  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/32554
	* io/write.c (output_float): Set edigits to a fixed size, avoiding
	variation in field width calculation and eliminate buffer overrun.

From-SVN: r126173
2007-07-01 15:46:33 +00:00
Jerry DeLisle d1d92e95d2 re PR libfortran/32456 (IO error message should show Unit/Filename)
2007-06-29  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/32456
	* io/unit.c (filename_from_unit): Don't use find_unit, instead search
	for unit directly.

From-SVN: r126119
2007-06-29 19:39:21 +00:00
Jerry DeLisle 87557722c8 re PR libfortran/32456 (IO error message should show Unit/Filename)
2007-06-24  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/32456
	* runtime/error.c (show_locus): Update to emit the unit number
	and file name involved with the error.  Use new function
	filename_from_unit.
	* libgfortran.h (filename_from_unit): Declare new function.
	* io/unit.c (init_units): Set the unit file name for stdin, stdout,
	and stderr for use later in error reporting.
	(filename_from_unit): Add this new function.

From-SVN: r125989
2007-06-24 22:56:21 +00:00
Jerry DeLisle 69774e69a7 re PR fortran/32446 (F0.n output format fails with large numbers)
2007-06-24  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/32446
	* io/write.c (output_float): Calculate ndigits correctly for large
	numbered formats that must pad zeros before the decimal point.

From-SVN: r125985
2007-06-24 18:54:50 +00:00
Jerry DeLisle 82fa3fc0d3 re PR fortran/32235 (incorrectly position text file after backspace)
2007-06-10  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/32235
	* io/transfer.c (st_read): Remove test for end of file condition.
	(next_record_r): Add test for end of file condition.

From-SVN: r125606
2007-06-10 22:50:47 +00:00
Janne Blomqvist 88fdfd5a86 string.c (compare0): Use gfc_charlen_type instead of int.
2007-05-27  Janne Blomqvist  <jb@gcc.gnu.org>

	* runtime/string.c (compare0): Use gfc_charlen_type instead of int.
	(fstrlen): Likewise.
	(find_option): Likewise.
	(fstrcpy): Use gfc_charlen_type instead of int, return length.
	(cf_strcpy): Likewise.
	* libgfortran.h: Change string prototypes to use gfc_charlen_type.
	* io/open.c (new_unit): Use snprintf if available.
	* io/list_read.c (nml_touch_nodes): Use memcpy instead of strcpy/strcat.
	(nml_read_obj): Likewise.
	* io/transfer.c (st_set_nml_var): Likewise.
	* io/write.c (output_float): Use snprintf if available.
	(nml_write_obj) Use memcpy instead of strcpy/strcat.

From-SVN: r125100
2007-05-27 00:15:22 +03:00
Janne Blomqvist c132497f1b unix.c (unix_stream): Rearrange struct members, remove small_buffer.
2007-05-26  Janne Blomqvist  <jb@gcc.gnu.org>

	* io/unix.c (unix_stream): Rearrange struct members, remove
	small_buffer.
	(int_stream): New struct.
	(fd_alloc): Always use existing buffer, never reallocate.
	(fd_sfree): Remove check for buffer != small_buffer.
	(fd_close): Likewise.
	(mem_alloc_r_at): Change to use int_stream.
	(mem_alloc_w_at): Likewise.
	(mem_read): Likewise.
	(mem_write): Likewise.
	(mem_set): Likewise.
	(mem_truncate): Likewise.
	(mem_close): Likewise.
	(mem_sfree): Likewise.
	(empty_internal_buffer): Likewise.
	(open_internal): Likewise.

From-SVN: r125099
2007-05-26 23:50:21 +03:00
Jerry DeLisle 853c0ad7f0 transfer.c (unformatted_read): Use size from front end eliminating use of size_from_real_kind.
2007-05-25  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	* io/transfer.c (unformatted_read): Use size from front end eliminating
	use of size_from_real_kind. (unformatted_write): Ditto.

From-SVN: r125064
2007-05-25 17:41:17 +00:00
Tobias Burnus 80bcbc8044 re PR libfortran/31915 (Failure with unf_io_convert_3.f90)
2007-05-15  Tobias Burnus  <burnus@net-b.de>

        PR libfortran/31915
        * io/transfer.c (unformatted_read): Use proper size for real(10).
          (unformatted_write): Ditto.

From-SVN: r124741
2007-05-15 12:16:46 +02:00
Jerry DeLisle d5f9d0802c re PR libfortran/31880 ([4.2 only] silent data corruption in gfortran read statement)
2007-05-09  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/31880
	* io/unix.c (fd_alloc_r_at): Fix calculation of physical offset.

From-SVN: r124588
2007-05-10 01:01:27 +00:00
Francois-Xavier Coudert 25a5e75613 re PR libfortran/31607 (CALL SYSTEM produces garbled output when writing to a buffered file)
PR libfortran/31607
	* intrinsics/system.c (system_sub): Call flush_all_units.
	* io/io.h (flush_all_units): Move prototype to libgfortran.h.
	* libgfortran.h (flush_all_units): Add prototype.

From-SVN: r124510
2007-05-07 19:48:40 +00:00
Jerry DeLisle cb13c28858 re PR fortran/31201 (Too large unit number generates wrong code)
2007-05-06  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/31201
	* runtime/error.c (runtime_error_at): New function.
	(generate_error): Export this function.
	* gfortran.map: Add _gfortran_generate_error and
	_gfortran_runtime_error_at.
	* libgfortran.h: Add comment to reference error codes in front end.
	(library_start): Locate prototype with library_end macro and add
	a new comment.  Add prototype for runtime_error_at. Export prototype for
	generate_error.
	* io/lock.c (library_start): Fix check for error condition.
	* io/transfer.c (data_transfer_init): Add library check.

From-SVN: r124479
2007-05-06 22:28:31 +00:00
Daniel Franke dcdc26dfd5 re PR target/22539 (Internal compiler error with maximum sized array)
gcc/fortran:
2007-05-04  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/22539
	* intrinsic.c (add_subroutines): Added FSEEK.
	* intrinsic.h (gfc_resolve_fseek_sub, gfc_check_fseek_sub): New.
	* iresolve.c (gfc_resolve_fseek_sub): New.
	* check.c (gfc_check_fseek_sub): New.
	* intrinsic.texi (FSEEK): Updated.

gcc/testsuite:
2007-05-01  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/22539
	* gfortran.dg/fseek.f90: New test.

libgfortran:
2007-05-04  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/22539
	* io/intrinsics.c (fseek_sub): New.
	* io/unix.c (fd_fseek): Change logical and physical offsets only
	if seek succeeds.
	* gfortran.map (fseek_sub): New.

From-SVN: r124437
2007-05-04 14:02:18 -04:00
Francois-Xavier Coudert e50443368c re PR libfortran/31210 (I/O of string with (non-constant) zero length)
PR libfortran/31210
	* io/transfer.c (transfer_character): Avoid passing a NULL
	pointer as source to the transfer routines, if the string length
	is zero.

From-SVN: r124428
2007-05-04 15:14:07 +00:00
Jerry DeLisle d10fb73e91 re PR libfortran/31501 (libgfortran internal unit I/O performance issues)
2007-04-28  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/31501
	* io/list_read.c (next_char): Fix whitespace.
	* io/io.h: Remove prototypes and define macros for is_array_io,
	is_stream_io, and is_internal_unit.
	* io/unit.c (is_array_io), (is_internal_unit), (is_stream_io): Delete
	these functions.
	* io/transfer.c (read_sf): Change handling of internal_unit to make a
	single call to salloc_r and use memcpy to transfer the data.

From-SVN: r124266
2007-04-28 23:23:35 +00:00
Jerry DeLisle 16d962d92c re PR libfortran/31532 (INQUIRE(...,POSITION=...) not standard conforming)
2007-04-27  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/31532
	* io/file_pos.c (st_backspace): Set flags.position for end of file
	condition and use new function update_position.
	(st_endfile): Use new function update_position.
	* io/io.h: Add prototype for new function.
	* io/inquire.c (inquire_via_unit): If not direct access, set NEXTREC
	to zero.
	* io/unit.c (update_position): New function to update position info
	used by inquire.
	* io/transfer.c (next_record): Fix typo and use new function.

From-SVN: r124252
2007-04-28 02:03:21 +00:00
Thomas Koenig e08e57d0c5 re PR fortran/31618 ([4.2, 4.1 only] backspace intrinsic is not working on an unformatted file)
2007-04-23  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/31618
	* io/transfer.c (read_block_direct):  Instead of calling us_read,
	set dtp->u.p.current_unit->current_record = 0 so that pre_position
	will read the record marker.
	(data_transfer_init):  For different error conditions, call
	generate_error, then return.

2007-04-23  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/31618
	* gfortran.dg/backspace_8.f:  New test case.

From-SVN: r124079
2007-04-23 19:43:54 +00:00
Jerry DeLisle b4501dfdd2 open.c (test_endfile): Revert changes for 31052, restoring this function.
2007-04-14  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	* io/open.c (test_endfile): Revert changes for 31052, restoring this
	function.

From-SVN: r123842
2007-04-15 01:53:43 +00:00
Francois-Xavier Coudert 5e9f08ba5d cpu_time.c: Don't include headers already included by libgfortran.h.
* intrinsics/cpu_time.c: Don't include headers already included
	by libgfortran.h. Protect inclusion of sys/times.h.
	* configure.ac: Remove unneeded checks for finit, stdio.h,
	stddef.h, math.h and sys/params.h.
	* config/fpu-aix.h: Don't include headers already included by
	libgfortran.h.
	* config/fpu-sysv.h: Likewise.
	* io/write.c: Likewise.
	* m4/minloc1.m4: Likewise.
	* m4/maxloc1.m4: Likewise.
	* m4/fraction.m4: Likewise.
	* m4/set_exponent.m4: Likewise.
	* m4/spacing.m4: Likewise.
	* m4/minval.m4: Likewise.
	* m4/maxval.m4: Likewise.
	* m4/exponent.m4: Likewise.
	* m4/nearest.m4: Likewise.
	* m4/minloc0.m4: Likewise.
	* m4/maxloc0.m4: Likewise.
	* m4/rrspacing.m4: Likewise.
	* runtime/main.c: Likewise.
	* runtime/error.c: Likewise.
	* intrinsics/system_clock.c: Likewise.
	* intrinsics/etime.c: Likewise.
	* intrinsics/stat.c: Likewise.
	* intrinsics/date_and_time.c: Likewise.
	* intrinsics/env.c: Likewise.
	* intrinsics/kill.c: Likewise.
	* intrinsics/getXid.c: Likewise.
	* intrinsics/chmod.c: Likewise.
	* intrinsics/args.c: Likewise.
	* intrinsics/c99_functions.c: Likewise.
	* generated/minval_r8.c: Regenerate.
	* generated/maxloc1_4_r8.c: Regenerate.
	* generated/minloc1_16_r16.c: Regenerate.
	* generated/maxval_i2.c: Regenerate.
	* generated/maxloc1_8_i4.c: Regenerate.
	* generated/exponent_r16.c: Regenerate.
	* generated/maxloc0_4_r4.c: Regenerate.
	* generated/fraction_r16.c: Regenerate.
	* generated/fraction_r4.c: Regenerate.
	* generated/minloc0_4_r16.c: Regenerate.
	* generated/minloc0_4_i1.c: Regenerate.
	* generated/maxloc0_4_r16.c: Regenerate.
	* generated/maxloc0_4_i2.c: Regenerate.
	* generated/minloc1_8_r16.c: Regenerate.
	* generated/maxloc1_8_r16.c: Regenerate.
	* generated/set_exponent_r8.c: Regenerate.
	* generated/maxloc0_8_i8.c: Regenerate.
	* generated/minloc1_4_r8.c: Regenerate.
	* generated/maxloc1_16_r16.c: Regenerate.
	* generated/minloc1_16_i4.c: Regenerate.
	* generated/maxloc1_16_i4.c: Regenerate.
	* generated/minloc0_16_i8.c: Regenerate.
	* generated/maxloc0_16_i8.c: Regenerate.
	* generated/nearest_r8.c: Regenerate.
	* generated/spacing_r16.c: Regenerate.
	* generated/maxval_r16.c: Regenerate.
	* generated/minloc1_8_i4.c: Regenerate.
	* generated/minloc0_16_i16.c: Regenerate.
	* generated/minloc0_4_r4.c: Regenerate.
	* generated/set_exponent_r10.c: Regenerate.
	* generated/rrspacing_r10.c: Regenerate.
	* generated/minloc0_4_i2.c: Regenerate.
	* generated/maxloc0_8_i1.c: Regenerate.
	* generated/minloc0_8_i8.c: Regenerate.
	* generated/spacing_r4.c: Regenerate.
	* generated/minloc1_16_r10.c: Regenerate.
	* generated/minloc0_16_i1.c: Regenerate.
	* generated/maxloc0_16_i1.c: Regenerate.
	* generated/maxloc1_8_r8.c: Regenerate.
	* generated/minval_i16.c: Regenerate.
	* generated/exponent_r10.c: Regenerate.
	* generated/maxval_i4.c: Regenerate.
	* generated/minval_i8.c: Regenerate.
	* generated/maxloc1_4_i8.c: Regenerate.
	* generated/fraction_r10.c: Regenerate.
	* generated/maxloc0_16_i16.c: Regenerate.
	* generated/maxloc0_8_r4.c: Regenerate.
	* generated/rrspacing_r8.c: Regenerate.
	* generated/minloc1_4_i16.c: Regenerate.
	* generated/minloc0_4_r10.c: Regenerate.
	* generated/maxloc1_4_i16.c: Regenerate.
	* generated/minloc0_8_i16.c: Regenerate.
	* generated/maxloc0_4_r10.c: Regenerate.
	* generated/maxloc0_8_i16.c: Regenerate.
	* generated/minloc1_8_r10.c: Regenerate.
	* generated/minloc0_16_r4.c: Regenerate.
	* generated/maxloc1_8_r10.c: Regenerate.
	* generated/maxloc0_16_r4.c: Regenerate.
	* generated/minloc1_16_r8.c: Regenerate.
	* generated/minloc0_8_i1.c: Regenerate.
	* generated/maxloc0_4_i4.c: Regenerate.
	* generated/maxloc1_16_r8.c: Regenerate.
	* generated/maxloc0_8_i2.c: Regenerate.
	* generated/nearest_r16.c: Regenerate.
	* generated/maxloc1_16_r10.c: Regenerate.
	* generated/minloc0_16_i2.c: Regenerate.
	* generated/minloc1_8_r8.c: Regenerate.
	* generated/maxloc0_16_i2.c: Regenerate.
	* generated/exponent_r4.c: Regenerate.
	* generated/spacing_r10.c: Regenerate.
	* generated/maxval_r10.c: Regenerate.
	* generated/minval_i1.c: Regenerate.
	* generated/maxloc1_4_i1.c: Regenerate.
	* generated/minloc1_4_i8.c: Regenerate.
	* generated/minloc0_8_r4.c: Regenerate.
	* generated/minloc0_16_r16.c: Regenerate.
	* generated/minloc0_4_i4.c: Regenerate.
	* generated/minloc0_8_i2.c: Regenerate.
	* generated/minval_r4.c: Regenerate.
	* generated/maxloc1_4_r4.c: Regenerate.
	* generated/maxval_r8.c: Regenerate.
	* generated/minval_r16.c: Regenerate.
	* generated/minloc1_4_i1.c: Regenerate.
	* generated/minval_i2.c: Regenerate.
	* generated/maxloc1_4_i2.c: Regenerate.
	* generated/maxloc1_8_i8.c: Regenerate.
	* generated/maxloc0_4_r8.c: Regenerate.
	* generated/maxloc0_16_r16.c: Regenerate.
	* generated/minloc1_4_r16.c: Regenerate.
	* generated/fraction_r8.c: Regenerate.
	* generated/maxloc1_4_r16.c: Regenerate.
	* generated/set_exponent_r4.c: Regenerate.
	* generated/minloc0_8_r16.c: Regenerate.
	* generated/maxloc0_8_r16.c: Regenerate.
	* generated/nearest_r10.c: Regenerate.
	* generated/maxloc0_8_i4.c: Regenerate.
	* generated/minloc1_4_r4.c: Regenerate.
	* generated/minloc0_16_i4.c: Regenerate.
	* generated/maxloc0_16_i4.c: Regenerate.
	* generated/nearest_r4.c: Regenerate.
	* generated/minloc1_16_i8.c: Regenerate.
	* generated/maxloc1_16_i8.c: Regenerate.
	* generated/minloc1_4_i2.c: Regenerate.
	* generated/maxloc1_8_i1.c: Regenerate.
	* generated/minloc0_16_r10.c: Regenerate.
	* generated/minloc1_8_i8.c: Regenerate.
	* generated/minloc0_4_r8.c: Regenerate.
	* generated/minloc0_8_i4.c: Regenerate.
	* generated/minloc1_16_i16.c: Regenerate.
	* generated/spacing_r8.c: Regenerate.
	* generated/maxloc1_8_r4.c: Regenerate.
	* generated/minloc1_16_i1.c: Regenerate.
	* generated/maxloc1_16_i1.c: Regenerate.
	* generated/minval_r10.c: Regenerate.
	* generated/minval_i4.c: Regenerate.
	* generated/minloc1_8_i1.c: Regenerate.
	* generated/maxloc1_4_i4.c: Regenerate.
	* generated/maxloc1_8_i2.c: Regenerate.
	* generated/maxval_i8.c: Regenerate.
	* generated/maxloc0_16_r10.c: Regenerate.
	* generated/rrspacing_r4.c: Regenerate.
	* generated/minloc0_4_i16.c: Regenerate.
	* generated/maxloc0_8_r8.c: Regenerate.
	* generated/maxloc0_4_i16.c: Regenerate.
	* generated/minloc1_4_r10.c: Regenerate.
	* generated/minloc1_8_i16.c: Regenerate.
	* generated/maxloc1_4_r10.c: Regenerate.
	* generated/minloc0_8_r10.c: Regenerate.
	* generated/maxloc1_8_i16.c: Regenerate.
	* generated/maxloc0_8_r10.c: Regenerate.
	* generated/minloc1_16_r4.c: Regenerate.
	* generated/maxloc1_16_r4.c: Regenerate.
	* generated/minloc0_16_r8.c: Regenerate.
	* generated/maxloc0_16_r8.c: Regenerate.
	* generated/maxloc0_4_i8.c: Regenerate.
	* generated/maxloc1_16_i16.c: Regenerate.
	* generated/minloc1_8_r4.c: Regenerate.
	* generated/minloc1_16_i2.c: Regenerate.
	* generated/maxloc1_16_i2.c: Regenerate.
	* generated/maxval_i16.c: Regenerate.
	* generated/exponent_r8.c: Regenerate.
	* generated/minloc1_4_i4.c: Regenerate.
	* generated/maxval_i1.c: Regenerate.
	* generated/minloc1_8_i2.c: Regenerate.
	* generated/minloc0_8_r8.c: Regenerate.
	* generated/set_exponent_r16.c: Regenerate.
	* generated/maxloc0_4_i1.c: Regenerate.
	* generated/rrspacing_r16.c: Regenerate.
	* generated/minloc0_4_i8.c: Regenerate.
	* generated/maxval_r4.c: Regenerate.
	* configure: Regenerate.
	* config.h.in: Regenerate.

From-SVN: r123623
2007-04-06 16:47:23 +00:00
Jerry DeLisle 5a97b4f907 re PR fortran/31395 ([4.2 Only] Colon edit descriptor is ignored unless preceded by a comma or a slash)
2007-04-06  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/31395
	* io/format.c (parse_format_list): Fix parsing.

From-SVN: r123620
2007-04-06 15:39:02 +00:00
Jerry DeLisle 08f9246a45 re PR libfortran/31052 ([4.2 only] Bad IOSTAT values when readings NAMELISTs past EOF)
2007-04-01  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/31052
	* io/open.c (test_endfile): Delete this function.
	(edit_modes): Delete call to test_endfile.
	(new_unit): Likewise.
	* io/io.h: Delete prototype for test_endfile.
	* io/transfer.c (next_record_r): Remove use of test_endfile.
	(st_read):  Add test for end file condition and adjust status.

From-SVN: r123403
2007-04-01 17:32:20 +00:00
Jerry DeLisle 138469296c re PR fortran/31366 ([4.2 only] Last record truncated for read after short write, direct access file)
2007-04-01  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/31366
	* io/transfer.c (read_block_direct): Do not generate error when reading
	past EOF on a short record that is less than the RECL= specified.
	
2007-04-01  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/31207
	* io/unit.c (close_unit_1): If there are bytes previously written from
	ADVANCE="no", move to the end before closing.

From-SVN: r123401
2007-04-01 15:23:48 +00:00
Jerry DeLisle f70ddc12ec re PR libfortran/31052 ([4.2 only] Bad IOSTAT values when readings NAMELISTs past EOF)
2007-03-27  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/31052
	* io/transfer.c (next_record_r): Do not call test_endfile if in namelist
	mode.

From-SVN: r123284
2007-03-28 00:19:39 +00:00
Jerry DeLisle beb6a65e75 re PR fortran/31199 (write with "t1" + nonadvancing transfer format gives wrong output)
2007-03-25  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/31199
	*io/io.h: Add saved_pos to gfc_unit structure.
	*io/open.c (new_unit): Initialize saved_pos.
	*io/transfer.c (data_transfer_init): Set max_pos to value in saved_pos.
	(next_record_w): Fix whitespace.
	(finalze_transfer): Calculate max_pos for ADVANCE="no" and save it for
	later use.  If not ADVANCE="no" set saved_pos to zero.

From-SVN: r123205
2007-03-26 03:23:15 +00:00
Jerry DeLisle 9a7b6ea727 re PR libfortran/31052 ([4.2 only] Bad IOSTAT values when readings NAMELISTs past EOF)
2007-03-22  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/31052
	* file_pos.c: Update Copyright year.
	* io/open.c (test_endfile): Restore test_endfile to fix SPEC regression.
	Update Copyright year.
	* io/io.h: Same.
	* io/unix.c (is_special): Add missing type for this function.
	Update Copyright year.
	* io/transfer.c (next_record_r): Restore test_endfile.
	(st_read): Fix whitespace.  Update Copyright year

From-SVN: r123139
2007-03-23 00:13:19 +00:00
Jerry DeLisle 7ab8aa3620 re PR libfortran/31052 ([4.2 only] Bad IOSTAT values when readings NAMELISTs past EOF)
2007-03-18  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/31052
	* io/file_position (st_rewind): Fix comments. Remove use of
	test_endfile. Don't seek if already at 0 position.  Use new is_special
	function to set endfile state.
	* io/open.c (test_endfile): Delete this function.
	* io/io.h: Delete prototype for test_endfile.  Add prototype
	for is_special.
	* io/unix.c (is_special): New function. Fix whitespace.
	* io/transfer.c (next_record_r): Remove use of test_endfile.

From-SVN: r123038
2007-03-18 18:13:50 +00:00
Jerry DeLisle b746fc0e8c re PR libfortran/31099 (Runtime error on legal code using RECL)
2007-03-15  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/31099
	* io/file_pos.c (st_rewind): Don't set bytes_left to zero.

From-SVN: r122970
2007-03-16 00:41:36 +00:00
Jerry DeLisle 22cbc70726 re PR fortran/31051 ([4.2 Only] gfortran bug with x and t format descriptors.)
2007-03-14  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/31051
	* io/transfer.c (formatted_transfer_scalar): Adjust position for pending
	spaces when in writing mode.  Clean up some formatting.

From-SVN: r122940
2007-03-15 01:25:27 +00:00
Jakub Jelinek d70d13acb5 unix.c (regular_file): For ACTION_UNSPECIFIED retry with O_RDONLY even if errno is EROFS.
* io/unix.c (regular_file): For ACTION_UNSPECIFIED retry with
	O_RDONLY even if errno is EROFS.

From-SVN: r122914
2007-03-14 13:14:58 +01:00
Jerry DeLisle f4072316a3 re PR libfortran/31099 (Runtime error on legal code using RECL)
2007-03-09  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/31099
	* io/open.c (new_unit): Initialize bytes_left and recl_subrecord.
	* io/transfer.c (next_record_w): Set bytes left to record length for
	sequential unformatted I/O.
	(next_record_r): Ditto.
	(read_block_direct): Fix test for exceeding bytes_left.

From-SVN: r122763
2007-03-09 21:51:39 +00:00
Jerry DeLisle 4f8d744edb re PR libfortran/30918 (Failure to skip commented out NAMELIST)
2007-02-24  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/30918
	* io/listread.c (namelist_read): Eat comment line.

From-SVN: r122307
2007-02-25 02:27:17 +00:00
Jerry DeLisle 9014618cb9 re PR fortran/30910 ([Regression 4.2, 4.3] Gfortran: ES format not quite right...)
2007-02-22  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/30910
	* io/write.c (output_float): Add condition of format F only for
	special case rounding with zero precision.

From-SVN: r122250
2007-02-23 05:43:16 +00:00
Paul Thomas d4feb3d31a re PR fortran/30284 ([4.1 only] ICE in gfc_add_modify with internal reads)
2007-02-02  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/30284
	PR fortran/30626
	* trans-expr.c (gfc_conv_aliased_arg): Remove static attribute
	from function and make sure that substring lengths are
	translated.
	(is_aliased_array): Remove static attribute.
	* trans.c : Add prototypes for gfc_conv_aliased_arg and
	is_aliased_array.
	* trans-io.c (set_internal_unit): Add the post block to the
	arguments of the function.  Use is_aliased_array to check if
	temporary is needed; if so call gfc_conv_aliased_arg.
	(build_dt): Pass the post block to set_internal_unit and
	add to the block after all io activiy is done.

2007-02-02  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/30284
	PR fortran/30626
	* io/transfer.c (init_loop_spec, next_array_record): Change to
	lbound rather than unity base.

2007-02-02  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/30284
	* gfortran.dg/arrayio_11.f90.f90: New test.

	PR fortran/30626
	* gfortran.dg/arrayio_12.f90.f90: New test.

From-SVN: r121500
2007-02-02 12:35:57 +00:00
Francois-Xavier Coudert eedeea04da re PR libfortran/29649 (Force core dump on runtime library errors)
2007-01-18  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
            Tobias Burnus  <burnus@net-b.de>

       PR libfortran/29649
       * gfortran.h (gfc_option_t): Add flag_dump_core.
       * lang.opt: Add -fdump-core option.
       * invoke.texi: Document the new options.
       * trans-decl.c (gfc_build_builtin_function_decls): Add new
         options to the call to set_std.
       * options.c (gfc_init_options, gfc_handle_option): Set the
         new options.

2007-01-18  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
            Tobias Burnus  <burnus@net-b.de>

       PR libfortran/29649
       * runtime/environ.c (variable_table): New GFORTRAN_ERROR_DUMPCORE
         environment variable.
       * runtime/compile_options.c (set_std): Add new argument.
       * runtime/error.c (sys_exit): Move from io/unix.c. Add coredump functionality.
       * libgfortran.h (options_t): New dump_core and backtrace members.
         (sys_exit): Move prototype.
       * io/unix.c (sys_exit): Move to runtime/error.c.
       * configure.ac: Add check for getrlimit.
       * configure: Regenerate.


Co-Authored-By: Tobias Burnus <burnus@net-b.de>

From-SVN: r120897
2007-01-18 13:54:11 +01:00
Francois-Xavier Coudert 0dce3ca161 re PR libfortran/27107 (Make dependency on io/io.h broken)
PR libfortran/27107
	* runtime/environ.c: Don't include io/io.h.
	* runtime/string.c: Don't include io/io.h.
	(compare0): Add cast to avoid warning.
	* runtime/error.c: Don't include io/io.h.
	(st_printf): Move to io/unix.c.
	* intrinsics/flush.c: Delete, contents moved to io/intrinsics.c.
	* intrinsics/fget.c: Likewise.
	* intrinsics/ftell.c: Likewise.
	* intrinsics/tty.c: Likewise.
	* libgfortran.h (DEFAULT_RECL, notification_std,
	get_unformatted_convert, IOPARM_*, st_parameter_common, unit_convert,
	DEFAULT_TEMPDIR): New declarations.
	* io/io.h (DEFAULT_RECL, notification_std, get_unformatted_convert,
	IOPARM_*, st_parameter_common, unit_convert, DEFAULT_TEMPDIR):
	Move to libgfortran.h.
	* io/unix.c: Add io/unix.h content.
	(st_printf): New function.
	* io/intrinsics.c: New file.
	* io/unix.h: Remove, contents moved into unix.c.
	* libtool-version: Update library version to 3.0.0.
	* configure.ac: Update library version to 0.3.
	* Makefile.am (intrinsics/fget.c, intrinsics/flush.c,
	intrinsics/ftell.c, intrinsics/tty.c, libgfortran.h): Remove targets.
	* Makefile.in: Regenerate.
	* configure: Regenerate.

From-SVN: r120869
2007-01-17 19:44:00 +00:00
Jerry DeLisle b8df885f63 re PR fortran/30435 (Slash at end of input not recognized according to standard)
2007-01-12  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/30435
	* io/list_read.c (finish_separator): Don't call next_record.
	(list_formatted_read_scalar): Clean up some comments and whitespace.
	(nml_read_obj): Whitespace fix.

From-SVN: r120737
2007-01-12 23:10:27 +00:00
Jerry DeLisle 779f397598 re PR libfortran/30162 (Document when sequential I/O with named pipes works)
2007-01-05  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/30162
	* io/unix.c (fd_flush): Don't seek if file is not seekable, defined as
	s->file_length == -1.
	(fd_alloc_w_at): Do not adjust file_length if file is not seekable.
	(fd_seek): If not seekable, just return success.
	(fd_truncate): If not seekable, no need to truncate.  Return failure if
	seek fails and the stream is not a pipe.
	(fd_to_stream): Make test for non-seekable file more robust.

From-SVN: r120512
2007-01-06 00:14:38 +00:00
Jerry DeLisle cf79465213 re PR libfortran/30014 (INQUIRE (iolength = xx) limited to kind=4)
2006-12-27  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/30014
	*io/io.h (st_parameter_dt): Change *size and *iolength type to
	GFC_IO_INT.
	*io/transfer.c (finalize_transfer): Cast dtp->u.p.size_used to
	GFC_IO_INT.  (iolength_transfer): Cast size * nelems to GFC_IO_INT.

From-SVN: r120234
2006-12-28 01:40:23 +00:00
Jerry DeLisle 87cd572dee re PR fortran/30145 (Fortran 90: write statement fails to ignore zero-sized array...)
2006-12-15  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/30145
	* io/transfer.c (transfer_array):  Check for negative extent.

From-SVN: r119942
2006-12-15 19:54:52 +00:00
Thomas Koenig b4c811bd14 re PR libfortran/30009 ([4.1 only] Unformatted reads exceeding storage units gives EOF instead of ERR)
2006-12-06  Thomas Koenig  <Thomas.Koenig@online.de>

	PR libfortran/30009
	PR libfortran/30056
	* gfortran.dg/read_eof_4.f90:  Add tests.
	* gfortran.dg/readwrite_unf_direct_eor_1.f90:  New test.
	* gfortran.dg/unf_read_corrupted_1.f90: New test.

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

	PR libfortran/30009
	PR libfortran/30056
	* libgfortran.h:  Add ERROR_CORRUPT_FILE to error_codes.
	* runtime/error.c (translate_error):  Add handling for
	ERROR_CORRUPT_FILE.
	* io/transfer.c (read_block_direct):  Add comment about
	EOR for stream files.
	Remove test for no bytes left for direct access files.
	Generate an ERROR_SHORT_RECORD if the read was short.
	For unformatted sequential files:  Check endfile condition.
	Remove test for no bytes left.  End of file here means
	that the file structure has been corrupted.  Pre-position
	the file for the next record in case of error.
	(write_buf):  Whitespace fix.  Subtract the number of bytes
	written from bytes_left.

From-SVN: r119592
2006-12-06 19:25:44 +00:00
Jerry DeLisle db7317c3cf re PR libfortran/30005 (Open errors (not/already exists etc.): show also the file name)
2006-12-04  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/30005
	* io/open.c: Add errno.h include.
	(new_unit): Add new error messages with file name for file open.

From-SVN: r119530
2006-12-05 00:51:26 +00:00
Thomas Koenig 07b3bbf200 re PR libfortran/29568 (implement unformatted files with subrecords (Intel style))
2006-12-01  Thomas Koenig  <Thomas.Koenig@online.de>

	PR libfortran/29568
	* gfortran.dg/convert_implied_open.f90:  Change to
	new default record length.
	* gfortran.dg/unf_short_record_1.f90:  Adapt to
	new error message.
	* gfortran.dg/unformatted_subrecords_1.f90:  New test.

2006-12-01  Thomas Koenig  <Thomas.Koenig@online.de>

	PR libfortran/29568
	* gfortran.h (gfc_option_t):  Add max_subrecord_length.
	(top level): Define MAX_SUBRECORD_LENGTH.
	* lang.opt:  Add option -fmax-subrecord-length=.
	* trans-decl.c:  Add new function set_max_subrecord_length.
	(gfc_generate_function_code): If we are within the main
	program and max_subrecord_length has been set, call
	set_max_subrecord_length.
	* options.c (gfc_init_options):  Add defaults for
	max_subrecord_lenght, convert and record_marker.
	(gfc_handle_option):  Add handling for
	-fmax_subrecord_length.
	* invoke.texi:  Document the new default for
	-frecord-marker=<n>.

2006-12-01  Thomas Koenig  <Thomas.Koenig@online.de>

	PR libfortran/29568
	* libgfortran/libgfortran.h (compile_options_t):  Add
	record_marker. (top level):  Define GFC_MAX_SUBRECORD_LENGTH.
	* runtime/compile_options.c (set_record_marker):  Change
	default to four-byte record marker.
	(set_max_subrecord_length):  New function.
	* runtime/error.c (translate_error):  Change error message
	for short record on unformatted read.
	* io/io.h (gfc_unit):  Add recl_subrecord, bytes_left_subrecord
	and continued.
	* io/file_pos.c (unformatted_backspace):  Change default of record
	marker size to four bytes.  Loop over subrecords.
	* io/open.c:  Default recl is max_offset.  If
	compile_options.max_subrecord_length has been set, set set
	u->recl_subrecord to its value, to the maximum value otherwise.
	* io/transfer.c (top level):  Add prototypes for us_read, us_write,
	next_record_r_unf and next_record_w_unf.
	(read_block_direct):  Separate codepaths for unformatted direct
	and unformatted sequential.  If a recl has been set by the
	user, use the number of bytes left for the record if it is smaller
	than the read request.  Loop over subrecords.  Set an error if the
	user has set a recl and the read was short.
	(write_buf):  Separate codepaths for unformatted direct and
	unformatted sequential. If a recl has been set by the
	user, use the number of bytes left for the record if it is smaller
	than the read request.  Loop over subrecords.  Set an error if the
	user has set a recl and the read was short.
	(us_read):  Add parameter continued (to indicate that bytes_left
	should not be intialized).  Change default of record marker size
	to four bytes. Use subrecord.  If the subrecord length is smaller than
	zero, this indicates a continuation.
	(us_write):  Add parameter continued (to indicate that the continued
	flag should be set).  Use subrecord.
	(pre_position):  Use 0 for continued on us_write and us_read calls.
	(skip_record):  New function.
	(next_record_r_unf):  New function.
	(next_record_r):  Use next_record_r_unf.
	(write_us_marker):  Default size for record markers is four bytes.
	(next_record_w_unf):  New function.
	(next_record_w):  Use next_record_w_unf.

From-SVN: r119412
2006-12-01 21:04:38 +00:00
Jerry DeLisle b0c6db58ad io.h (unit_flags): Add new flag has_recl.
2006-11-22  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	* io/io.h (unit_flags): Add new flag has_recl.
	* io.open.c (new_unit): Set flag if RECL= was specified.
	* io/transfer.c (us_write): If flag set, leave recl as initialized by
	new_unit.

From-SVN: r119087
2006-11-22 07:32:09 +00:00
François-Xavier Coudert 6c0e51c4fa trans-decl.c (gfc_get_symbol_decl): Fix formatting.
* trans-decl.c (gfc_get_symbol_decl): Fix formatting.

	* io/open.c (new_unit): Format %d expects an int variable.
	* runtime/error.c (show_locus): Format %d expects an int variable.

From-SVN: r118887
2006-11-16 11:20:57 +00:00
Steven G. Kargl 474e88dd75 2006-11-08 Steven G. Kargl <kargl@gcc.gnu.org>
* io/read. (max_value): Hide "int n" in an #ifdef.

From-SVN: r118613
2006-11-09 03:57:44 +00:00
Jerry DeLisle 54938c1127 re PR fortran/29752 (write(*,*,advance='NO'), READ(): Data not flushed)
2006-11-08  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/29752
	* io/transfer.c (finalize_transfer): Flush on ADVANCE_NO.

From-SVN: r118611
2006-11-09 03:03:40 +00:00