Commit Graph

831 Commits

Author SHA1 Message Date
Jerry DeLisle 2b70275ee1 PR 90374 d0.d, e0.d, es0.d, en0.d, g0.d and ew.d edit descriptors.
PR libfortran/90274
        * io/format.c (parse_format_list): Implement the E0 exponent
        width to provide smallest possible width for exponent fields.
        Refactor code for correct parsing and better readability of the
        code.
        * io/io.h (write_real_w0): Change interface to pass in pointer
        to fnode.
        * io/transfer.c: Update all calls to write_real_w0 to use the
        new interface.
        * io/write.c ((write_real_w0): Use the new interface with fnode
        to access both the decimal precision and exponent widths used in
        build_float_string.
        * io/write_float.def (build_float_string): Use the passed in
        exponent width to calculate the used width in the case of E0.

From-SVN: r279828
2020-01-02 00:57:31 +00:00
Jakub Jelinek 8d9254fc8a Update copyright years.
From-SVN: r279813
2020-01-01 12:51:42 +01:00
Jerry DeLisle e51e2058f0 re PR libfortran/90374 (Fortran 2018: Support d0.d, e0.d, es0.d, en0.d, g0.d and ew.d e0 edit descriptors for output)
2019-12-01  Jerry DeLisle  <jvdelisle@gcc.ngu.org>

	PR fortran/90374
	* io/format.c (parse_format_list): Add braces to disambiguate
	conditional.

From-SVN: r278886
2019-12-01 22:29:43 +00:00
Jerry DeLisle 68c28e37e4 re PR libfortran/90374 (Fortran 2018: Support d0.d, e0.d, es0.d, en0.d, g0.d and ew.d e0 edit descriptors for output)
PR fortran/90374
	* io.c (check_format): Allow zero width expoenent with e0.

	* io/format.c (parse_format_list): Relax format checking to allow
	e0 exponent specifier.

	* gfortran.dg/fmt_zero_width.f90: Update test.

From-SVN: r278817
2019-11-28 18:33:20 +00:00
Jerry DeLisle 73af0c7b3a re PR libfortran/92100 (Formatted stream IO irreproducible read with binary data in file)
2019-11-24  Jerry DeLisle  <jvdelisle@gcc.ngu.org>

	PR fortran/92100
	io/transfer.c (data_transfer_init_worker): Use fbuf_reset
	instead of fbuf_flush before the seek. Note that fbuf_reset
	calls fbuf_flush and adjusts fbuf pointers.

From-SVN: r278660
2019-11-24 22:14:59 +00:00
Thomas Koenig 859174c824 Fix EOF handling for arrays.
2019-11-23  Thomas Koenig  <tkoenig@gcc.gnu.org>
	Harald Anlauf <anlauf@gmx.de>

	PR fortran/92569
	* io/transfer.c (transfer_array_inner):  If position is
	at AFTER_ENDFILE in current unit, return from data loop.

2019-11-23  Thomas Koenig  <tkoenig@gcc.gnu.org>
	Harald Anlauf <anlauf@gmx.de>

	PR fortran/92569
	* gfortran.dg/eof_6.f90: New test.


Co-Authored-By: Harald Anlauf <anlauf@gmx.de>

From-SVN: r278659
2019-11-24 19:16:23 +00:00
Jerry DeLisle 67732fbced re PR libfortran/90374 (Fortran 2018: Support d0.d, e0.d, es0.d, en0.d, g0.d and ew.d e0 edit descriptors for output)
2019-11-06  Jerry DeLisle  <jvdelisle@gcc.ngu.org>

	PR fortran/90374
	* io.c (check_format): Allow zero width for D, E, EN, and ES
	specifiers as default and when -std=F2018 is given. Retain
	existing errors when using the -fdec family of flags.

	* libgfortran/io/format.c (parse_format_list): Relax format checking for
	zero width as default and when -std=f2018.
	io/format.h (format_token): Move definition to io.h.
	io/io.h (format_token): Add definition here to allow access to
	this definition at higher levels. Rename the declaration of
	write_real_g0 to write_real_w0 and add a new format_token
	argument, allowing higher level functions to pass in the
	token for handling of g0 vs the other zero width specifiers.
	io/transfer.c (formatted_transfer_scalar_write): Add checks for
	zero width and call write_real_w0 to handle it.
	io/write.c (write_real_g0): Remove.
	(write_real_w0): Add new, same as previous write_real_g0 except
	check format token to handle the g0 case.

	* gfortran.dg/fmt_error_10.f: Modify for new constraints.
	* gfortran.dg/fmt_error_7.f: Add dg-options "-std=f95".
	* gfortran.dg/fmt_error_9.f: Modify for new constraints.
	* gfortran.dg/fmt_zero_width.f90: New test.

From-SVN: r277905
2019-11-07 03:06:20 +00:00
Jerry DeLisle a4626a7b3e re PR libfortran/91593 (Implicit enum conversions in libgfortran/io/transfer.c)
2019-10-01  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/91593
	* io/read.c (read_decimal): Cast constant to size_t to turn off
	a bogus warning.
	* io/write.c (btoa_big): Use memset in lieu of setting the null
	byte in a string buffer to turn off a bogus warning.

From-SVN: r276439
2019-10-02 02:35:14 +00:00
Jerry DeLisle 60674b3f8a re PR libfortran/91593 (Implicit enum conversions in libgfortran/io/transfer.c)
2019-09-28  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/91593
	* io/io.h: Add gcc_unreachable().
	* io/transfer.c (file_mode, current_mode,
	formatted_transfer_scalar_read, formatted_transfer_scalar_write,
	pre_position, next_record_r, next_record_w): Add and use
	FORMATTED_UNSPECIFIED to enumeration.

From-SVN: r276255
2019-09-28 19:14:47 +00:00
Janne Blomqvist 4047bab96d PR 53796 Make inquire(file=, recl=) conform to F2018
In my original patch to fix PR 53796 I forgot to fix the behavior for
unconnected units when inquiring via filename. This patch fixes that.

Regtested on x86_64-pc-linux-gnu, committed as obvious.

libgfortran/ChangeLog:

2019-08-07  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/53796
	* io/inquire.c (inquire_via_filename): Set recl to -1 for
	unconnected units.

gcc/testsuite/ChangeLog:

2019-08-07  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/53796
	* gfortran.dg/inquire_recl_f2018.f90: Test for unconnected unit
	with inquire via filename.

From-SVN: r274160
2019-08-07 10:34:10 +03:00
Thomas Koenig c37b0163fe re PR libfortran/91030 (Poor performance of I/O -fconvert=big-endian)
2019-07-21  Thomas König  <tkoenig@gcc.gnu.org>

	PR libfortran/91030
	* gfortran.texi (GFORTRAN_FORMATTED_BUFFER_SIZE): Document
	(GFORTRAN_UNFORMATTED_BUFFER_SIZE): Likewise.

2019-07-21  Thomas König  <tkoenig@gcc.gnu.org>

	PR libfortran/91030
	* io/unix.c (BUFFER_SIZE): Delete.
	(BUFFER_FORMATTED_SIZE_DEFAULT): New variable.
	(BUFFER_UNFORMATTED_SIZE_DEFAULT): New variable.
	(unix_stream): Add buffer_size.
	(buf_read): Use s->buffer_size instead of BUFFER_SIZE.
	(buf_write): Likewise.
	(buf_init): Add argument unformatted.  Handle block sizes
	for unformatted vs. formatted, using defaults if provided.
	(fd_to_stream): Add argument unformatted in call to buf_init.
	* libgfortran.h (options_t): Add buffer_size_formatted and
	buffer_size_unformatted.
	* runtime/environ.c (variable_table): Add
	GFORTRAN_UNFORMATTED_BUFFER_SIZE and
	GFORTRAN_FORMATTED_BUFFER_SIZE.

From-SVN: r273643
2019-07-21 15:55:49 +00:00
Janne Blomqvist 88a8126a90 fortran/89100: Default widths with -fdec-format-defaults
gcc/fortran ChangeLog:

2019-05-22  Jeff Law  <law@redhat.com>
            Mark Eggleston  <mark.eggleston@codethink.com>

        PR fortran/89100
        * gfortran.texi: Add Default widths for F, G and I format
        descriptors to Extensions section.
        * invoke.texi: Add -fdec-format-defaults
        * io.c (check_format): Use default widths for i, f and g when
        flag_dec_format_defaults is enabled.
        * lang.opt: Add new option.
        * options.c (set_dec_flags): Add SET_BITFLAG for
        flag_dec_format_defaults.


gcc/testsuite ChangeLog:

2019-05-22  Mark Eggleston  <mark.eggleston@codethink.com>

        PR fortran/89100
        * gfortran.dg/fmt_f_default_field_width_1.f90: New test.
        * gfortran.dg/fmt_f_default_field_width_2.f90: New test.
        * gfortran.dg/fmt_f_default_field_width_3.f90: New test.
        * gfortran.dg/fmt_g_default_field_width_1.f90: New test.
        * gfortran.dg/fmt_g_default_field_width_2.f90: New test.
        * gfortran.dg/fmt_g_default_field_width_3.f90: New test.
        * gfortran.dg/fmt_i_default_field_width_1.f90: New test.
        * gfortran.dg/fmt_i_default_field_width_2.f90: New test.
        * gfortran.dg/fmt_i_default_field_width_3.f90: New test.


libgfortran ChangeLog:

2019-05-22  Jeff Law  <law@redhat.com>

        PR fortran/89100
        * io/format.c (parse_format_list): set default width when the
        IOPARM_DT_DEC_EXT flag is set for i, f and g.
        * io/io.h: add default_width_for_integer, default_width_for_float
        and default_precision_for_float.
        * io/write.c (write_boz): extra parameter giving length of data
        corresponding to the type's kind.
        (write_b): pass data length as extra parameter in calls to
        write_boz.
        (write_o): pass data length as extra parameter in calls to
        write_boz.
        (write_z): pass data length as extra parameter in calls to
        write_boz.
        (size_from_kind): also set size is default width is set.
        * io/write_float.def (build_float_string): new paramter inserted
        before result parameter. If default width use values passed
        instead of the values in fnode.
        (FORMAT_FLOAT): macro modified to check for default width and
        calls to build_float_string to pass in default width.
        (get_float_string): set width and precision to defaults when
        needed.

From-SVN: r271511
2019-05-22 14:56:01 +03:00
Janne Blomqvist 0c15ebf1bd Allow opening file on multiple units
As of Fortran 2018 it's allowed to open the same file on multiple
units.

libgfortran/ChangeLog:

2019-05-15  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/90461
        * io/open.c (new_unit): Don't check if the file is already open
	for F2018.

testsuite/ChangeLog:

2019-05-15  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/90461
        * gfortran.dg/open_errors_2.f90: Add -std=f2008, adjust line number.
	* gfortran.dg/open_errors_3.f90: New test.

From-SVN: r271260
2019-05-15 21:02:36 +03:00
John David Anglin b7ca376ae9 re PR libfortran/79540 (FAIL: gfortran.dg/fmt_fw_d.f90 -O0 execution test)
PR libgfortran/79540
	* io/write_float.def (build_float_string): Don't copy digits when
	ndigits is negative.

From-SVN: r269911
2019-03-25 11:48:36 +00:00
Uros Bizjak 140a0bddcc transfer.c (transfer_array_inner): Do not cast charlen to index_type.
* io/transfer.c (transfer_array_inner): Do not
	cast charlen to index_type.

From-SVN: r269224
2019-02-26 19:41:53 +01:00
Dominique d'Humieres b8f412849b re PR libfortran/89274 (Inconsistent list directed output of INTEGER(16))
2019-02-25  Dominique d'Humieres  <dominiq@gcc.gnu.org>

	PR libfortran/89274
	* gfortran.dg/list_directed_large.f90: New test. 

2019-02-25  Dominique d'Humieres  <dominiq@gcc.gnu.org>

	PR libfortran/89274
	* io/write.c (write_integer): Add width for INTEGER(16).

From-SVN: r269187
2019-02-25 11:39:38 +01:00
Sebastian Huber 92ab6b83cd libgfortran: Use proper gthr.h API
libgfortran/

	* io/async.c (init_adv_cond): Use __GTHREAD_COND_INIT_FUNCTION().

From-SVN: r268331
2019-01-28 06:35:41 +00:00
Jerry DeLisle 9faf6e7018 re PR libfortran/89020 (close(status='DELETE') does not remove file)
2019-01-27  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/89020
	* io/close.c (st_close): Simplify text of error message to not
	presume a specific cause of failure to remove file.

From-SVN: r268319
2019-01-27 19:42:34 +00:00
Jerry DeLisle 2ee43ae6d6 re PR libfortran/89020 (close(status='DELETE') does not remove file)
2019-01-26  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/89020
	* io/close.c (st_close): Fix typo.

From-SVN: r268309
2019-01-27 01:36:40 +00:00
Jerry DeLisle 0e34715e97 re PR libfortran/89020 (close(status='DELETE') does not remove file)
2019-01-26  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/88020
	* io/close.c (st_close): Generate error if calls to 'remove' return
	an error.

From-SVN: r268301
2019-01-26 20:27:16 +00:00
Jerry DeLisle 9c5f89006f re PR libfortran/88776 (Namelist read from stdin: loss of data)
2019-01-13  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/88776
	* io/open.c (newunit): Free format buffer if the unit specified is for
	stdin, stdout, or stderr.

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

From-SVN: r267910
2019-01-14 00:22:00 +00:00
Jerry DeLisle 9443a1859f re PR libfortran/88776 (Namelist read from stdin: loss of data)
2019-01-12  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/88776
	* io/list_read.c (namelist_read): Use nml_err_ret path on read error
	not based on stdin_unit.

From-SVN: r267898
2019-01-12 23:06:47 +00:00
Sandra Loosemore 6791469314 PR other/16615 [1/5]
2019-01-09  Sandra Loosemore  <sandra@codesourcery.com>

	PR other/16615 [1/5]

	contrib/
	* mklog: Mechanically replace "can not" with "cannot".

	gcc/
	* Makefile.in: Mechanically replace "can not" with "cannot".
	* alias.c: Likewise.
	* builtins.c: Likewise.
	* calls.c: Likewise.
	* cgraph.c: Likewise.
	* cgraph.h: Likewise.
	* cgraphclones.c: Likewise.
	* cgraphunit.c: Likewise.
	* combine-stack-adj.c: Likewise.
	* combine.c: Likewise.
	* common/config/i386/i386-common.c: Likewise.
	* config/aarch64/aarch64.c: Likewise.
	* config/alpha/sync.md: Likewise.
	* config/arc/arc.c: Likewise.
	* config/arc/predicates.md: Likewise.
	* config/arm/arm-c.c: Likewise.
	* config/arm/arm.c: Likewise.
	* config/arm/arm.h: Likewise.
	* config/arm/arm.md: Likewise.
	* config/arm/cortex-r4f.md: Likewise.
	* config/csky/csky.c: Likewise.
	* config/csky/csky.h: Likewise.
	* config/darwin-f.c: Likewise.
	* config/epiphany/epiphany.md: Likewise.
	* config/i386/i386.c: Likewise.
	* config/i386/sol2.h: Likewise.
	* config/m68k/m68k.c: Likewise.
	* config/mcore/mcore.h: Likewise.
	* config/microblaze/microblaze.md: Likewise.
	* config/mips/20kc.md: Likewise.
	* config/mips/sb1.md: Likewise.
	* config/nds32/nds32.c: Likewise.
	* config/nds32/predicates.md: Likewise.
	* config/pa/pa.c: Likewise.
	* config/rs6000/e300c2c3.md: Likewise.
	* config/rs6000/rs6000.c: Likewise.
	* config/s390/s390.h: Likewise.
	* config/sh/sh.c: Likewise.
	* config/sh/sh.md: Likewise.
	* config/spu/vmx2spu.h: Likewise.
	* cprop.c: Likewise.
	* dbxout.c: Likewise.
	* df-scan.c: Likewise.
	* doc/cfg.texi: Likewise.
	* doc/extend.texi: Likewise.
	* doc/fragments.texi: Likewise.
	* doc/gty.texi: Likewise.
	* doc/invoke.texi: Likewise.
	* doc/lto.texi: Likewise.
	* doc/md.texi: Likewise.
	* doc/objc.texi: Likewise.
	* doc/rtl.texi: Likewise.
	* doc/tm.texi: Likewise.
	* dse.c: Likewise.
	* emit-rtl.c: Likewise.
	* emit-rtl.h: Likewise.
	* except.c: Likewise.
	* expmed.c: Likewise.
	* expr.c: Likewise.
	* fold-const.c: Likewise.
	* genautomata.c: Likewise.
	* gimple-fold.c: Likewise.
	* hard-reg-set.h: Likewise.
	* ifcvt.c: Likewise.
	* ipa-comdats.c: Likewise.
	* ipa-cp.c: Likewise.
	* ipa-devirt.c: Likewise.
	* ipa-fnsummary.c: Likewise.
	* ipa-icf.c: Likewise.
	* ipa-inline-transform.c: Likewise.
	* ipa-inline.c: Likewise.
	* ipa-polymorphic-call.c: Likewise.
	* ipa-profile.c: Likewise.
	* ipa-prop.c: Likewise.
	* ipa-pure-const.c: Likewise.
	* ipa-reference.c: Likewise.
	* ipa-split.c: Likewise.
	* ipa-visibility.c: Likewise.
	* ipa.c: Likewise.
	* ira-build.c: Likewise.
	* ira-color.c: Likewise.
	* ira-conflicts.c: Likewise.
	* ira-costs.c: Likewise.
	* ira-int.h: Likewise.
	* ira-lives.c: Likewise.
	* ira.c: Likewise.
	* ira.h: Likewise.
	* loop-invariant.c: Likewise.
	* loop-unroll.c: Likewise.
	* lower-subreg.c: Likewise.
	* lra-assigns.c: Likewise.
	* lra-constraints.c: Likewise.
	* lra-eliminations.c: Likewise.
	* lra-lives.c: Likewise.
	* lra-remat.c: Likewise.
	* lra-spills.c: Likewise.
	* lra.c: Likewise.
	* lto-cgraph.c: Likewise.
	* lto-streamer-out.c: Likewise.
	* postreload-gcse.c: Likewise.
	* predict.c: Likewise.
	* profile-count.h: Likewise.
	* profile.c: Likewise.
	* recog.c: Likewise.
	* ree.c: Likewise.
	* reload.c: Likewise.
	* reload1.c: Likewise.
	* reorg.c: Likewise.
	* resource.c: Likewise.
	* rtl.def: Likewise.
	* rtl.h: Likewise.
	* rtlanal.c: Likewise.
	* sched-deps.c: Likewise.
	* sched-ebb.c: Likewise.
	* sched-rgn.c: Likewise.
	* sel-sched-ir.c: Likewise.
	* sel-sched.c: Likewise.
	* shrink-wrap.c: Likewise.
	* simplify-rtx.c: Likewise.
	* symtab.c: Likewise.
	* target.def: Likewise.
	* toplev.c: Likewise.
	* tree-call-cdce.c: Likewise.
	* tree-cfg.c: Likewise.
	* tree-complex.c: Likewise.
	* tree-core.h: Likewise.
	* tree-eh.c: Likewise.
	* tree-inline.c: Likewise.
	* tree-loop-distribution.c: Likewise.
	* tree-nrv.c: Likewise.
	* tree-profile.c: Likewise.
	* tree-sra.c: Likewise.
	* tree-ssa-alias.c: Likewise.
	* tree-ssa-dce.c: Likewise.
	* tree-ssa-dom.c: Likewise.
	* tree-ssa-forwprop.c: Likewise.
	* tree-ssa-loop-im.c: Likewise.
	* tree-ssa-loop-ivcanon.c: Likewise.
	* tree-ssa-loop-ivopts.c: Likewise.
	* tree-ssa-loop-niter.c: Likewise.
	* tree-ssa-phionlycprop.c: Likewise.
	* tree-ssa-phiopt.c: Likewise.
	* tree-ssa-propagate.c: Likewise.
	* tree-ssa-threadedge.c: Likewise.
	* tree-ssa-threadupdate.c: Likewise.
	* tree-ssa-uninit.c: Likewise.
	* tree-ssanames.c: Likewise.
	* tree-streamer-out.c: Likewise.
	* tree.c: Likewise.
	* tree.h: Likewise.
	* vr-values.c: Likewise.

	gcc/ada/
	* exp_ch9.adb: Mechanically replace "can not" with "cannot".
	* libgnat/s-regpat.ads: Likewise.
	* par-ch4.adb: Likewise.
	* set_targ.adb: Likewise.
	* types.ads: Likewise.

	gcc/cp/
	* cp-tree.h: Mechanically replace "can not" with "cannot".
	* parser.c: Likewise.
	* pt.c: Likewise.

	gcc/fortran/
	* class.c: Mechanically replace "can not" with "cannot".
	* decl.c: Likewise.
	* expr.c: Likewise.
	* gfc-internals.texi: Likewise.
	* intrinsic.texi: Likewise.
	* invoke.texi: Likewise.
	* io.c: Likewise.
	* match.c: Likewise.
	* parse.c: Likewise.
	* primary.c: Likewise.
	* resolve.c: Likewise.
	* symbol.c: Likewise.
	* trans-array.c: Likewise.
	* trans-decl.c: Likewise.
	* trans-intrinsic.c: Likewise.
	* trans-stmt.c: Likewise.

	gcc/go/
	* go-backend.c: Mechanically replace "can not" with "cannot".
	* go-gcc.cc: Likewise.

	gcc/lto/
	* lto-partition.c: Mechanically replace "can not" with "cannot".
	* lto-symtab.c: Likewise.
	* lto.c: Likewise.

	gcc/objc/
	* objc-act.c: Mechanically replace "can not" with "cannot".

	libbacktrace/
	* backtrace.h: Mechanically replace "can not" with "cannot".

	libgcc/
	* config/c6x/libunwind.S: Mechanically replace "can not" with
	"cannot".
	* config/tilepro/atomic.h: Likewise.
	* config/vxlib-tls.c: Likewise.
	* generic-morestack-thread.c: Likewise.
	* generic-morestack.c: Likewise.
	* mkmap-symver.awk: Likewise.

	libgfortran/
	* caf/single.c: Mechanically replace "can not" with "cannot".
	* io/unit.c: Likewise.

	libobjc/
	* class.c: Mechanically replace "can not" with "cannot".
	* objc/runtime.h: Likewise.
	* sendmsg.c: Likewise.

	liboffloadmic/
	* include/coi/common/COIResult_common.h: Mechanically replace
	"can not" with "cannot".
	* include/coi/source/COIBuffer_source.h: Likewise.

	libstdc++-v3/
	* include/ext/bitmap_allocator.h: Mechanically replace "can not"
	with "cannot".

From-SVN: r267783
2019-01-09 16:37:45 -05:00
Jakub Jelinek a554497024 Update copyright years.
From-SVN: r267494
2019-01-01 13:31:55 +01:00
Thomas Koenig d0cbb206e2 re PR libfortran/88411 (Random crashes for ASYNCHRONOUS writes (bad locking?))
2018-12-09  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/88411
	* io/transfer.c (dta_transfer_init): Do not treat as an
	asynchronous statement unless the statement has
	ASYNCHRONOUS="YES".
	(st_write_done): Likewise.
	(st_read_done): Do not perform async_wait for synchronous I/O
	on an async unit.
	(st_read_done): Likewise.

2018-12-09  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/88411
	* testsuite/libgomp.fortran/async_io_8.f90: New test.

From-SVN: r266929
2018-12-09 18:54:47 +00:00
Janne Blomqvist 0536d5b37d Replace sync builtins with atomic builtins
The old __sync builtins have been deprecated for a long time now in
favor of the __atomic builtins following the C++11/C11 memory model.
This patch converts libgfortran to use the modern __atomic builtins.

At the same time I weakened the consistency to relaxed for
incrementing and decrementing the counter, and acquire-release when
decrementing to check whether the counter is 0 and the unit can be
freed.  This is similar to e.g. std::shared_ptr in C++.

Regtested on x86_64-pc-linux-gnu.

libgfortran/ChangeLog:

2018-11-22  Janne Blomqvist  <jb@gcc.gnu.org>

	* acinclude.m4 (LIBGFOR_CHECK_ATOMIC_FETCH_ADD): Rename and test
	presence of atomic builtins instead of sync builtins.
	* configure.ac (LIBGFOR_CHECK_ATOMIC_FETCH_ADD): Call new test.
	* io/io.h (inc_waiting_locked): Use __atomic_fetch_add.
	(predec_waiting_locked): Use __atomic_add_fetch.
	(dec_waiting_unlocked): Use __atomic_fetch_add.
	* config.h.in: Regenerated.
	* configure: Regenerated.
        * Makefile.in: Regenerated.

From-SVN: r266367
2018-11-22 09:58:29 +02:00
Jerry DeLisle 900dab1338 re PR fortran/78351 (comma not terminating READ of formatted input field - ok in 4.1.7, not 4.4.7- maybe related to 25419?)
2018-11-09  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/78351
	* io/transfer.c (read_sf_internal): Delete leftover
	debug code.

From-SVN: r265979
2018-11-09 17:29:33 +00:00
Jerry DeLisle 3f3284629b re PR fortran/78351 (comma not terminating READ of formatted input field - ok in 4.1.7, not 4.4.7- maybe related to 25419?)
2018-11-08  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/78351
	* io/transfer.c (read_sf_internal): Add support for early
	comma termination of internal unit formatted reads.

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

From-SVN: r265946
2018-11-09 02:46:03 +00:00
Janne Blomqvist c0ab1530d4 Use gfc_charlen_type instead of int for string lenghts
This patch cleans up a few places where I noticed the code was still
using int instead gfc_charlen_type for string lengths.  Regtested on
x86_64-pc-linux-gnu, committed as obvious.

libgfortran/ChangeLog:

2018-10-06  Janne Blomqvist  <jb@gcc.gnu.org>

	* io/unix.c (compare_file_filename): Use gfc_charlen_type instead
	of int for string length.
	(inquire_sequential): Likewise.
	(inquire_direct): Likewise.
	(inquire_formatted): Likewise.
	(inquire_unformatted): Likewise.
	(inquire_access): Likewise.
	(inquire_read): Likewise.
	(inquire_write): Likewise.
	(inquire_readwrite): Likewise.
	* io/unix.h (compare_file_filename): Likewise.
	(inquire_sequential): Likewise.
	(inquire_direct): Likewise.
	(inquire_formatted): Likewise.
	(inquire_unformatted): Likewise.
	(inquire_read): Likewise.
	(inquire_write): Likewise.
	(inquire_readwrite): Likewise.

From-SVN: r264901
2018-10-06 21:21:00 +03:00
Gerald Pfeifer ff504cc2b8 * io/close.c [!HAVE_UNLINK_OPEN_FILE]: Include <string.h>.
From-SVN: r264800
2018-10-02 20:02:03 +00:00
Kyrylo Tkachov ef5057c89e [libgfortran] Fix uninitialized variable use in fallback_access
I've been tracking down a bug in a Fortran program on a newlib target and it boils down to fallback_access doing something bad.
The unconditional calls to close cause havoc when open doesn't get called due to the short-circuiting in the if-statement above
because the fd is uninitialised. In my environment GCC ends up calling close on file descriptor 0, thus trying to close stdin.

This patch tightens up the calling so that close is called only when the corresponding open call succeeded.
With this my runtime failure disappears.

Bootstrapped and tested on aarch64-none-linux-gnu.
Though that doesn't exercise this call I hope it's an obviously correct change. 

	* io/unix.c (fallback_access): Avoid calling close on
	uninitialized file descriptor.

From-SVN: r264305
2018-09-14 09:22:01 +00:00
Hans-Peter Nilsson a79878585a * io/async.h: Use __gthread_mutex_t, not pthread_mutex_t.
From-SVN: r264120
2018-09-05 10:28:45 +00:00
Jerry DeLisle 636b78f0a3 io.h: Change declaration of vlist type to gfc_full_array_i4 to eliminate warning for...
2018-09-01  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	* io/io.h: Change declaration of vlist type to
	gfc_full_array_i4 to eliminate warning for mismatched type.
	* io/format.c ((parse_format_list): Use gfc_full_array_i4.
	* io/io.h: Use gfc_full_array_i4.

From-SVN: r264043
2018-09-02 15:55:51 +00:00
David Edelsohn 464c1bd834 * async.h (ASYNC_IO): Revert _AIX test.
From-SVN: r263821
2018-08-23 15:33:45 -04:00
Thomas Koenig 2532f0f5e6 gfortran.texi: Mention that asynchronous I/O does not work on systems which lack condition...
2018-08-22  Thomas Koenig  <tkoenig@gcc.gnu.org>

	* gfortran.texi: Mention that asynchronous I/O does
	not work on systems which lack condition variables, such
	as AIX.

2018-08-22  Thomas Koenig  <tkoenig@gcc.gnu.org>

	* async.h: Set ASYNC_IO to zero if _AIX is defined.
	(struct adv_cond): If ASYNC_IO is zero, the struct has no members.
	(async_unit): If ASYNC_IO is zero, remove unneeded members.

From-SVN: r263788
2018-08-22 21:29:49 +00:00
Nicolas Koenig 2b4c906561 re PR fortran/25829 ([F03] Asynchronous IO support)
2018-08-21  Nicolas Koenig  <koenigni@gcc.gnu.org>
	Thomas Koenig <tkoenig@gcc.gnu.org>

	PR fortran/25829
	* gfortran.texi: Add description of asynchronous I/O.
	* trans-decl.c (gfc_finish_var_decl): Treat asynchronous variables
	as volatile.
	* trans-io.c (gfc_build_io_library_fndecls): Rename st_wait to
	st_wait_async and change argument spec from ".X" to ".w".
	(gfc_trans_wait): Pass ID argument via reference.

2018-08-21  Nicolas Koenig  <koenigni@gcc.gnu.org>
	Thomas Koenig <tkoenig@gcc.gnu.org>

	PR fortran/25829
	* gfortran.dg/f2003_inquire_1.f03: Add write statement.
	* gfortran.dg/f2003_io_1.f03: Add wait statement.

2018-08-21  Nicolas Koenig  <koenigni@gcc.gnu.org>
	Thomas Koenig <tkoenig@gcc.gnu.org>

	PR fortran/25829
	* Makefile.am: Add async.c to gfor_io_src.
	Add async.h to gfor_io_headers.
	* Makefile.in: Regenerated.
	* gfortran.map: Add _gfortran_st_wait_async.
	* io/async.c: New file.
	* io/async.h: New file.
	* io/close.c: Include async.h.
	(st_close): Call async_wait for an asynchronous unit.
	* io/file_pos.c (st_backspace): Likewise.
	(st_endfile): Likewise.
	(st_rewind): Likewise.
	(st_flush): Likewise.
	* io/inquire.c: Add handling for asynchronous PENDING
	and ID arguments.
	* io/io.h (st_parameter_dt): Add async bit.
	(st_parameter_wait): Correct.
	(gfc_unit): Add au pointer.
	(st_wait_async): Add prototype.
	(transfer_array_inner): Likewise.
	(st_write_done_worker): Likewise.
	* io/open.c: Include async.h.
	(new_unit): Initialize asynchronous unit.
	* io/transfer.c (async_opt): New struct.
	(wrap_scalar_transfer): New function.
	(transfer_integer): Call wrap_scalar_transfer to do the work.
	(transfer_real): Likewise.
	(transfer_real_write): Likewise.
	(transfer_character): Likewise.
	(transfer_character_wide): Likewise.
	(transfer_complex): Likewise.
	(transfer_array_inner): New function.
	(transfer_array): Call transfer_array_inner.
	(transfer_derived): Call wrap_scalar_transfer.
	(data_transfer_init): Check for asynchronous I/O.
	Perform a wait operation on any pending asynchronous I/O
	if the data transfer is synchronous. Copy PDT and enqueue
	thread for data transfer.
	(st_read_done_worker): New function.
	(st_read_done): Enqueue transfer or call st_read_done_worker.
	(st_write_done_worker): New function.
	(st_write_done): Enqueue transfer or call st_read_done_worker.
	(st_wait): Document as no-op for compatibility reasons.
	(st_wait_async): New function.
	* io/unit.c (insert_unit): Use macros LOCK, UNLOCK and TRYLOCK;
	add NOTE where necessary.
	(get_gfc_unit): Likewise.
	(init_units): Likewise.
	(close_unit_1): Likewise. Call async_close if asynchronous.
	(close_unit): Use macros LOCK and UNLOCK.
	(finish_last_advance_record): Likewise.
	(newunit_alloc): Likewise.
	* io/unix.c (find_file): Likewise.
	(flush_all_units_1): Likewise.
	(flush_all_units): Likewise.
	* libgfortran.h (generate_error_common): Add prototype.
	* runtime/error.c: Include io.h and async.h.
	(generate_error_common): New function.

2018-08-21  Nicolas Koenig  <koenigni@gcc.gnu.org>
	Thomas Koenig <tkoenig@gcc.gnu.org>

	PR fortran/25829
	* testsuite/libgomp.fortran/async_io_1.f90: New test.
	* testsuite/libgomp.fortran/async_io_2.f90: New test.
	* testsuite/libgomp.fortran/async_io_3.f90: New test.
	* testsuite/libgomp.fortran/async_io_4.f90: New test.
	* testsuite/libgomp.fortran/async_io_5.f90: New test.
	* testsuite/libgomp.fortran/async_io_6.f90: New test.
	* testsuite/libgomp.fortran/async_io_7.f90: New test.


Co-Authored-By: Thomas Koenig <tkoenig@gcc.gnu.org>

From-SVN: r263750
2018-08-21 18:48:59 +00:00
Andre Vieira 1d4a51cf50 Reverting 'AsyncI/O patch committed' as it is breaking bare-metal builds.
2018-07-31  Andre Vieira  <andre.simoesdiasvieira@arm.com>

	Revert 'AsyncI/O patch committed'
	2018-07-25  Nicolas Koenig  <koenigni@gcc.gnu.org>
		Thomas Koenig <tkoenig@gcc.gnu.org>

	PR fortran/25829
	* gfortran.texi: Add description of asynchronous I/O.
	* trans-decl.c (gfc_finish_var_decl): Treat asynchronous variables
	as volatile.
	* trans-io.c (gfc_build_io_library_fndecls): Rename st_wait to
	st_wait_async and change argument spec from ".X" to ".w".
	(gfc_trans_wait): Pass ID argument via reference.

2018-07-31  Andre Vieira  <andre.simoesdiasvieira@arm.com>

	Revert 'AsyncI/O patch committed'
	2018-07-25  Nicolas Koenig  <koenigni@gcc.gnu.org>
		Thomas Koenig <tkoenig@gcc.gnu.org>

	PR fortran/25829
	* gfortran.dg/f2003_inquire_1.f03: Add write statement.
	* gfortran.dg/f2003_io_1.f03: Add wait statement.

2018-07-31  Andre Vieira  <andre.simoesdiasvieira@arm.com>

	Revert 'AsyncI/O patch committed'
	2018-07-25  Nicolas Koenig  <koenigni@gcc.gnu.org>
		Thomas Koenig <tkoenig@gcc.gnu.org>

	PR fortran/25829
	* Makefile.am: Add async.c to gfor_io_src.
	Add async.h to gfor_io_headers.
	* Makefile.in: Regenerated.
	* gfortran.map: Add _gfortran_st_wait_async.
	* io/async.c: New file.
	* io/async.h: New file.
	* io/close.c: Include async.h.
	(st_close): Call async_wait for an asynchronous unit.
	* io/file_pos.c (st_backspace): Likewise.
	(st_endfile): Likewise.
	(st_rewind): Likewise.
	(st_flush): Likewise.
	* io/inquire.c: Add handling for asynchronous PENDING
	and ID arguments.
	* io/io.h (st_parameter_dt): Add async bit.
	(st_parameter_wait): Correct.
	(gfc_unit): Add au pointer.
	(st_wait_async): Add prototype.
	(transfer_array_inner): Likewise.
	(st_write_done_worker): Likewise.
	* io/open.c: Include async.h.
	(new_unit): Initialize asynchronous unit.
	* io/transfer.c (async_opt): New struct.
	(wrap_scalar_transfer): New function.
	(transfer_integer): Call wrap_scalar_transfer to do the work.
	(transfer_real): Likewise.
	(transfer_real_write): Likewise.
	(transfer_character): Likewise.
	(transfer_character_wide): Likewise.
	(transfer_complex): Likewise.
	(transfer_array_inner): New function.
	(transfer_array): Call transfer_array_inner.
	(transfer_derived): Call wrap_scalar_transfer.
	(data_transfer_init): Check for asynchronous I/O.
	Perform a wait operation on any pending asynchronous I/O
	if the data transfer is synchronous. Copy PDT and enqueue
	thread for data transfer.
	(st_read_done_worker): New function.
	(st_read_done): Enqueue transfer or call st_read_done_worker.
	(st_write_done_worker): New function.
	(st_write_done): Enqueue transfer or call st_read_done_worker.
	(st_wait): Document as no-op for compatibility reasons.
	(st_wait_async): New function.
	* io/unit.c (insert_unit): Use macros LOCK, UNLOCK and TRYLOCK;
	add NOTE where necessary.
	(get_gfc_unit): Likewise.
	(init_units): Likewise.
	(close_unit_1): Likewise. Call async_close if asynchronous.
	(close_unit): Use macros LOCK and UNLOCK.
	(finish_last_advance_record): Likewise.
	(newunit_alloc): Likewise.
	* io/unix.c (find_file): Likewise.
	(flush_all_units_1): Likewise.
	(flush_all_units): Likewise.
	* libgfortran.h (generate_error_common): Add prototype.
	* runtime/error.c: Include io.h and async.h.
	(generate_error_common): New function.

2018-07-31  Andre Vieira  <andre.simoesdiasvieira@arm.com>

	Revert 'AsyncI/O patch committed'.
	2018-07-25  Nicolas Koenig  <koenigni@gcc.gnu.org>
		Thomas Koenig <tkoenig@gcc.gnu.org>

	PR fortran/25829
	* testsuite/libgomp.fortran/async_io_1.f90: New test.
	* testsuite/libgomp.fortran/async_io_2.f90: New test.
	* testsuite/libgomp.fortran/async_io_3.f90: New test.
	* testsuite/libgomp.fortran/async_io_4.f90: New test.
	* testsuite/libgomp.fortran/async_io_5.f90: New test.
	* testsuite/libgomp.fortran/async_io_6.f90: New test.
	* testsuite/libgomp.fortran/async_io_7.f90: New test.

From-SVN: r263082
2018-07-31 08:42:21 +00:00
Nicolas Koenig b1f45884f6 re PR fortran/25829 ([F03] Asynchronous IO support)
2018-07-25  Nicolas Koenig  <koenigni@gcc.gnu.org>
	Thomas Koenig <tkoenig@gcc.gnu.org>

	PR fortran/25829
	* gfortran.texi: Add description of asynchronous I/O.
	* trans-decl.c (gfc_finish_var_decl): Treat asynchronous variables
	as volatile.
	* trans-io.c (gfc_build_io_library_fndecls): Rename st_wait to
	st_wait_async and change argument spec from ".X" to ".w".
	(gfc_trans_wait): Pass ID argument via reference.

2018-07-25  Nicolas Koenig  <koenigni@gcc.gnu.org>
	Thomas Koenig <tkoenig@gcc.gnu.org>

	PR fortran/25829
	* gfortran.dg/f2003_inquire_1.f03: Add write statement.
	* gfortran.dg/f2003_io_1.f03: Add wait statement.

2018-07-25  Nicolas Koenig  <koenigni@gcc.gnu.org>
	Thomas Koenig <tkoenig@gcc.gnu.org>

	PR fortran/25829
	* Makefile.am: Add async.c to gfor_io_src.
	Add async.h to gfor_io_headers.
	* Makefile.in: Regenerated.
	* gfortran.map: Add _gfortran_st_wait_async.
	* io/async.c: New file.
	* io/async.h: New file.
	* io/close.c: Include async.h.
	(st_close): Call async_wait for an asynchronous unit.
	* io/file_pos.c (st_backspace): Likewise.
	(st_endfile): Likewise.
	(st_rewind): Likewise.
	(st_flush): Likewise.
	* io/inquire.c: Add handling for asynchronous PENDING
	and ID arguments.
	* io/io.h (st_parameter_dt): Add async bit.
	(st_parameter_wait): Correct.
	(gfc_unit): Add au pointer.
	(st_wait_async): Add prototype.
	(transfer_array_inner): Likewise.
	(st_write_done_worker): Likewise.
	* io/open.c: Include async.h.
	(new_unit): Initialize asynchronous unit.
	* io/transfer.c (async_opt): New struct.
	(wrap_scalar_transfer): New function.
	(transfer_integer): Call wrap_scalar_transfer to do the work.
	(transfer_real): Likewise.
	(transfer_real_write): Likewise.
	(transfer_character): Likewise.
	(transfer_character_wide): Likewise.
	(transfer_complex): Likewise.
	(transfer_array_inner): New function.
	(transfer_array): Call transfer_array_inner.
	(transfer_derived): Call wrap_scalar_transfer.
	(data_transfer_init): Check for asynchronous I/O.
	Perform a wait operation on any pending asynchronous I/O
	if the data transfer is synchronous. Copy PDT and enqueue
	thread for data transfer.
	(st_read_done_worker): New function.
	(st_read_done): Enqueue transfer or call st_read_done_worker.
	(st_write_done_worker): New function.
	(st_write_done): Enqueue transfer or call st_read_done_worker.
	(st_wait): Document as no-op for compatibility reasons.
	(st_wait_async): New function.
	* io/unit.c (insert_unit): Use macros LOCK, UNLOCK and TRYLOCK;
	add NOTE where necessary.
	(get_gfc_unit): Likewise.
	(init_units): Likewise.
	(close_unit_1): Likewise. Call async_close if asynchronous.
	(close_unit): Use macros LOCK and UNLOCK.
	(finish_last_advance_record): Likewise.
	(newunit_alloc): Likewise.
	* io/unix.c (find_file): Likewise.
	(flush_all_units_1): Likewise.
	(flush_all_units): Likewise.
	* libgfortran.h (generate_error_common): Add prototype.
	* runtime/error.c: Include io.h and async.h.
	(generate_error_common): New function.

2018-07-25  Nicolas Koenig  <koenigni@gcc.gnu.org>
	Thomas Koenig <tkoenig@gcc.gnu.org>

	PR fortran/25829
	* testsuite/libgomp.fortran/async_io_1.f90: New test.
	* testsuite/libgomp.fortran/async_io_2.f90: New test.
	* testsuite/libgomp.fortran/async_io_3.f90: New test.
	* testsuite/libgomp.fortran/async_io_4.f90: New test.
	* testsuite/libgomp.fortran/async_io_5.f90: New test.
	* testsuite/libgomp.fortran/async_io_6.f90: New test.
	* testsuite/libgomp.fortran/async_io_7.f90: New test.


Co-Authored-By: Thomas Koenig <tkoenig@gcc.gnu.org>

From-SVN: r262978
2018-07-25 18:48:39 +00:00
Jerry DeLisle 3a579cbe07 re PR libfortran/86070 (gfortran.dg/fmt_zero_digits.f90 segmentation fault starting with r261077)
2018-06-09  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/86070
	* io/write_float.def (build_float_string): Initialize *len.

From-SVN: r261382
2018-06-10 01:49:02 +00:00
Jerry DeLisle 1f161c48ed re PR fortran/85840 (Memory leak in write.c)
2018-05-28  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/85840
	* io/write.c (write_real, write_real_g0, write_complex): Use
	separate local variables for the float string length.

From-SVN: r260851
2018-05-28 21:55:31 +00:00
Jerry DeLisle 8cb19ee36a re PR target/89506 (ICE: in decompose, at rtl.h:2266 with -Og -g)
2018-05-26  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/89506
	* io/write.c (write_integer): Initialise the fnode format to
	FMT_NONE, used for list directed write.
	(BUF_STACK_SZ): Bump default buffer size up to avoid allocs on
	small stuff.

From-SVN: r260795
2018-05-26 18:22:18 +00:00
Jerry DeLisle 3c2ce89364 re PR fortran/85840 (Memory leak in write.c)
2018-05-26  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/85840
	* io/write.c (write_float_0): Use separate local variable for
	the float string length.

From-SVN: r260793
2018-05-26 17:30:52 +00:00
Jakub Jelinek 7ee4f6f3ec gfortran.h (gfc_dt): Rename default_exp field to dec_ext.
* gfortran.h (gfc_dt): Rename default_exp field to dec_ext.
	* ioparm.def (IOPARM_dt_default_exp): Rename to ...
	(IOPARM_dt_dec_ext): ... this.
	* trans-io.c (build_dt): Adjust for default_exp renaming to
	dec_ext and IOPARM_dt_default_exp renaming to IOPARM_dt_dec_ext.
	* io.c (match_io): Likewise.

	* io/io.h (IOPARM_DT_DEFAULT_EXP): Rename to ...
	(IOPARM_DT_DEC_EXT): ... this.
	* io/list_read.c (parse_real): Adjust for IOPARM_DT_DEFAULT_EXP
	renaming to IOPARM_DT_DEC_EXT.
	(read_real): Likewise.
	* io/read.c (read_f): Likewise.

From-SVN: r258920
2018-03-28 13:59:06 +02:00
Jerry DeLisle d5efbf3fd5 re PR fortran/84412 (Erroneous "Inquire statement identifies an internal file" error)
2018-02-18  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/84412
	* io/transfer.c (finalize_transfer): After completng an internal unit
	I/O operation, clear internal_unit_kind.

From-SVN: r257791
2018-02-18 15:32:39 +00:00
Thomas Koenig e9bfdf18cb libgfortran.h (GFC_ARRAY_DESCRIPTOR): Remove dimension of descriptor to use vaiable members for dim.
2018-02-12  Thomas Koenig  <tkoenig@gcc.gnu.org>

	* libgfortran.h (GFC_ARRAY_DESCRIPTOR): Remove dimension
	of descriptor to use vaiable members for dim.
	Change usage of GFC_ARRAY_DESCRIPTOR accordingly.
	(GFC_FILL_ARRAY_DESCRIPTOR): New macro.
	(gfc_full_array_i4): New type.
	* intrinsics/date_and_time.c (secnds): Use sizeof
	(gfc_array_i4) + sizeof (descriptor_dimension) for memory
	allocation.
	* intrinsics/reshape_generic.c: Use GFC_FULL_ARRAY_DESCRIPTOR.
	* io/format.c: Use sizeof (gfc_array_i4) + sizeof
	(descriptor_dimension) for memoy allocation.
	* io/list_read.c (list_formatted_read_scalar): Use
	gfc_full_array_i4 for variable.
	(nml_read_obj): Likewise.
	* io/write.c (list_formatted_write_scalar): Likewise.
	(nml_write_obj): Likewise.
	* m4/reshape.m4: Use GFC_FULL_ARRAY_DESCRIPTOR.
	* generated/reshape_c10.c: Regenerated.
	* generated/reshape_c16.c: Regenerated.
	* generated/reshape_c4.c: Regenerated.
	* generated/reshape_c8.c: Regenerated.
	* generated/reshape_i16.c: Regenerated.
	* generated/reshape_i4.c: Regenerated.
	* generated/reshape_i8.c: Regenerated.
	* generated/reshape_r10.c: Regenerated.
	* generated/reshape_r16.c: Regenerated.
	* generated/reshape_r4.c: Regenerated.
	* generated/reshape_r8.c: Regenerated.

From-SVN: r257601
2018-02-12 19:53:17 +00:00
Paul Thomas 7fb43006b2 re PR fortran/37577 ([meta-bug] change internal array descriptor format for better syntax, C interop TR, rank 15)
2018-25-01  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/37577
	* array.c (gfc_match_array_ref): If standard earlier than F2008
	it is an error if the reference dimension is greater than 7.
	libgfortran.h : Increase GFC_MAX_DIMENSIONS to 15. Change the
	dtype masks and shifts accordingly.
	* trans-array.c (gfc_conv_descriptor_dtype): Use the dtype
	type node to check the field.
	(gfc_conv_descriptor_dtype): Access the rank field of dtype.
	(duplicate_allocatable_coarray): Access the rank field of the
	dtype descriptor rather than the dtype itself.
	* trans-expr.c (get_scalar_to_descriptor_type): Store the type
	of 'scalar' on entry and use its TREE_TYPE if it is ARRAY_TYPE
	(ie. a character).
	(gfc_conv_procedure_call): Pass TREE_OPERAND (tmp,0) to
	get_scalar_to_descriptor_type if the actual expression is a
	constant.
	(gfc_trans_structure_assign): Assign the rank directly to the
	dtype rank field.
	* trans-intrinsic.c (gfc_conv_intrinsic_rank): Cast the result
	to default integer kind.
	(gfc_conv_intrinsic_sizeof): Obtain the element size from the
	'elem_len' field of the dtype.
	* trans-io.c (gfc_build_io_library_fndecls): Replace
	gfc_int4_type_node with dtype_type_node where necessary.
	(transfer_namelist_element): Use gfc_get_dtype_rank_type for
	scalars.
	* trans-types.c : Provide 'get_dtype_type_node' to acces the
	dtype_type_node and, if necessary, build it.
	The maximum size of an array element is now determined by the
	maximum value of size_t.
	Update the description of the array descriptor, including the
	type def for the dtype_type.
	(gfc_get_dtype_rank_type): Build a constructor for the dtype.
	Distinguish RECORD_TYPEs that are BT_DERIVED or BT_CLASS.
	(gfc_get_array_descriptor_base): Change the type of the dtype
	field to dtype_type_node.
	(gfc_get_array_descr_info): Get the offset to the rank field of
	the dtype.
	* trans-types.h : Add a prototype for 'get_dtype_type_node ()'.
	* trans.h : Define the indices of the dtype fields.

2018-25-01  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/37577
	* gfortran.dg/coarray_18.f90: Allow dimension 15 for F2008.
	* gfortran.dg/coarray_lib_this_image_2.f90: Change 'array1' to
	'array01' in the tree dump comparison.
	* gfortran.dg/coarray_lib_token_4.f90: Likewise.
	* gfortran.dg/inline_sum_1.f90: Similar - allow two digits.
	* gfortran.dg/rank_1.f90: Allow dimension 15 for F2008.

2018-25-01  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/37577
	* caf/single.c (_gfortran_caf_failed_images): Access the 'type'
	and 'elem_len' fields of the dtype instead of the shifts.
	(_gfortran_caf_stopped_images): Likewise.
	* intrinsics/associated.c (associated): Compare the 'type' and
	'elem_len' fields instead of the dtype.
	* caf/date_and_time.c : Access the dtype fields rather using
	shifts and masks.
	* io/transfer.c (transfer_array ): Comment on item count.
	(set_nml_var,st_set_nml_var): Change dtype type and use fields.
	(st_set_nml_dtio_var): Likewise.
	* libgfortran.h : Change definition of GFC_ARRAY_DESCRIPTOR and
	add a typedef for the dtype_type. Change the GFC_DTYPE_* macros
	to access the dtype fields.

From-SVN: r257065
2018-01-25 19:09:40 +00:00
Jerry DeLisle 33b2b069c1 re PR libfortran/83811 (fortran 'e' format broken for single digit exponents)
2018-01-18  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

        PR libgfortran/83811
        * write.c (select_buffer): Adjust buffer size up by 1.

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

From-SVN: r256669
2018-01-14 17:36:29 +00:00
Janne Blomqvist 4135a21f4d PR 78534 Regression on 32-bit targets
By switching from int to size_t in order to handle larger values,
r256322 introduced a bug that manifested itself on 32-bit
targets. Fixed by using the correct type to store the result of a
next_array_record call.

Regtested on x86_64-pc-linux-gnu and i686-pc-linux-gnu, committed to
trunk as obvious.

libgfortran/ChangeLog:

2018-01-08  Janne Blomqvist  <jb@gcc.gnu.org>

	PR 78534, bugfix for r256322
	* io/transfer.c (next_record_w): Use correct type for return value
	of next_array_record.

From-SVN: r256337
2018-01-08 14:12:05 +02:00
Janne Blomqvist ea99ec5bd6 PR 78534, 83704 Handle large formatted I/O
In order to handle large characters when doing formatted I/O, use
size_t and ptrdiff_t for lengths.  Compared to the previous patch,
based on discussions on IRC use size_t for sizes that don't need to be
negative rather than ptrdiff_t everywhere.

Regtested on x86_64-pc-linux-gnu, approved as part of the PR 78534
approval, committed to trunk.

libgfortran/ChangeLog:

2018-01-07  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/78534
	PR fortran/83704
	* io/fbuf.c (fbuf_init): Use size_t instead of int for length.
	(fbuf_debug): Convert debug output to unsigned long.
	(fbuf_reset): Use ptrdiff_t for return value.
	(fbuf_alloc): Use size_t for length argument.
	(fbuf_flush): Handle large buffers.
	(fbuf_flush_list): Likewise.
	(fbuf_seek): Use ptrdiff_t for offset and return value.
	(fbuf_read): Use size_t for length argument.
	(fbuf_getc_refill): Use size_t to match fbuf_read.
	* io/fbuf.h (struct fbuf): Use size_t for lengths.
	(fbuf_init): Use size_t instead of int for length.
	(fbuf_reset): Use ptrdiff_t for return value.
	(fbuf_alloc): Use size_t for length argument.
	(fbuf_seek): Use ptrdiff_t for offset and return value.
	(fbuf_read): Use size_t for length argument.
	* io/io.h (read_block_form): Likewise.
	(read_block_form4): Likewise.
	(write_block): Likewise.
	(read_a): Likewise.
	(read_a_char4): Likewise.
	(read_x): Likewise.
	(write_a): Likewise.
	(write_a_char4): Likewise.
	* io/list_read.c (list_formatted_read_scalar): Use size_t to
	handle large buffers.
	* io/read.c (read_l): Likewise.
	(read_utf8): Likewise.
	(read_utf8_char1): Likewise.
	(read_default_char1): Likewise.
	(read_utf8_char4): Likewise.
	(read_default_char4): Likewise.
	(read_a): Likewise.
	(read_a_char4): Likewise.
	(eat_leading_spaces): Likewise.
	(next_char): Likewise.
	(read_decimal): Likewise.
	(read_radix): Likewise.
	(read_f): Likewise.
	(read_x): Likewise.
	* io/transfer.c (read_sf_internal): Likewise.
	(read_sf): Likewise.
	(read_block_form): Likewise.
	(read_block_form4): Likewise.
	(write_block): Likewise.
	(formatted_transfer_scalar_write): Likewise.
	(next_record_w): Likewise.
	* io/unix.c (mem_alloc_r): Likewise.
	(mem_alloc_r4): Likewise.
	(mem_alloc_w): Likewise.
	(mem_alloc_w4): Likewise.
	(mem_read): Likewise.
	(mem_read4): Likewise.
	(mem_write): Likewise.
	(mem_write4): Likewise.
	(open_internal): Likewise.
	(open_internal4): Likewise.
	* io/unix.h (open_internal): Likewise.
	(open_internal4): Likewise.
	(mem_alloc_w): Likewise.
	(mem_alloc_r): Likewise.
	(mem_alloc_w4): Likewise.
	(mem_alloc_r4): Likewise.
	* io/write.c (write_check_cc): Likewise.
	(write_cc): Likewise.
	(write_a): Likewise.
	(write_a_char4): Likewise.

From-SVN: r256322
2018-01-07 12:17:52 +02:00
Janne Blomqvist dd8b1ebf35 Remove unused variable
2018-01-06  Janne Blomqvist  <jb@gcc.gnu.org>

        * io/write.c (namelist_write): Remove unused variable "i".

From-SVN: r256314
2018-01-06 21:16:55 +02:00