Commit Graph

210 Commits

Author SHA1 Message Date
Jakub Jelinek
7c3b9c1736 libgfortran: Fix build on non-glibc targets
When the __GLIBC_PREREQ macro isn't defined, the
  #if ... && defined __GLIBC_PREREQ && __GLIBC_PREREQ (2, 32)
directive has invalid syntax - the __GLIBC_PREREQ in there evaluates
to 0 and is followed by (2, 32).

2022-01-12  Jakub Jelinek  <jakub@redhat.com>

	* libgfortran.h (POWER_IEEE128): Use __GLIBC_PREREQ in a separate
	#if directive inside of #if ... && defined __GLIBC_PREREQ.
2022-01-12 09:43:18 +01:00
Jakub Jelinek
4d0e778fe3 libgfortran: Avoid using libquadmath APIs on powerpc64le on glibc 2.32+
On a glibc 2.32+ build, we still use some libquadmath APIs
when we shouldn't:
readelf -Wr /home/jakub/gcc/obj/powerpc64le-unknown-linux-gnu/libgfortran/.libs/libgfortran.so.5 | grep QUADMATH
00000000002502c8  0000002600000015 R_PPC64_JMP_SLOT       0000000000000000 fmaq@QUADMATH_1.0 + 0
00000000002505f8  0000006700000015 R_PPC64_JMP_SLOT       0000000000000000 tanq@QUADMATH_1.0 + 0
0000000000250930  0000009b00000015 R_PPC64_JMP_SLOT       0000000000000000 fabsq@QUADMATH_1.0 + 0
0000000000250940  0000009d00000015 R_PPC64_JMP_SLOT       0000000000000000 sinq@QUADMATH_1.0 + 0
0000000000250c98  000000cf00000015 R_PPC64_JMP_SLOT       0000000000000000 copysignq@QUADMATH_1.0 + 0
0000000000251038  0000010700000015 R_PPC64_JMP_SLOT       0000000000000000 cosq@QUADMATH_1.0 + 0
0000000000251068  0000010a00000015 R_PPC64_JMP_SLOT       0000000000000000 fmodq@QUADMATH_1.0 + 0
These should use __fmaieee128, __tanieee128 etc. instead.

2022-01-07  Jakub Jelinek  <jakub@redhat.com>

	* libgfortran.h (__copysignieee128, __fmaieee128, __fmodieee128):
	Declare.
	* intrinsics/trigd.c (COPYSIGN, FMOD, FABS, FMA, SIN, COS, TAN): If
	POWER_IEEE128 is defined, define these for kind 17 include.
	* intrinsics/trigd_lib.inc (COPYSIGN, FMOD, FABS, FMA, SIN, COS, TAN):
	Don't define if COPYSIGN is already defined.
2022-01-11 23:49:52 +01:00
Jakub Jelinek
5db042b2b8 fortran, libgfortran: Add remaining missing *_r17 symbols
Following patch adds remaining missing *_r17 entrypoints, so that
we have 91 *_r16 and 91 *_r17 entrypoints (and 24 *_c16 and 24 *_c17).

This fixes:
FAIL: gfortran.dg/dec_math.f90   -O0  execution test
FAIL: gfortran.dg/dec_math.f90   -O1  execution test
FAIL: gfortran.dg/dec_math.f90   -O2  execution test
FAIL: gfortran.dg/dec_math.f90   -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions  execution test
FAIL: gfortran.dg/dec_math.f90   -O3 -g  execution test
FAIL: gfortran.dg/dec_math.f90   -Os  execution test
FAIL: gfortran.dg/ieee/dec_math_1.f90   -O0  execution test
FAIL: gfortran.dg/ieee/dec_math_1.f90   -O1  execution test
FAIL: gfortran.dg/ieee/dec_math_1.f90   -O2  execution test
FAIL: gfortran.dg/ieee/dec_math_1.f90   -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions  execution test
FAIL: gfortran.dg/ieee/dec_math_1.f90   -O3 -g  execution test
FAIL: gfortran.dg/ieee/dec_math_1.f90   -Os  execution test

2022-01-04  Jakub Jelinek  <jakub@redhat.com>

gcc/fortran/
	* trans-intrinsic.c (gfc_get_intrinsic_lib_fndecl): Use
	gfc_type_abi_kind.
libgfortran/
	* libgfortran.h (GFC_REAL_17_INFINITY, GFC_REAL_17_QUIET_NAN): Define.
	(__erfcieee128): Declare.
	* intrinsics/trigd.c (_gfortran_sind_r17, _gfortran_cosd_r17,
	_gfortran_tand_r17): Define for HAVE_GFC_REAL_17.
	* intrinsics/random.c (random_r17, arandom_r17, rnumber_17): Define.
	* intrinsics/erfc_scaled.c (ERFC_SCALED): Define.
	(erfc_scaled_r16): Use ERFC_SCALED macro.
	(erfc_scaled_r17): Define.
2022-01-11 23:49:50 +01:00
Jakub Jelinek
07c60b8e33 fortran, libgfortran: -mabi=ieeelongdouble I/O
The following patch adds the compiler and library side of -mabi=ieeelongdouble
I/O support.

2022-01-04  Jakub Jelinek  <jakub@redhat.com>

gcc/fortran/
	* trans-io.c (transfer_namelist_element): Use gfc_type_abi_kind,
	formatting fixes.
	(transfer_expr): Use gfc_type_abi_kind, use *REAL128* APIs even
	for abi_kind == 17.
libgfortran/
	* libgfortran.h (__acoshieee128, __acosieee128, __asinhieee128,
	__asinieee128, __atan2ieee128, __atanhieee128, __atanieee128,
	__coshieee128, __cosieee128, __erfieee128, __expieee128,
	__fabsieee128, __jnieee128, __log10ieee128, __logieee128,
	__powieee128, __sinhieee128, __sinieee128, __sqrtieee128,
	__tanhieee128, __tanieee128, __ynieee128): Formatting fixes.
	(__strtoieee128, __snprintfieee128): Declare.
	* io/io.h (default_width_for_float, default_precision_for_float):
	Handle kind == 17.
	* io/size_from_kind.c (size_from_real_kind, size_from_complex_kind):
	Likewise.
	* io/read.c (set_integer, si_max, convert_real, convert_infnan,
	read_f): Likewise.
	* io/write.c (extract_uint, size_from_kind, set_fnode_default):
	Likewise.
	* io/write_float.def (DTOA2Q, FDTOA2Q): Define for HAVE_GFC_REAL_17.
	(determine_en_precision, get_float_string): Handle kind == 17.
	* io/transfer128.c: Use also for HAVE_GFC_REAL_17, but don't drag in
	libquadmath if POWER_IEEE128.
	* Makefile.am (comma, PREPROCESS): New variables.
	(gfortran.ver): New goal.
	(version_arg, version_dep): Use gfortran.ver instead of
	$(srcdir)/gfortran.map.
	(gfortran.map-sun): Depend on and use gfortran.ver instead of
	$(srcdir)/gfortran.map.
	(BUILT_SOURCES): Add $(version_dep).
	* Makefile.in: Regenerated.
	* gfortran.map (GFORTRAN_8): Don't export
	_gfortran_transfer_complex128, _gfortran_transfer_complex128_write,
	_gfortran_transfer_real128 and _gfortran_transfer_real128_write if
	HAVE_GFC_REAL_17 is defined.
	(GFORTRAN_12): Export those here instead.
2022-01-11 23:49:48 +01:00
Jakub Jelinek
23d11a0adc libgfortran: Small progress on the library side
The following patch quiets
../../../libgfortran/generated/in_pack_r17.c:35:1: warning: no previous prototype for ‘internal_pack_r17’ [-Wmissing-prototypes]
../../../libgfortran/generated/in_pack_c17.c:35:1: warning: no previous prototype for ‘internal_pack_c17’ [-Wmissing-prototypes]
../../../libgfortran/generated/in_unpack_r17.c:33:1: warning: no previous prototype for ‘internal_unpack_r17’ [-Wmissing-prototypes]
../../../libgfortran/generated/in_unpack_c17.c:33:1: warning: no previous prototype for ‘internal_unpack_c17’ [-Wmissing-prototypes]
../../../libgfortran/generated/pack_r17.c:73:1: warning: no previous prototype for ‘pack_r17’ [-Wmissing-prototypes]
../../../libgfortran/generated/pack_c17.c:73:1: warning: no previous prototype for ‘pack_c17’ [-Wmissing-prototypes]
../../../libgfortran/generated/unpack_r17.c:34:1: warning: no previous prototype for ‘unpack0_r17’ [-Wmissing-prototypes]
../../../libgfortran/generated/unpack_r17.c:178:1: warning: no previous prototype for ‘unpack1_r17’ [-Wmissing-prototypes]
../../../libgfortran/generated/unpack_c17.c:34:1: warning: no previous prototype for ‘unpack0_c17’ [-Wmissing-prototypes]
../../../libgfortran/generated/unpack_c17.c:178:1: warning: no previous prototype for ‘unpack1_c17’ [-Wmissing-prototypes]
../../../libgfortran/generated/spread_r17.c:34:1: warning: no previous prototype for ‘spread_r17’ [-Wmissing-prototypes]
../../../libgfortran/generated/spread_r17.c:230:1: warning: no previous prototype for ‘spread_scalar_r17’ [-Wmissing-prototypes]
../../../libgfortran/generated/spread_c17.c:34:1: warning: no previous prototype for ‘spread_c17’ [-Wmissing-prototypes]
../../../libgfortran/generated/spread_c17.c:230:1: warning: no previous prototype for ‘spread_scalar_c17’ [-Wmissing-prototypes]
../../../libgfortran/generated/cshift0_r17.c:33:1: warning: no previous prototype for ‘cshift0_r17’ [-Wmissing-prototypes]
../../../libgfortran/generated/cshift0_c17.c:33:1: warning: no previous prototype for ‘cshift0_c17’ [-Wmissing-prototypes]
../../../libgfortran/generated/cshift1_4_r17.c:32:1: warning: no previous prototype for ‘cshift1_4_r17’ [-Wmissing-prototypes]
../../../libgfortran/generated/cshift1_4_c17.c:32:1: warning: no previous prototype for ‘cshift1_4_c17’ [-Wmissing-prototypes]
../../../libgfortran/generated/cshift1_8_r17.c:32:1: warning: no previous prototype for ‘cshift1_8_r17’ [-Wmissing-prototypes]
../../../libgfortran/generated/cshift1_8_c17.c:32:1: warning: no previous prototype for ‘cshift1_8_c17’ [-Wmissing-prototypes]
../../../libgfortran/generated/cshift1_16_r17.c:32:1: warning: no previous prototype for ‘cshift1_16_r17’ [-Wmissing-prototypes]
../../../libgfortran/generated/cshift1_16_c17.c:32:1: warning: no previous prototype for ‘cshift1_16_c17’ [-Wmissing-prototypes]
warnings during libgfortran build and exports the new entrypoints.
Note, not all of them, clearly e.g. there are fewer *_r17* entrypoints than
*_r16* entrypoints, so more work is needed.

2021-12-31  Jakub Jelinek  <jakub@redhat.com>

	* libgfortran.h (internal_pack_r17, internal_pack_c17,
	internal_unpack_r17, internal_unpack_c17, pack_r17, pack_c17,
	unpack0_r17, unpack0_c17, unpack1_r17, unpack1_c17, spread_r17,
	spread_c17, spread_scalar_r17, spread_scalar_c17, cshift0_r17,
	cshift0_c17, cshift1_4_r17, cshift1_8_r17, cshift1_16_r17,
	cshift1_4_c17, cshift1_8_c17, cshift1_16_c17): Declare.
	* gfortran.map (GFORTRAN_12): Export *_r17 and *_c17.
2022-01-11 23:41:02 +01:00
Thomas Koenig
49ad4d2c30 Prepare library for REAL(KIND=17).
This prepares the library side for REAL(KIND=17).  It is
not yet tested, but at least compiles cleanly on POWER 9
and x86_64.

2021-10-19  Thomas Koenig  <tkoenig@gcc.gnu.org>

	* Makefile.am: Add _r17 and _c17 files.  Build them
	with -mabi=ieeelongdouble on POWER.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: New flag HAVE_REAL_17.
	* kinds-override.h: (HAVE_GFC_REAL_17): New macro.
	(HAVE_GFC_COMPLEX_17): New macro.
	(GFC_REAL_17_HUGE): New macro.
	(GFC_REAL_17_LITERAL_SUFFIX): New macro.
	(GFC_REAL_17_LITERAL): New macro.
	(GFC_REAL_17_DIGITS): New macro.
	(GFC_REAL_17_RADIX): New macro.
	* libgfortran.h	(POWER_IEEE128): New macro.
	(gfc_array_r17): Typedef.
	(GFC_DTYPE_REAL_17): New macro.
	(GFC_DTYPE_COMPLEX_17): New macro.
	(__acoshieee128): Prototype.
	(__acosieee128): Prototype.
	(__asinhieee128): Prototype.
	(__asinieee128): Prototype.
	(__atan2ieee128): Prototype.
	(__atanhieee128): Prototype.
	(__atanieee128): Prototype.
	(__coshieee128): Prototype.
	(__cosieee128): Prototype.
	(__erfieee128): Prototype.
	(__expieee128): Prototype.
	(__fabsieee128): Prototype.
	(__jnieee128): Prototype.
	(__log10ieee128): Prototype.
	(__logieee128): Prototype.
	(__powieee128): Prototype.
	(__sinhieee128): Prototype.
	(__sinieee128): Prototype.
	(__sqrtieee128): Prototype.
	(__tanhieee128): Prototype.
	(__tanieee128): Prototype.
	(__ynieee128): Prototype.
	* m4/mtype.m4: Make a bit more readable. Add KIND=17.
	* generated/_abs_c17.F90: New file.
	* generated/_abs_r17.F90: New file.
	* generated/_acos_r17.F90: New file.
	* generated/_acosh_r17.F90: New file.
	* generated/_aimag_c17.F90: New file.
	* generated/_aint_r17.F90: New file.
	* generated/_anint_r17.F90: New file.
	* generated/_asin_r17.F90: New file.
	* generated/_asinh_r17.F90: New file.
	* generated/_atan2_r17.F90: New file.
	* generated/_atan_r17.F90: New file.
	* generated/_atanh_r17.F90: New file.
	* generated/_conjg_c17.F90: New file.
	* generated/_cos_c17.F90: New file.
	* generated/_cos_r17.F90: New file.
	* generated/_cosh_r17.F90: New file.
	* generated/_dim_r17.F90: New file.
	* generated/_exp_c17.F90: New file.
	* generated/_exp_r17.F90: New file.
	* generated/_log10_r17.F90: New file.
	* generated/_log_c17.F90: New file.
	* generated/_log_r17.F90: New file.
	* generated/_mod_r17.F90: New file.
	* generated/_sign_r17.F90: New file.
	* generated/_sin_c17.F90: New file.
	* generated/_sin_r17.F90: New file.
	* generated/_sinh_r17.F90: New file.
	* generated/_sqrt_c17.F90: New file.
	* generated/_sqrt_r17.F90: New file.
	* generated/_tan_r17.F90: New file.
	* generated/_tanh_r17.F90: New file.
	* generated/bessel_r17.c: New file.
	* generated/cshift0_c17.c: New file.
	* generated/cshift0_r17.c: New file.
	* generated/cshift1_16_c17.c: New file.
	* generated/cshift1_16_r17.c: New file.
	* generated/cshift1_4_c17.c: New file.
	* generated/cshift1_4_r17.c: New file.
	* generated/cshift1_8_c17.c: New file.
	* generated/cshift1_8_r17.c: New file.
	* generated/findloc0_c17.c: New file.
	* generated/findloc0_r17.c: New file.
	* generated/findloc1_c17.c: New file.
	* generated/findloc1_r17.c: New file.
	* generated/in_pack_c17.c: New file.
	* generated/in_pack_r17.c: New file.
	* generated/in_unpack_c17.c: New file.
	* generated/in_unpack_r17.c: New file.
	* generated/matmul_c17.c: New file.
	* generated/matmul_r17.c: New file.
	* generated/matmulavx128_c17.c: New file.
	* generated/matmulavx128_r17.c: New file.
	* generated/maxloc0_16_r17.c: New file.
	* generated/maxloc0_4_r17.c: New file.
	* generated/maxloc0_8_r17.c: New file.
	* generated/maxloc1_16_r17.c: New file.
	* generated/maxloc1_4_r17.c: New file.
	* generated/maxloc1_8_r17.c: New file.
	* generated/maxval_r17.c: New file.
	* generated/minloc0_16_r17.c: New file.
	* generated/minloc0_4_r17.c: New file.
	* generated/minloc0_8_r17.c: New file.
	* generated/minloc1_16_r17.c: New file.
	* generated/minloc1_4_r17.c: New file.
	* generated/minloc1_8_r17.c: New file.
	* generated/minval_r17.c: New file.
	* generated/norm2_r17.c: New file.
	* generated/pack_c17.c: New file.
	* generated/pack_r17.c: New file.
	* generated/pow_c17_i16.c: New file.
	* generated/pow_c17_i4.c: New file.
	* generated/pow_c17_i8.c: New file.
	* generated/pow_r17_i16.c: New file.
	* generated/pow_r17_i4.c: New file.
	* generated/pow_r17_i8.c: New file.
	* generated/product_c17.c: New file.
	* generated/product_r17.c: New file.
	* generated/reshape_c17.c: New file.
	* generated/reshape_r17.c: New file.
	* generated/spread_c17.c: New file.
	* generated/spread_r17.c: New file.
	* generated/sum_c17.c: New file.
	* generated/sum_r17.c: New file.
	* generated/unpack_c17.c: New file.
	* generated/unpack_r17.c: New file.
2022-01-11 23:39:54 +01:00
Jakub Jelinek
7adcbafe45 Update copyright years. 2022-01-03 10:42:10 +01:00
Francois-Xavier Coudert
4ae906e46c Fortran: simplify library code for integer-to-decimal conversion
libgfortran/ChangeLog:

	PR libfortran/81986
	PR libfortran/99191

	* libgfortran.h: Remove gfc_xtoa(), adjust gfc_itoa() and
	GFC_ITOA_BUF_SIZE.
	* io/write.c (write_decimal): conversion parameter is always
	gfc_itoa(), so remove it. Protect from overflow.
	(xtoa): Move gfc_xtoa and update its name.
	(xtoa_big): Renamed from ztoa_big for consistency.
	(write_z): Adjust to new function names.
	(write_i, write_integer): Remove last arg of write_decimal.
	* runtime/backtrace.c (error_callback): Comment on the use of
	gfc_itoa().
	* runtime/error.c (gfc_xtoa): Move to io/write.c.
	* runtime/string.c (gfc_itoa): Take an unsigned argument,
	remove the handling of negative values.
2021-12-25 15:07:12 +01:00
François-Xavier Coudert
21423a1dfa Fortran: Cast arguments of <ctype.h> functions to unsigned char
Functions from <ctype.h> should only be called on values that can be
represented by unsigned char. On targets where char is a signed type,
some of libgfortran calls have undefined behaviour.

The solution is to cast the argument to unsigned char type. I’ve defined
macros in libgfortran.h to do so, to retain legibility of the library
code.

PR libfortran/95177

libgfortran/ChangeLog

	* libgfortran.h: include ctype.h, provide safe macros.
	* io/format.c: use safe macros.
	* io/list_read.c: use safe macros.
	* io/read.c: use safe macros.
	* io/write.c: use safe macros.
	* runtime/environ.c: use safe macros.
2021-12-18 09:21:16 +01:00
José Rui Faustino de Sousa
d514626ee2 Fortran: Fix some issues with pointers to character.
gcc/fortran/ChangeLog:

	PR fortran/100120
	PR fortran/100816
	PR fortran/100818
	PR fortran/100819
	PR fortran/100821
	* trans-array.c (gfc_get_array_span): rework the way character
	array "span" was calculated.
	(gfc_conv_expr_descriptor): improve handling of character sections
	and unlimited polymorphic objects.
	* trans-expr.c (gfc_get_character_len): new function to calculate
	character string length.
	(gfc_get_character_len_in_bytes): new function to calculate
	character string length in bytes.
	(gfc_conv_scalar_to_descriptor): add call to set the "span".
	(gfc_trans_pointer_assignment): set "_len" and antecipate the
	initialization of the deferred character length hidden argument.
	* trans-intrinsic.c (gfc_conv_associated): set "force_no_tmp" to
	avoid the creation of a temporary.
	* trans-types.c (gfc_get_dtype_rank_type): rework type detection
	so that unlimited polymorphic objects get proper type infomation,
	also important for bind(c).
	(gfc_get_dtype): add argument to pass the rank if necessary.
	(gfc_get_array_type_bounds): cosmetic change to have character
	arrays called character instead of unknown.
	* trans-types.h (gfc_get_dtype): modify prototype.
	* trans.c (get_array_span): rework the way character array "span"
	was calculated.
	* trans.h (gfc_get_character_len): new prototype.
	(gfc_get_character_len_in_bytes): new prototype.
	Add "unlimited_polymorphic" flag to "gfc_se" type to signal when
	expression carries an unlimited polymorphic object.

libgfortran/ChangeLog:

	PR fortran/100120
	* intrinsics/associated.c (associated): have associated verify if
	the "span" matches insted of the "elem_len".
	* libgfortran.h (GFC_DESCRIPTOR_SPAN): add macro to retrive the
	descriptor "span".

gcc/testsuite/ChangeLog:

	PR fortran/100120
	* gfortran.dg/PR100120.f90: New test.
	PR fortran/100816
	PR fortran/100818
	PR fortran/100819
	PR fortran/100821
	* gfortran.dg/character_workout_1.f90: New test.
	* gfortran.dg/character_workout_4.f90: New test.
2021-06-05 11:12:50 +00:00
Jakub Jelinek
99dee82307 Update copyright years. 2021-01-04 10:26:59 +01:00
Maciej W. Rozycki
c87cce5a33 libgfortran: Correct FP feature macro checks
The *_HAS_* floating-point feature macros are defined as 0/1 rather than
#undef/#define settings by gcc/c-family/c-cppbuiltin.c.  Consequently we
choose to use infinity and NaN features even with non-IEEE-754 targets
such as `vax-netbsdelf' that lack them, causing build warnings and
failures like:

In file included from .../libgfortran/generated/maxval_r4.c:26:
.../libgfortran/generated/maxval_r4.c: In function 'maxval_r4':
.../libgfortran/libgfortran.h:292:30: warning: target format does not support infinity
  292 | # define GFC_REAL_4_INFINITY __builtin_inff ()
      |                              ^~~~~~~~~~~~~~
.../libgfortran/generated/maxval_r4.c:149:19:
note: in expansion of macro 'GFC_REAL_4_INFINITY'
  149 |         result = -GFC_REAL_4_INFINITY;
      |                   ^~~~~~~~~~~~~~~~~~~
.../libgfortran/generated/maxval_r4.c: In function 'mmaxval_r4':
.../libgfortran/libgfortran.h:292:30: warning: target format does not support infinity
  292 | # define GFC_REAL_4_INFINITY __builtin_inff ()
      |                              ^~~~~~~~~~~~~~
.../libgfortran/generated/maxval_r4.c:363:19:
note: in expansion of macro 'GFC_REAL_4_INFINITY'
  363 |         result = -GFC_REAL_4_INFINITY;
      |                   ^~~~~~~~~~~~~~~~~~~
{standard input}: Assembler messages:
{standard input}:204: Fatal error: Can't relocate expression
make[3]: *** [Makefile:3358: maxval_r4.lo] Error 1

Correct the checks then for __FLT_HAS_INFINITY__, __DBL_HAS_INFINITY__,
__LDBL_HAS_INFINITY__, __FLT_HAS_QUIET_NAN__, __DBL_HAS_QUIET_NAN__, and
__LDBL_HAS_QUIET_NAN__ to match semantics and remove build issues coming
from the misinterpretation of these macros.

	libgfortran/
	* libgfortran.h: Use #if rather than #ifdef with
	__FLT_HAS_INFINITY__, __DBL_HAS_INFINITY__,
	__LDBL_HAS_INFINITY__, __FLT_HAS_QUIET_NAN__,
	__DBL_HAS_QUIET_NAN__, and __LDBL_HAS_QUIET_NAN__.
2020-11-26 17:26:43 +00:00
Jakub Jelinek
8d9254fc8a Update copyright years.
From-SVN: r279813
2020-01-01 12:51:42 +01:00
Janne Blomqvist
d74a8b0579 PR fortran/68401 Improve allocation error message
Improve the error message that is printed when a memory allocation
fails, by including the location, and the size of the allocation that
failed.

Regtested on x86_64-pc-linux-gnu.

gcc/fortran/ChangeLog:

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

	PR fortran/68401
	* trans-decl.c (gfc_build_builtin_function_decls): Replace
	os_error with os_error_at decl.
	* trans.c (trans_runtime_error_vararg): Modify so the error
	function decl is passed directly.
	(gfc_trans_runtime_error): Pass correct error function decl.
	(gfc_trans_runtime_check): Likewise.
	(trans_os_error_at): New function.
	(gfc_call_malloc): Use trans_os_error_at.
	(gfc_allocate_using_malloc): Likewise.
	(gfc_call_realloc): Likewise.
	* trans.h (gfor_fndecl_os_error): Replace with gfor_fndecl_os_error_at.

libgfortran/ChangeLog:

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

	PR fortran/68401
	* gfortran.map: Add GFORTRAN_10 node, add _gfortran_os_error_at
	symbol.
	* libgfortran.h (os_error_at): New prototype.
	* runtime/error.c (os_error_at): New function.

From-SVN: r274599
2019-08-17 08:45:37 +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
Thomas Koenig
419af57c13 re PR fortran/45424 ([F08] Add IS_CONTIGUOUS intrinsic)
2019-01-07  Thomas Koenig  <tkoenig@gcc.gnu.org>
	Harald Anlauf <anlauf@gmx.de>
	Tobias Burnus <burnus@gcc.gnu.org>

	PR fortran/45424
	* check.c (gfc_check_is_contiguous): New function.
	* expr.c (gfc_is_not_contiguous): New function.
	* gfortran.h (gfc_isym_id): Add GFC_ISYM_IS_CONTIGUOUS.
	Add prototype for gfc_is_not_contiguous.
	* intrinsic.c (do_ts29113_check): Add GFC_ISYM_IS_CONTIGUOUS.
	(add_function): Add is_contiguous.
	* intrinsic.h: Add prototypes for gfc_check_is_contiguous,
	gfc_simplify_is_contiguous and gfc_resolve_is_contiguous.
	* intrinsic.texi: Add IS_CONTIGUOUS.
	* iresolve.c (gfc_resolve_is_contiguous): New function.
	* simplify.c (gfc_simplify_is_contiguous): New function.
	* trans-decl.c (gfor_fncecl_is_contiguous0): New variable.
	(gfc_build_intrinsic_function_decl): Add it.
	* trans-intrinsic.c (gfc_conv_intrinsic_is_contiguous): New
	function.
	(gfc_conv_intrinsic_function): Handle GFC_ISYM_IS_CONTIGUOUS.

2019-01-07  Thomas Koenig  <tkoenig@gcc.gnu.org>
	Harald Anlauf <anlauf@gmx.de>
	Tobias Burnus <burnus@gcc.gnu.org>

	PR fortran/45424
	* Makefile.am: Add intrinsics/is_contiguous.c.
	* Makefile.in: Regenerated.
	* gfortran.map: Add _gfortran_is_contiguous0.
	* intrinsics/is_contiguous.c: New file.
	* libgfortran.h: Add prototype for is_contiguous0.

2019-01-07  Thomas Koenig  <tkoenig@gcc.gnu.org>
	Harald Anlauf <anlauf@gmx.de>
	Tobias Burnus <burnus@gcc.gnu.org>

	* gfortran.dg/is_contiguous_1.f90: New test.
	* gfortran.dg/is_contiguous_2.f90: New test.
	* gfortran.dg/is_contiguous_3.f90: New test.


Co-Authored-By: Harald Anlauf <anlauf@gmx.de>
Co-Authored-By: Tobias Burnus <burnus@gcc.gnu.org>

From-SVN: r267657
2019-01-07 19:30:28 +00:00
Martin Sebor
29d2485270 PR c/88546 - Copy attribute unusable for weakrefs
gcc/c-family/ChangeLog:

	PR c/88546
	* c-attribs.c (handle_copy_attribute): Avoid copying attribute leaf.
	Handle C++ empty throw specification and C11 _Noreturn.
	(has_attribute): Also handle C11 _Noreturn.

gcc/ChangeLog:

	PR c/88546
	* attribs.c (decls_mismatched_attributes): Avoid warning for attribute
	leaf.

gcc/testsuite/ChangeLog:

	PR c/88546
	* g++.dg/ext/attr-copy.C: New test.
	* gcc.dg/attr-copy-4.c: Disable macro expansion tracking.
	* gcc.dg/attr-copy-6.c: New test.
	* gcc.dg/attr-copy-7.c: New test.

From-SVN: r267591
2019-01-04 17:57:30 -07:00
Jakub Jelinek
a554497024 Update copyright years.
From-SVN: r267494
2019-01-01 13:31:55 +01:00
Thomas Koenig
01ce9e31a0 re PR fortran/54613 ([F08] Add FINDLOC plus support MAXLOC/MINLOC with KIND=/BACK=)
2017-10-28  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/54613
	* gfortran.h (gfc_isym_id): Add GFC_ISYM_FINDLOC.
	(gfc_check_f): Add f6fl field.
	(gfc_simplify_f): Add f6 field.
	(gfc_resolve_f): Likewise.
	(gfc_type_letter): Add optional logical_equas_int flag.
	* check.c (intrinsic_type_check): New function.
	(gfc_check_findloc): New function.
	* intrinsics.c (gfc_type_letter): If logical_equals_int is
	set, act accordingly.
	(add_sym_5ml):  Reformat comment.
	(add_sym_6fl): New function.
	(add_functions): Add findloc.
	(check_arglist): Add sixth argument, handle it.
	(resolve_intrinsic): Likewise.
	(check_specific): Handle findloc.
	* intrinsic.h (gfc_check_findloc): Add prototype.
	(gfc_simplify_findloc): Likewise.
	(gfc_resolve_findloc): Likewise.
	(MAX_INTRINSIC_ARGS): Adjust.
	* iresolve.c (gfc_resolve_findloc): New function.
	* simplify.c (gfc_simplify_minmaxloc): Make static.
	(simplify_findloc_to_scalar): New function.
	(simplify_findloc_nodim): New function.
	(simplify_findloc_to_array): New function.
	(gfc_simplify_findloc): New function.
	(gfc_conv_intrinsic_findloc): New function.
	(gfc_conv_intrinsic_function): Handle GFC_ISYM_FINDLOC.
	(gfc_is_intrinsic_libcall): Likewise.

2017-10-28  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/54613
	* Makefile.am: Add files for findloc.
	* Makefile.in: Regenerated.
	* libgfortran.h (gfc_array_index_type): Add.
	(gfc_array_s1): Add using GFC_UINTEGER_1.
	(gfc_array_s4): Likewise.
	Replace unnecessary comment.
	(HAVE_GFC_UINTEGER_1): Define.
	(HAVE_GFC_UINTEGER_4): Define.
	* m4/findloc0.m4: New file.
	* m4/findloc0s.m4: New file.
	* m4/findloc1.m4: New file.
	* m4/findloc1s.m4: New file.
	* m4/findloc2s.m4: New file.
	* m4/ifindloc0.m4: New file.
	* m4/ifindloc1.m4: New file.
	* m4/ifindloc2.m4: New file.
	* m4/iparm.m4: Use unsigned integer for characters.
        * generated/findloc0_c16.c: New file.
        * generated/findloc0_c4.c: New file.
        * generated/findloc0_c8.c: New file.
        * generated/findloc0_i1.c: New file.
        * generated/findloc0_i16.c: New file.
        * generated/findloc0_i2.c: New file.
        * generated/findloc0_i4.c: New file.
        * generated/findloc0_i8.c: New file.
        * generated/findloc0_r16.c: New file.
        * generated/findloc0_r4.c: New file.
        * generated/findloc0_r8.c: New file.
        * generated/findloc0_s1.c: New file.
        * generated/findloc0_s4.c: New file.
        * generated/findloc1_c16.c: New file.
        * generated/findloc1_c4.c: New file.
        * generated/findloc1_c8.c: New file.
        * generated/findloc1_i1.c: New file.
        * generated/findloc1_i16.c: New file.
        * generated/findloc1_i2.c: New file.
        * generated/findloc1_i4.c: New file.
        * generated/findloc1_i8.c: New file.
        * generated/findloc1_r16.c: New file.
        * generated/findloc1_r4.c: New file.
        * generated/findloc1_r8.c: New file.
        * generated/findloc1_s1.c: New file.
        * generated/findloc1_s4.c: New file.
        * generated/findloc2_s1.c: New file.
        * generated/findloc2_s4.c: New file.
        * generated/maxloc0_16_s1.c: Regenerated.
        * generated/maxloc0_16_s4.c: Regenerated.
        * generated/maxloc0_4_s1.c: Regenerated.
        * generated/maxloc0_4_s4.c: Regenerated.
        * generated/maxloc0_8_s1.c: Regenerated.
        * generated/maxloc0_8_s4.c: Regenerated.
        * generated/maxloc1_16_s1.c: Regenerated.
        * generated/maxloc1_16_s4.c: Regenerated.
        * generated/maxloc1_4_s1.c: Regenerated.
        * generated/maxloc1_4_s4.c: Regenerated.
        * generated/maxloc1_8_s1.c: Regenerated.
        * generated/maxloc1_8_s4.c: Regenerated.
        * generated/maxloc2_16_s1.c: Regenerated.
        * generated/maxloc2_16_s4.c: Regenerated.
        * generated/maxloc2_4_s1.c: Regenerated.
        * generated/maxloc2_4_s4.c: Regenerated.
        * generated/maxloc2_8_s1.c: Regenerated.
        * generated/maxloc2_8_s4.c: Regenerated.
        * generated/maxval0_s1.c: Regenerated.
        * generated/maxval0_s4.c: Regenerated.
        * generated/maxval1_s1.c: Regenerated.
        * generated/maxval1_s4.c: Regenerated.
        * generated/minloc0_16_s1.c: Regenerated.
        * generated/minloc0_16_s4.c: Regenerated.
        * generated/minloc0_4_s1.c: Regenerated.
        * generated/minloc0_4_s4.c: Regenerated.
        * generated/minloc0_8_s1.c: Regenerated.
        * generated/minloc0_8_s4.c: Regenerated.
        * generated/minloc1_16_s1.c: Regenerated.
        * generated/minloc1_16_s4.c: Regenerated.
        * generated/minloc1_4_s1.c: Regenerated.
        * generated/minloc1_4_s4.c: Regenerated.
        * generated/minloc1_8_s1.c: Regenerated.
        * generated/minloc1_8_s4.c: Regenerated.
        * generated/minloc2_16_s1.c: Regenerated.
        * generated/minloc2_16_s4.c: Regenerated.
        * generated/minloc2_4_s1.c: Regenerated.
        * generated/minloc2_4_s4.c: Regenerated.
        * generated/minloc2_8_s1.c: Regenerated.
        * generated/minloc2_8_s4.c: Regenerated.
        * generated/minval0_s1.c: Regenerated.
        * generated/minval0_s4.c: Regenerated.
        * generated/minval1_s1.c: Regenerated.
        * generated/minval1_s4.c: Regenerated.

2017-10-28  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/54613
	* gfortran.dg/findloc_1.f90: New test.
	* gfortran.dg/findloc_2.f90: New test.
	* gfortran.dg/findloc_3.f90: New test.
	* gfortran.dg/findloc_4.f90: New test.
	* gfortran.dg/findloc_5.f90: New test.
	* gfortran.dg/findloc_6.f90: New test.

From-SVN: r265570
2018-10-28 11:05:05 +00:00
Janne Blomqvist
edaaef601d Use vectored writes when reporting errors and warnings.
When producing error and warning messages, libgfortran writes a
message by using many system calls.  By using vectored writes (the
POSIX writev function) when available and feasible to use without
major surgery, we reduce the chance that output gets intermingled with
other output to stderr.

In practice, this is done by introducing a new function estr_writev in
addition to the existing estr_write.  In order to use this, the old
st_vprintf is removed, replaced by direct calls of vsnprintf, allowing
more message batching.

Regtested on x86_64-pc-linux-gnu.

libgfortran/ChangeLog:

2018-09-21  Janne Blomqvist  <jb@gcc.gnu.org>

	* config.h.in: Regenerated.
	* configure: Regenerated.
	* configure.ac: Check for writev and sys/uio.h.
	* libgfortran.h: Include sys/uio.h.
	(st_vprintf): Remove prototype.
	(struct iovec): Define if not available.
	(estr_writev): New prototype.
	* runtime/backtrace.c (error_callback): Use estr_writev.
	* runtime/error.c (ST_VPRINTF_SIZE): Remove.
	(estr_writev): New function.
	(st_vprintf): Remove.
	(gf_vsnprintf): New function.
	(ST_ERRBUF_SIZE): New macro.
	(st_printf): Use vsnprintf.
	(os_error): Use estr_writev.
	(runtime_error): Use vsnprintf and estr_writev.
	(runtime_error_at): Likewise.
	(runtime_warning_at): Likewise.
	(internal_error): Use estr_writev.
	(generate_error_common): Likewise.
	(generate_warning): Likewise.
	(notify_std): Likewise.
	* runtime/pause.c (pause_string): Likewise.
	* runtime/stop.c (report_exception): Likewise.
	(stop_string): Likewise.
	(error_stop_string): Likewise.

From-SVN: r264487
2018-09-21 21:12:59 +03: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
Steven G. Kargl
ca708a2b55 re PR fortran/85816 (nested spread fails with "Integer overflow in xmallocarray")
2018-06-01  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/85816
	PR fortran/85975
	* libgfortran.h: Remove the GFC_DTYPE_COPY_SETRANK macro.
	* intrinsics/reshape_generic.c: Directly assign rank.
	* intrinsics/spread_generic.c: Ditto.
	* m4/iforeach-s.m4: Ditto.
	* m4/iforeach.m4: Ditto.
	* m4/ifunction-s.m4: Ditto.
	* m4/ifunction-s2.m4: Ditto.
	* m4/ifunction.m4: Ditto.
	* m4/ifunction_logical.m4: Ditto.
	* m4/reshape.m4: Ditto.
	* m4/spread.m4: Ditto.
	* generated/all_l1.c: Regenerated from m4 files.
	* generated/all_l16.c: Ditto.
	* generated/all_l2.c: Ditto.
	* generated/all_l4.c: Ditto.
	* generated/all_l8.c: Ditto.
	* generated/any_l1.c: Ditto.
	* generated/any_l16.c: Ditto.
	* generated/any_l2.c: Ditto.
	* generated/any_l4.c: Ditto.
	* generated/any_l8.c: Ditto.
	* generated/count_16_l.c: Ditto.
	* generated/count_1_l.c: Ditto.
	* generated/count_2_l.c: Ditto.
	* generated/count_4_l.c: Ditto.
	* generated/count_8_l.c: Ditto.
	* generated/iall_i1.c: Ditto.
	* generated/iall_i16.c: Ditto.
	* generated/iall_i2.c: Ditto.
	* generated/iall_i4.c: Ditto.
	* generated/iall_i8.c: Ditto.
	* generated/iany_i1.c: Ditto.
	* generated/iany_i16.c: Ditto.
	* generated/iany_i2.c: Ditto.
	* generated/iany_i4.c: Ditto.
	* generated/iany_i8.c: Ditto.
	* generated/iparity_i1.c: Ditto.
	* generated/iparity_i16.c: Ditto.
	* generated/iparity_i2.c: Ditto.
	* generated/iparity_i4.c: Ditto.
	* generated/iparity_i8.c: Ditto.
	* generated/maxloc0_16_i1.c: Ditto.
	* generated/maxloc0_16_i16.c: Ditto.
	* generated/maxloc0_16_i2.c: Ditto.
	* generated/maxloc0_16_i4.c: Ditto.
	* generated/maxloc0_16_i8.c: Ditto.
	* generated/maxloc0_16_r10.c: Ditto.
	* generated/maxloc0_16_r16.c: Ditto.
	* generated/maxloc0_16_r4.c: Ditto.
	* generated/maxloc0_16_r8.c: Ditto.
	* generated/maxloc0_16_s1.c: Ditto.
	* generated/maxloc0_16_s4.c: Ditto.
	* generated/maxloc0_4_i1.c: Ditto.
	* generated/maxloc0_4_i16.c: Ditto.
	* generated/maxloc0_4_i2.c: Ditto.
	* generated/maxloc0_4_i4.c: Ditto.
	* generated/maxloc0_4_i8.c: Ditto.
	* generated/maxloc0_4_r10.c: Ditto.
	* generated/maxloc0_4_r16.c: Ditto.
	* generated/maxloc0_4_r4.c: Ditto.
	* generated/maxloc0_4_r8.c: Ditto.
	* generated/maxloc0_4_s1.c: Ditto.
	* generated/maxloc0_4_s4.c: Ditto.
	* generated/maxloc0_8_i1.c: Ditto.
	* generated/maxloc0_8_i16.c: Ditto.
	* generated/maxloc0_8_i2.c: Ditto.
	* generated/maxloc0_8_i4.c: Ditto.
	* generated/maxloc0_8_i8.c: Ditto.
	* generated/maxloc0_8_r10.c: Ditto.
	* generated/maxloc0_8_r16.c: Ditto.
	* generated/maxloc0_8_r4.c: Ditto.
	* generated/maxloc0_8_r8.c: Ditto.
	* generated/maxloc0_8_s1.c: Ditto.
	* generated/maxloc0_8_s4.c: Ditto.
	* generated/maxloc1_16_i1.c: Ditto.
	* generated/maxloc1_16_i16.c: Ditto.
	* generated/maxloc1_16_i2.c: Ditto.
	* generated/maxloc1_16_i4.c: Ditto.
	* generated/maxloc1_16_i8.c: Ditto.
	* generated/maxloc1_16_r10.c: Ditto.
	* generated/maxloc1_16_r16.c: Ditto.
	* generated/maxloc1_16_r4.c: Ditto.
	* generated/maxloc1_16_r8.c: Ditto.
	* generated/maxloc1_16_s1.c: Ditto.
	* generated/maxloc1_16_s4.c: Ditto.
	* generated/maxloc1_4_i1.c: Ditto.
	* generated/maxloc1_4_i16.c: Ditto.
	* generated/maxloc1_4_i2.c: Ditto.
	* generated/maxloc1_4_i4.c: Ditto.
	* generated/maxloc1_4_i8.c: Ditto.
	* generated/maxloc1_4_r10.c: Ditto.
	* generated/maxloc1_4_r16.c: Ditto.
	* generated/maxloc1_4_r4.c: Ditto.
	* generated/maxloc1_4_r8.c: Ditto.
	* generated/maxloc1_4_s1.c: Ditto.
	* generated/maxloc1_4_s4.c: Ditto.
	* generated/maxloc1_8_i1.c: Ditto.
	* generated/maxloc1_8_i16.c: Ditto.
	* generated/maxloc1_8_i2.c: Ditto.
	* generated/maxloc1_8_i4.c: Ditto.
	* generated/maxloc1_8_i8.c: Ditto.
	* generated/maxloc1_8_r10.c: Ditto.
	* generated/maxloc1_8_r16.c: Ditto.
	* generated/maxloc1_8_r4.c: Ditto.
	* generated/maxloc1_8_r8.c: Ditto.
	* generated/maxloc1_8_s1.c: Ditto.
	* generated/maxloc1_8_s4.c: Ditto.
	* generated/maxval1_s1.c: Ditto.
	* generated/maxval1_s4.c: Ditto.
	* generated/maxval_i1.c: Ditto.
	* generated/maxval_i16.c: Ditto.
	* generated/maxval_i2.c: Ditto.
	* generated/maxval_i4.c: Ditto.
	* generated/maxval_i8.c: Ditto.
	* generated/maxval_r10.c: Ditto.
	* generated/maxval_r16.c: Ditto.
	* generated/maxval_r4.c: Ditto.
	* generated/maxval_r8.c: Ditto.
	* generated/minloc0_16_i1.c: Ditto.
	* generated/minloc0_16_i16.c: Ditto.
	* generated/minloc0_16_i2.c: Ditto.
	* generated/minloc0_16_i4.c: Ditto.
	* generated/minloc0_16_i8.c: Ditto.
	* generated/minloc0_16_r10.c: Ditto.
	* generated/minloc0_16_r16.c: Ditto.
	* generated/minloc0_16_r4.c: Ditto.
	* generated/minloc0_16_r8.c: Ditto.
	* generated/minloc0_16_s1.c: Ditto.
	* generated/minloc0_16_s4.c: Ditto.
	* generated/minloc0_4_i1.c: Ditto.
	* generated/minloc0_4_i16.c: Ditto.
	* generated/minloc0_4_i2.c: Ditto.
	* generated/minloc0_4_i4.c: Ditto.
	* generated/minloc0_4_i8.c: Ditto.
	* generated/minloc0_4_r10.c: Ditto.
	* generated/minloc0_4_r16.c: Ditto.
	* generated/minloc0_4_r4.c: Ditto.
	* generated/minloc0_4_r8.c: Ditto.
	* generated/minloc0_4_s1.c: Ditto.
	* generated/minloc0_4_s4.c: Ditto.
	* generated/minloc0_8_i1.c: Ditto.
	* generated/minloc0_8_i16.c: Ditto.
	* generated/minloc0_8_i2.c: Ditto.
	* generated/minloc0_8_i4.c: Ditto.
	* generated/minloc0_8_i8.c: Ditto.
	* generated/minloc0_8_r10.c: Ditto.
	* generated/minloc0_8_r16.c: Ditto.
	* generated/minloc0_8_r4.c: Ditto.
	* generated/minloc0_8_r8.c: Ditto.
	* generated/minloc0_8_s1.c: Ditto.
	* generated/minloc0_8_s4.c: Ditto.
	* generated/minloc1_16_i1.c: Ditto.
	* generated/minloc1_16_i16.c: Ditto.
	* generated/minloc1_16_i2.c: Ditto.
	* generated/minloc1_16_i4.c: Ditto.
	* generated/minloc1_16_i8.c: Ditto.
	* generated/minloc1_16_r10.c: Ditto.
	* generated/minloc1_16_r16.c: Ditto.
	* generated/minloc1_16_r4.c: Ditto.
	* generated/minloc1_16_r8.c: Ditto.
	* generated/minloc1_16_s1.c: Ditto.
	* generated/minloc1_16_s4.c: Ditto.
	* generated/minloc1_4_i1.c: Ditto.
	* generated/minloc1_4_i16.c: Ditto.
	* generated/minloc1_4_i2.c: Ditto.
	* generated/minloc1_4_i4.c: Ditto.
	* generated/minloc1_4_i8.c: Ditto.
	* generated/minloc1_4_r10.c: Ditto.
	* generated/minloc1_4_r16.c: Ditto.
	* generated/minloc1_4_r4.c: Ditto.
	* generated/minloc1_4_r8.c: Ditto.
	* generated/minloc1_4_s1.c: Ditto.
	* generated/minloc1_4_s4.c: Ditto.
	* generated/minloc1_8_i1.c: Ditto.
	* generated/minloc1_8_i16.c: Ditto.
	* generated/minloc1_8_i2.c: Ditto.
	* generated/minloc1_8_i4.c: Ditto.
	* generated/minloc1_8_i8.c: Ditto.
	* generated/minloc1_8_r10.c: Ditto.
	* generated/minloc1_8_r16.c: Ditto.
	* generated/minloc1_8_r4.c: Ditto.
	* generated/minloc1_8_r8.c: Ditto.
	* generated/minloc1_8_s1.c: Ditto.
	* generated/minloc1_8_s4.c: Ditto.
	* generated/minval1_s1.c: Ditto.
	* generated/minval1_s4.c: Ditto.
	* generated/minval_i1.c: Ditto.
	* generated/minval_i16.c: Ditto.
	* generated/minval_i2.c: Ditto.
	* generated/minval_i4.c: Ditto.
	* generated/minval_i8.c: Ditto.
	* generated/minval_r10.c: Ditto.
	* generated/minval_r16.c: Ditto.
	* generated/minval_r4.c: Ditto.
	* generated/minval_r8.c: Ditto.
	* generated/norm2_r10.c: Ditto.
	* generated/norm2_r16.c: Ditto.
	* generated/norm2_r4.c: Ditto.
	* generated/norm2_r8.c: Ditto.
	* generated/parity_l1.c: Ditto.
	* generated/parity_l16.c: Ditto.
	* generated/parity_l2.c: Ditto.
	* generated/parity_l4.c: Ditto.
	* generated/parity_l8.c: Ditto.
	* generated/product_c10.c: Ditto.
	* generated/product_c16.c: Ditto.
	* generated/product_c4.c: Ditto.
	* generated/product_c8.c: Ditto.
	* generated/product_i1.c: Ditto.
	* generated/product_i16.c: Ditto.
	* generated/product_i2.c: Ditto.
	* generated/product_i4.c: Ditto.
	* generated/product_i8.c: Ditto.
	* generated/product_r10.c: Ditto.
	* generated/product_r16.c: Ditto.
	* generated/product_r4.c: Ditto.
	* generated/product_r8.c: Ditto.
	* generated/reshape_c10.c: Ditto.
	* generated/reshape_c16.c: Ditto.
	* generated/reshape_c4.c: Ditto.
	* generated/reshape_c8.c: Ditto.
	* generated/reshape_i16.c: Ditto.
	* generated/reshape_i4.c: Ditto.
	* generated/reshape_i8.c: Ditto.
	* generated/reshape_r10.c: Ditto.
	* generated/reshape_r16.c: Ditto.
	* generated/reshape_r4.c: Ditto.
	* generated/reshape_r8.c: Ditto.
	* generated/spread_c10.c: Ditto.
	* generated/spread_c16.c: Ditto.
	* generated/spread_c4.c: Ditto.
	* generated/spread_c8.c: Ditto.
	* generated/spread_i1.c: Ditto.
	* generated/spread_i16.c: Ditto.
	* generated/spread_i2.c: Ditto.
	* generated/spread_i4.c: Ditto.
	* generated/spread_i8.c: Ditto.
	* generated/spread_r10.c: Ditto.
	* generated/spread_r16.c: Ditto.
	* generated/spread_r4.c: Ditto.
	* generated/spread_r8.c: Ditto.
	* generated/sum_c10.c: Ditto.
	* generated/sum_c16.c: Ditto.
	* generated/sum_c4.c: Ditto.
	* generated/sum_c8.c: Ditto.
	* generated/sum_i1.c: Ditto.
	* generated/sum_i16.c: Ditto.
	* generated/sum_i2.c: Ditto.
	* generated/sum_i4.c: Ditto.
	* generated/sum_i8.c: Ditto.
	* generated/sum_r10.c: Ditto.
	* generated/sum_r16.c: Ditto.
	* generated/sum_r4.c: Ditto.
	* generated/sum_r8.c: Ditto.

2018-06-01  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/85816
	PR fortran/85975
	* gfortran.dg/pr85816.f90: New test.
	* gfortran.dg/pr85975.f90: New test.

From-SVN: r261081
2018-06-01 20:20:35 +00:00
Janne Blomqvist
dffb1e2279 PR 84519 Handle optional QUIET specifier for STOP and ERROR STOP
Fortran 2018 adds a new QUIET specifier for the STOP and ERROR STOP
statements, in order to suppress the printing of signaling FP
exceptions and the stop code. This patch adds the necessary library
changes, but for now the new specifier is not parsed and the frontend
unconditionally adds a false value for the new argument.

Regtested on x86_64-pc-linux-gnu.

gcc/fortran/ChangeLog:

2018-02-23  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/84519
	* trans-decl.c (gfc_build_builtin_function_decls): Add bool
	argument to stop and error stop decls.
	* trans-stmt.c (gfc_trans_stop): Add false value to argument
	lists.

libgfortran/ChangeLog:

2018-02-23  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/84519
	* caf/libcaf.h (_gfortran_caf_stop_numeric): Add bool argument.
	(_gfortran_caf_stop_str): Likewise.
	(_gfortran_caf_error_stop_str): Likewise.
	(_gfortran_caf_error_stop): Likewise.
	* caf/mpi.c (_gfortran_caf_error_stop_str): Handle new argument.
	(_gfortran_caf_error_stop): Likewise.
	* caf/single.c (_gfortran_caf_stop_numeric): Likewise.
	(_gfortran_caf_stop_str): Likewise.
	(_gfortran_caf_error_stop_str): Likewise.
	(_gfortran_caf_error_stop): Likewise.
	(_gfortran_caf_lock): Likewise.
	(_gfortran_caf_unlock): Likewise.
	* libgfortran.h (stop_string): Add bool argument.
	* runtime/pause.c (do_pause): Add false argument.
	* runtime/stop.c (stop_numeric): Handle new argument.
	(stop_string): Likewise.
	(error_stop_string): Likewise.
	(error_stop_numeric): Likewise.

From-SVN: r257928
2018-02-23 11:07:24 +02:00
Janne Blomqvist
3f5fabc0ea Character length cleanup for Coarray Fortran library
Following the change to use size_t for Fortran character lengths (PR
78534), this patch modifies the Coarray ABI in a similar way. The
single-image implementation that is included in libgfortran is
updated, but this needs corresponding work in the OpenCoarray library
as well for multi-image support. I also fixed the types for the STOP
and ERROR STOP implementation in libgfortran, as the calling of them
is somewhat intertwined with the calling of the corresponding CAF
functions. I'll send the OpenCoarray changes as a separate pull
request to the OpenCoarrays repository.

Regtested on x86_64-pc-linux-gnu.

gcc/fortran/ChangeLog:

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

	* gfortran.texi: Update Coarray API description.
	* trans-decl.c (gfc_build_builtin_function_decls): Use size_t for
	character lengths, int for exit codes.
	(generate_coarray_sym_init): Use size_t for character length.
	* trans-intrinsic.c (conv_co_collective): Likewise.
	* trans-stmt.c (gfc_trans_lock_unlock): Likewise.
	(gfc_trans_event_post_wait): Likewise.
	(gfc_trans_sync): Likewise.
	(gfc_trans_stop): Use size_t for character lengths, int for exit
	codes.

libgfortran/ChangeLog:

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

	* libgfortran.h (stop_string): Use size_t for character length.
	* runtime/stop.c (stop_string): Likewise.
	(error_stop_string): Likewise.
	(stop_numeric): Use int for exit code.
	(error_stop_numeric): Likewise.
	* caf/libcaf.h: Remove stdint.h include.
	(_gfortran_caf_register): Use size_t for character length.
	(_gfortran_caf_deregister): Likewise.
	(_gfortran_caf_sync_all): Likewise.
	(_gfortran_caf_sync_memory): Likewise.
	(_gfortran_caf_sync_images): Likewise.
	(_gfortran_caf_stop_numeric): Use int for exit code.
	(_gfortran_caf_stop_str): Use size_t for character length.
	(_gfortran_caf_error_stop_str): Likewise.
	(_gfortran_caf_error_stop): Use int for exit code.
	(_gfortran_caf_co_broadcast): Use size_t for character length.
	(_gfortran_caf_co_sum): Likewise.
	(_gfortran_caf_co_min): Likewise.
	(_gfortran_caf_co_max): Likewise.
	(_gfortran_caf_co_reduce): Likewise.
	(_gfortran_caf_lock): Likewise.
	(_gfortran_caf_unlock): Likewise.
	(_gfortran_caf_event_post): Likewise.
	(_gfortran_caf_event_wait): Likewise.
	* caf/mpi.c (_gfortran_caf_register): Update implementation to
	match prototype.
	(_gfortran_caf_deregister): Likewise.
	(_gfortran_caf_sync_all): Likewise.
	(_gfortran_caf_sync_images): Likewise.
	(_gfortran_caf_error_stop_str): Likewise.
	(_gfortran_caf_error_stop): Likewise.
	* caf/single.c (caf_internal_error): Likewise.
	(_gfortran_caf_register): Likewise.
	(_gfortran_caf_deregister): Likewise.
	(_gfortran_caf_sync_all): Likewise.
	(_gfortran_caf_sync_memory): Likewise.
	(_gfortran_caf_sync_images): Likewise.
	(_gfortran_caf_stop_numeric): Likewise.
	(_gfortran_caf_stop_str): Likewise.
	(_gfortran_caf_error_stop_str): Likewise.
	(_gfortran_caf_error_stop): Likewise.
	(_gfortran_caf_co_broadcast): Likewise.
	(_gfortran_caf_co_sum): Likewise.
	(_gfortran_caf_co_min): Likewise.
	(_gfortran_caf_co_max): Likewise.
	(_gfortran_caf_co_reduce): Likewise.
	(_gfortran_caf_event_post): Likewise.
	(_gfortran_caf_event_wait): Likewise.
	(_gfortran_caf_lock): Likewise.
	(_gfortran_caf_unlock): Likewise.

From-SVN: r257894
2018-02-22 11:44:31 +02: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
Thomas Koenig
b6019ab18c re PR fortran/37577 ([meta-bug] change internal array descriptor format for better syntax, C interop TR, rank 15)
2018-01-30  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/37577
	* libgfortran.h: Remove GFC_DTYPE_DERIVED_1, GFC_DTYPE_DERIVED_2,
	GFC_DTYPE_DERIVED_4, GFC_DTYPE_DERIVED_8 and GFC_DTYPE_DERIVED_16.
	* m4/cshift1.m4: Remove GFC_DTYPE_DERIVED_1.
	* generated/cshift1_16.c: Regenerated.
	* generated/cshift1_4.c: Regenerated.
	* generated/cshift1_8.c: Regenerated.
	* intrinsics/cshift0.c: Remove GFC_DTYPE_DERIVED_1.
	* intrinsics/pack_generic.c (pack): Move handling of other types
	into separate switch statement.
	* intrinsics/spread_generic.c (spread): Likewise.
	(spread_scalar): Likewise.
	* intrinsics/unpack_generic.c (unpack1): Likewise.
	(unpack0): Likewise.
	* runtime/in_pack_generic.c (internal_pack): Likewise.
	* runtime/in_unpack_generic.c (internal_unpack): Likewise.

From-SVN: r257195
2018-01-30 18:20:27 +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
Thomas Koenig
fa3c4d47b9 libgfortran.h (GFC_DTYPE_COPY): New macro.
2018-01-07  Thomas Koenig  <tkoenig@gcc.gnu.org>

	* libgfortran.h (GFC_DTYPE_COPY): New macro.
	(GFC_DTYPE_COPY_SETRANK): New macro.
	(GFC_DTYPE_IS_UNSET): New macro.
	* intrinsics/cshift0.c (cshift0): Use new macros.
	* intrinsics/eoshift0.c (eoshift0): Likewise.
	* intrinsics/eoshift2.c (eoshift2): Likewise.
	* intrinsics/move_alloc.c (move_alloc): Likewise.
	* intrinsics/reshape_generic.c (reshape_internal): Likewise.
	* intrinsics/spread_generic.c (spread_internal): Likewise.
	* intrinsics/spread_generic.c (spread_scalar): Likewise.
	* intrinsics/spread_generic.c (spread_char_scalar): Likewise.
	* intrinsics/spread_generic.c (spread_char4_scalar): Likewise.
	* intrinsics/unpack_generic.c (unpack0): Likewise.
	* intrinsics/unpack_generic.c (unpack0_char): Likewise.
	* intrinsics/unpack_generic.c (unpack0_char4): Likewise.
	* m4/cshift1.m4 (cshift1): Likewise.
	* m4/eoshift1.m4 (eoshift1): Likewise.
	* m4/eoshift3.m4 (eoshift3): Likewise.
	* m4/iforeach-s.m4: Likewise.
	* m4/iforeach.m4: Likewise.
	* m4/ifunction-s.m4: Likewise.
	* m4/ifunction-s2.m4: Likewise.
	* m4/ifunction.m4: Likewise.
	* m4/ifunction_logical.m4: Likewise.
	* m4/reshape.m4: Likewise.
	* m4/spread.m4: Likewise.
	* generated/all_l1.c : Regenerated.
	* generated/all_l16.c : Regenerated.
	* generated/all_l2.c : Regenerated.
	* generated/all_l4.c : Regenerated.
	* generated/all_l8.c : Regenerated.
	* generated/any_l1.c : Regenerated.
	* generated/any_l16.c : Regenerated.
	* generated/any_l2.c : Regenerated.
	* generated/any_l4.c : Regenerated.
	* generated/any_l8.c : Regenerated.
	* generated/count_16_l.c : Regenerated.
	* generated/count_1_l.c : Regenerated.
	* generated/count_2_l.c : Regenerated.
	* generated/count_4_l.c : Regenerated.
	* generated/count_8_l.c : Regenerated.
	* generated/cshift1_16.c : Regenerated.
	* generated/cshift1_4.c : Regenerated.
	* generated/cshift1_8.c : Regenerated.
	* generated/eoshift1_16.c : Regenerated.
	* generated/eoshift1_4.c : Regenerated.
	* generated/eoshift1_8.c : Regenerated.
	* generated/eoshift3_16.c : Regenerated.
	* generated/eoshift3_4.c : Regenerated.
	* generated/eoshift3_8.c : Regenerated.
	* generated/iall_i1.c : Regenerated.
	* generated/iall_i16.c : Regenerated.
	* generated/iall_i2.c : Regenerated.
	* generated/iall_i4.c : Regenerated.
	* generated/iall_i8.c : Regenerated.
	* generated/iany_i1.c : Regenerated.
	* generated/iany_i16.c : Regenerated.
	* generated/iany_i2.c : Regenerated.
	* generated/iany_i4.c : Regenerated.
	* generated/iany_i8.c : Regenerated.
	* generated/iparity_i1.c : Regenerated.
	* generated/iparity_i16.c : Regenerated.
	* generated/iparity_i2.c : Regenerated.
	* generated/iparity_i4.c : Regenerated.
	* generated/iparity_i8.c : Regenerated.
	* generated/maxloc0_16_i1.c : Regenerated.
	* generated/maxloc0_16_i16.c : Regenerated.
	* generated/maxloc0_16_i2.c : Regenerated.
	* generated/maxloc0_16_i4.c : Regenerated.
	* generated/maxloc0_16_i8.c : Regenerated.
	* generated/maxloc0_16_r10.c : Regenerated.
	* generated/maxloc0_16_r16.c : Regenerated.
	* generated/maxloc0_16_r4.c : Regenerated.
	* generated/maxloc0_16_r8.c : Regenerated.
	* generated/maxloc0_16_s1.c : Regenerated.
	* generated/maxloc0_16_s4.c : Regenerated.
	* generated/maxloc0_4_i1.c : Regenerated.
	* generated/maxloc0_4_i16.c : Regenerated.
	* generated/maxloc0_4_i2.c : Regenerated.
	* generated/maxloc0_4_i4.c : Regenerated.
	* generated/maxloc0_4_i8.c : Regenerated.
	* generated/maxloc0_4_r10.c : Regenerated.
	* generated/maxloc0_4_r16.c : Regenerated.
	* generated/maxloc0_4_r4.c : Regenerated.
	* generated/maxloc0_4_r8.c : Regenerated.
	* generated/maxloc0_4_s1.c : Regenerated.
	* generated/maxloc0_4_s4.c : Regenerated.
	* generated/maxloc0_8_i1.c : Regenerated.
	* generated/maxloc0_8_i16.c : Regenerated.
	* generated/maxloc0_8_i2.c : Regenerated.
	* generated/maxloc0_8_i4.c : Regenerated.
	* generated/maxloc0_8_i8.c : Regenerated.
	* generated/maxloc0_8_r10.c : Regenerated.
	* generated/maxloc0_8_r16.c : Regenerated.
	* generated/maxloc0_8_r4.c : Regenerated.
	* generated/maxloc0_8_r8.c : Regenerated.
	* generated/maxloc0_8_s1.c : Regenerated.
	* generated/maxloc0_8_s4.c : Regenerated.
	* generated/maxloc1_16_i1.c : Regenerated.
	* generated/maxloc1_16_i16.c : Regenerated.
	* generated/maxloc1_16_i2.c : Regenerated.
	* generated/maxloc1_16_i4.c : Regenerated.
	* generated/maxloc1_16_i8.c : Regenerated.
	* generated/maxloc1_16_r10.c : Regenerated.
	* generated/maxloc1_16_r16.c : Regenerated.
	* generated/maxloc1_16_r4.c : Regenerated.
	* generated/maxloc1_16_r8.c : Regenerated.
	* generated/maxloc1_16_s1.c : Regenerated.
	* generated/maxloc1_16_s4.c : Regenerated.
	* generated/maxloc1_4_i1.c : Regenerated.
	* generated/maxloc1_4_i16.c : Regenerated.
	* generated/maxloc1_4_i2.c : Regenerated.
	* generated/maxloc1_4_i4.c : Regenerated.
	* generated/maxloc1_4_i8.c : Regenerated.
	* generated/maxloc1_4_r10.c : Regenerated.
	* generated/maxloc1_4_r16.c : Regenerated.
	* generated/maxloc1_4_r4.c : Regenerated.
	* generated/maxloc1_4_r8.c : Regenerated.
	* generated/maxloc1_4_s1.c : Regenerated.
	* generated/maxloc1_4_s4.c : Regenerated.
	* generated/maxloc1_8_i1.c : Regenerated.
	* generated/maxloc1_8_i16.c : Regenerated.
	* generated/maxloc1_8_i2.c : Regenerated.
	* generated/maxloc1_8_i4.c : Regenerated.
	* generated/maxloc1_8_i8.c : Regenerated.
	* generated/maxloc1_8_r10.c : Regenerated.
	* generated/maxloc1_8_r16.c : Regenerated.
	* generated/maxloc1_8_r4.c : Regenerated.
	* generated/maxloc1_8_r8.c : Regenerated.
	* generated/maxloc1_8_s1.c : Regenerated.
	* generated/maxloc1_8_s4.c : Regenerated.
	* generated/maxval1_s1.c : Regenerated.
	* generated/maxval1_s4.c : Regenerated.
	* generated/maxval_i1.c : Regenerated.
	* generated/maxval_i16.c : Regenerated.
	* generated/maxval_i2.c : Regenerated.
	* generated/maxval_i4.c : Regenerated.
	* generated/maxval_i8.c : Regenerated.
	* generated/maxval_r10.c : Regenerated.
	* generated/maxval_r16.c : Regenerated.
	* generated/maxval_r4.c : Regenerated.
	* generated/maxval_r8.c : Regenerated.
	* generated/minloc0_16_i1.c : Regenerated.
	* generated/minloc0_16_i16.c : Regenerated.
	* generated/minloc0_16_i2.c : Regenerated.
	* generated/minloc0_16_i4.c : Regenerated.
	* generated/minloc0_16_i8.c : Regenerated.
	* generated/minloc0_16_r10.c : Regenerated.
	* generated/minloc0_16_r16.c : Regenerated.
	* generated/minloc0_16_r4.c : Regenerated.
	* generated/minloc0_16_r8.c : Regenerated.
	* generated/minloc0_16_s1.c : Regenerated.
	* generated/minloc0_16_s4.c : Regenerated.
	* generated/minloc0_4_i1.c : Regenerated.
	* generated/minloc0_4_i16.c : Regenerated.
	* generated/minloc0_4_i2.c : Regenerated.
	* generated/minloc0_4_i4.c : Regenerated.
	* generated/minloc0_4_i8.c : Regenerated.
	* generated/minloc0_4_r10.c : Regenerated.
	* generated/minloc0_4_r16.c : Regenerated.
	* generated/minloc0_4_r4.c : Regenerated.
	* generated/minloc0_4_r8.c : Regenerated.
	* generated/minloc0_4_s1.c : Regenerated.
	* generated/minloc0_4_s4.c : Regenerated.
	* generated/minloc0_8_i1.c : Regenerated.
	* generated/minloc0_8_i16.c : Regenerated.
	* generated/minloc0_8_i2.c : Regenerated.
	* generated/minloc0_8_i4.c : Regenerated.
	* generated/minloc0_8_i8.c : Regenerated.
	* generated/minloc0_8_r10.c : Regenerated.
	* generated/minloc0_8_r16.c : Regenerated.
	* generated/minloc0_8_r4.c : Regenerated.
	* generated/minloc0_8_r8.c : Regenerated.
	* generated/minloc0_8_s1.c : Regenerated.
	* generated/minloc0_8_s4.c : Regenerated.
	* generated/minloc1_16_i1.c : Regenerated.
	* generated/minloc1_16_i16.c : Regenerated.
	* generated/minloc1_16_i2.c : Regenerated.
	* generated/minloc1_16_i4.c : Regenerated.
	* generated/minloc1_16_i8.c : Regenerated.
	* generated/minloc1_16_r10.c : Regenerated.
	* generated/minloc1_16_r16.c : Regenerated.
	* generated/minloc1_16_r4.c : Regenerated.
	* generated/minloc1_16_r8.c : Regenerated.
	* generated/minloc1_16_s1.c : Regenerated.
	* generated/minloc1_16_s4.c : Regenerated.
	* generated/minloc1_4_i1.c : Regenerated.
	* generated/minloc1_4_i16.c : Regenerated.
	* generated/minloc1_4_i2.c : Regenerated.
	* generated/minloc1_4_i4.c : Regenerated.
	* generated/minloc1_4_i8.c : Regenerated.
	* generated/minloc1_4_r10.c : Regenerated.
	* generated/minloc1_4_r16.c : Regenerated.
	* generated/minloc1_4_r4.c : Regenerated.
	* generated/minloc1_4_r8.c : Regenerated.
	* generated/minloc1_4_s1.c : Regenerated.
	* generated/minloc1_4_s4.c : Regenerated.
	* generated/minloc1_8_i1.c : Regenerated.
	* generated/minloc1_8_i16.c : Regenerated.
	* generated/minloc1_8_i2.c : Regenerated.
	* generated/minloc1_8_i4.c : Regenerated.
	* generated/minloc1_8_i8.c : Regenerated.
	* generated/minloc1_8_r10.c : Regenerated.
	* generated/minloc1_8_r16.c : Regenerated.
	* generated/minloc1_8_r4.c : Regenerated.
	* generated/minloc1_8_r8.c : Regenerated.
	* generated/minloc1_8_s1.c : Regenerated.
	* generated/minloc1_8_s4.c : Regenerated.
	* generated/minval1_s1.c : Regenerated.
	* generated/minval1_s4.c : Regenerated.
	* generated/minval_i1.c : Regenerated.
	* generated/minval_i16.c : Regenerated.
	* generated/minval_i2.c : Regenerated.
	* generated/minval_i4.c : Regenerated.
	* generated/minval_i8.c : Regenerated.
	* generated/minval_r10.c : Regenerated.
	* generated/minval_r16.c : Regenerated.
	* generated/minval_r4.c : Regenerated.
	* generated/minval_r8.c : Regenerated.
	* generated/norm2_r10.c : Regenerated.
	* generated/norm2_r16.c : Regenerated.
	* generated/norm2_r4.c : Regenerated.
	* generated/norm2_r8.c : Regenerated.
	* generated/parity_l1.c : Regenerated.
	* generated/parity_l16.c : Regenerated.
	* generated/parity_l2.c : Regenerated.
	* generated/parity_l4.c : Regenerated.
	* generated/parity_l8.c : Regenerated.
	* generated/product_c10.c : Regenerated.
	* generated/product_c16.c : Regenerated.
	* generated/product_c4.c : Regenerated.
	* generated/product_c8.c : Regenerated.
	* generated/product_i1.c : Regenerated.
	* generated/product_i16.c : Regenerated.
	* generated/product_i2.c : Regenerated.
	* generated/product_i4.c : Regenerated.
	* generated/product_i8.c : Regenerated.
	* generated/product_r10.c : Regenerated.
	* generated/product_r16.c : Regenerated.
	* generated/product_r4.c : Regenerated.
	* generated/product_r8.c : Regenerated.
	* 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.
	* generated/spread_c10.c : Regenerated.
	* generated/spread_c16.c : Regenerated.
	* generated/spread_c4.c : Regenerated.
	* generated/spread_c8.c : Regenerated.
	* generated/spread_i1.c : Regenerated.
	* generated/spread_i16.c : Regenerated.
	* generated/spread_i2.c : Regenerated.
	* generated/spread_i4.c : Regenerated.
	* generated/spread_i8.c : Regenerated.
	* generated/spread_r10.c : Regenerated.
	* generated/spread_r16.c : Regenerated.
	* generated/spread_r4.c : Regenerated.
	* generated/spread_r8.c : Regenerated.
	* generated/sum_c10.c : Regenerated.
	* generated/sum_c16.c : Regenerated.
	* generated/sum_c4.c : Regenerated.
	* generated/sum_c8.c : Regenerated.
	* generated/sum_i1.c : Regenerated.
	* generated/sum_i16.c : Regenerated.
	* generated/sum_i2.c : Regenerated.
	* generated/sum_i4.c : Regenerated.
	* generated/sum_i8.c : Regenerated.
	* generated/sum_r10.c : Regenerated.
	* generated/sum_r16.c : Regenerated.
	* generated/sum_r4.c : Regenerated.
	* generated/sum_r8.c : Regenerated.

From-SVN: r256323
2018-01-07 14:11:11 +00:00
Janne Blomqvist
f622221ab4 PR 78534 Change character length from int to size_t
In order to handle large character lengths on (L)LP64 targets, switch
the GFortran character length from an int to a size_t.

This is an ABI change, as procedures with character arguments take
hidden arguments with the character length.

I also changed the _size member in vtables from int to size_t, as
there were some cases where character lengths and sizes were
apparently mixed up and caused regressions otherwise. Although I
haven't tested, this might enable very large derived types as well.

Also, as there are some places in the frontend were negative character
lengths are used as special flag values, in the frontend the character
length is handled as a signed variable of the same size as a size_t,
although in the runtime library it really is size_t.

I haven't changed the character length variables for the co-array
intrinsics, as this is something that may need to be synchronized with
OpenCoarrays.

This is v5 of the patch. v4 was applied but caused breakage on big
endian targets. These have been fixed and tested, thanks to access to
the GCC compile farm.

Overview of v4 of the patch: v3 was applied but had to reverted due to
breaking bootstrap. The fix is in resolve.c:resolve_charlen, where
it's necessary to check that an expression is constant before using
mpz_sgn.

Overview of v3 of the patch: All the issues pointed out by FX's review
of v2 have been fixed. In particular, there are now new functions
gfc_mpz_get_hwi and gfc_mpz_set_hwi, similar to the GMP functions
mpz_get_si and mpz_set_si, except that they get/set a HOST_WIDE_INT
instead of a long value. Similarly, gfc_get_int_expr now takes a
HOST_WIDE_INT instead of a long, gfc_extract_long is replaced by
gfc_extract_hwi. Also, the preliminary work to handle
gfc_charlen_type_node being unsigned has been removed.

Regtested on x86_64-pc-linux-gnu, i686-pc-linux-gnu and
powerpc64-unknown-linux-gnu. Also regtested all three targets by
modifying gfortran-dg.exp to also test with "-g -flto", no new
failures observed.

frontend:

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

	PR fortran/78534
	PR fortran/66310
	* array.c (got_charlen): Use gfc_charlen_int_kind.
	* class.c (gfc_find_derived_vtab): Use gfc_size_kind instead of
	hardcoded kind.
	(find_intrinsic_vtab): Likewise.
	* decl.c (match_char_length): Use gfc_charlen_int_kind.
	(add_init_expr_to_sym): Use gfc_charlen_t and gfc_charlen_int_kind.
	(gfc_match_implicit): Use gfc_charlen_int_kind.
	* dump-parse-tree.c (show_char_const): Use gfc_charlen_t and size_t.
	(show_expr): Use HOST_WIDE_INT_PRINT_DEC.
	* expr.c (gfc_get_character_expr): Length parameter of type
	gfc_charlen_t.
	(gfc_get_int_expr): Value argument of type HOST_WIDE_INT.
	(gfc_extract_hwi): New function.
	(simplify_const_ref): Make string_len of type gfc_charlen_t.
	(gfc_simplify_expr): Use HOST_WIDE_INT for substring refs.
	* frontend-passes.c (optimize_trim): Use gfc_charlen_int_kind.
	* gfortran.h (gfc_mpz_get_hwi): New prototype.
	(gfc_mpz_set_hwi): Likewise.
	(gfc_charlen_t): New typedef.
	(gfc_expr): Use gfc_charlen_t for character lengths.
	(gfc_size_kind): New extern variable.
	(gfc_extract_hwi): New prototype.
	(gfc_get_character_expr): Use gfc_charlen_t for character length.
	(gfc_get_int_expr): Use HOST_WIDE_INT type for value argument.
	* gfortran.texi: Update description of hidden string length argument.
	* iresolve.c (check_charlen_present): Use gfc_charlen_int_kind.
	(gfc_resolve_char_achar): Likewise.
	(gfc_resolve_repeat): Pass string length directly without
	temporary, use gfc_charlen_int_kind.
	(gfc_resolve_transfer): Use gfc_charlen_int_kind.
	* match.c (select_intrinsic_set_tmp): Use HOST_WIDE_INT for charlen.
	* misc.c (gfc_mpz_get_hwi): New function.
	(gfc_mpz_set_hwi): New function.
	* module.c (atom_int): Change type from int to HOST_WIDE_INT.
	(parse_integer): Don't complain about large integers.
	(write_atom): Use HOST_WIDE_INT for integers.
	(mio_integer): Handle integer type mismatch.
	(mio_hwi): New function.
	(mio_intrinsic_op): Use HOST_WIDE_INT.
	(mio_array_ref): Likewise.
	(mio_expr): Likewise.
	* primary.c (match_substring): Use gfc_charlen_int_kind.
	* resolve.c (resolve_substring_charlen): Use gfc_charlen_int_kind.
	(resolve_character_operator): Likewise.
	(resolve_assoc_var): Likewise.
	(resolve_select_type): Use HOST_WIDE_INT for charlen, use snprintf.
	(resolve_charlen): Use mpz_sgn to determine sign.
	* simplify.c (gfc_simplify_repeat): Use HOST_WIDE_INT/gfc_charlen_t
	instead of long.
	* symbol.c (generate_isocbinding_symbol): Use gfc_charlen_int_kind.
	* target-memory.c (size_character): Length argument of type
	gfc_charlen_t.
	(gfc_encode_character): Likewise.
	(gfc_interpret_character): Use gfc_charlen_t.
	* target-memory.h (gfc_encode_character): Modify prototype.
	* trans-array.c (gfc_trans_array_ctor_element): Use existing type.
	(get_array_ctor_var_strlen): Use gfc_conv_mpz_to_tree_type.
	(trans_array_constructor): Use existing type.
	(get_array_charlen): Likewise.
	* trans-const.c (gfc_conv_mpz_to_tree_type): New function.
	* trans-const.h (gfc_conv_mpz_to_tree_type): New prototype.
	* trans-decl.c (gfc_trans_deferred_vars): Use existing type.
	(add_argument_checking): Likewise.
	* trans-expr.c (gfc_class_len_or_zero_get): Build const of type
	gfc_charlen_type_node.
	(gfc_conv_intrinsic_to_class): Use gfc_charlen_int_kind instead of
	4, fold_convert to correct type.
	(gfc_conv_class_to_class): Build const of type size_type_node for
	size.
	(gfc_copy_class_to_class): Likewise.
	(gfc_conv_string_length): Use same type in expression.
	(gfc_conv_substring): Likewise, use HOST_WIDE_INT for charlen.
	(gfc_conv_string_tmp): Make sure len is of the right type.
	(gfc_conv_concat_op): Use same type in expression.
	(gfc_conv_procedure_call): Likewise.
	(fill_with_spaces): Comment out memset() block due to spurious
	-Wstringop-overflow warnings.
	(gfc_trans_string_copy): Use gfc_charlen_type_node.
	(alloc_scalar_allocatable_for_subcomponent_assignment):
	fold_convert to right type.
	(gfc_trans_subcomponent_assign): Likewise.
	(trans_class_vptr_len_assignment): Build const of correct type.
	(gfc_trans_pointer_assignment): Likewise.
	(alloc_scalar_allocatable_for_assignment): fold_convert to right
	type in expr.
	(trans_class_assignment): Build const of correct type.
	* trans-intrinsic.c (gfc_conv_associated): Likewise.
	(gfc_conv_intrinsic_repeat): Do calculation in sizetype.
	* trans-io.c (gfc_build_io_library_fndecls): Use
	gfc_charlen_type_node for character lengths.
	(set_string): Convert to right type in assignment.
	* trans-stmt.c (gfc_trans_label_assign): Build const of
	gfc_charlen_type_node.
	(trans_associate_var): Likewise.
	(gfc_trans_character_select): Likewise.
	(gfc_trans_allocate): Likewise, don't typecast strlen result.
	(gfc_trans_deallocate): Don't typecast strlen result.
	* trans-types.c (gfc_size_kind): New variable.
	(gfc_init_types): Determine gfc_charlen_int_kind and gfc_size_kind
	from size_type_node.
	* trans-types.h: Fix comment.

testsuite:

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

	PR fortran/78534
	PR fortran/66310
	* gfortran.dg/char_cast_1.f90: Update scan pattern.
	* gfortran.dg/dependency_49.f90: Likewise.
	* gfortran.dg/repeat_4.f90: Use integers of kind C_SIZE_T.
	* gfortran.dg/repeat_7.f90: New test for PR 66310.
	* gfortran.dg/scan_2.f90: Handle potential cast in assignment.
	* gfortran.dg/string_1.f90: Limit to ilp32 targets.
	* gfortran.dg/string_1_lp64.f90: New test.
	* gfortran.dg/string_3.f90: Limit to ilp32 targets.
	* gfortran.dg/string_3_lp64.f90: New test.

libgfortran:

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

	PR fortran/78534
	* intrinsics/args.c (getarg_i4): Use gfc_charlen_type.
	(get_command_argument_i4): Likewise.
	(get_command_i4): Likewise.
	* intrinsics/chmod.c (chmod_internal): Likewise.
	* intrinsics/env.c (get_environment_variable_i4): Likewise.
	* intrinsics/extends_type_of.c (struct vtype): Use size_t for size
	member.
	* intrinsics/gerror.c (gerror): Use gfc_charlen_type.
	* intrinsics/getlog.c (getlog): Likewise.
	* intrinsics/hostnm.c (hostnm_0): Likewise.
	* intrinsics/string_intrinsics_inc.c (string_len_trim): Rework to
	work if gfc_charlen_type is unsigned.
	(string_scan): Likewise.
	* io/transfer.c (transfer_character): Modify prototype.
	(transfer_character_write): Likewise.
	(transfer_character_wide): Likewise.
	(transfer_character_wide_write): Likewise.
	(transfer_array): Typecast to avoid signed-unsigned comparison.
	* io/unit.c (is_trim_ok): Use gfc_charlen_type.
	* io/write.c (namelist_write): Likewise.
	* libgfortran.h (gfc_charlen_type): Change typedef to size_t.

From-SVN: r256284
2018-01-05 21:01:12 +02:00
Jakub Jelinek
85ec4feb11 Update copyright years.
From-SVN: r256169
2018-01-03 11:03:58 +01:00
Janne Blomqvist
67c24a8bd6 PR 53796 Improve INQUIRE(RECL=...) handling
The current F2018 draft (N2137) specifies behavior of the RECL=
specifier in the INQUIRE statement, where it previously was left as
undefined. Namely:

- If the unit is not connected, RECL= should be given the value -1.
- If the unit is connected with stream access, RECL= should be given
  the value -2.

Further, as PR 53796 describes, the handling of RECL= is poor in other
ways as well. When the recl is set to the maximum possible
(GFC_INTEGER_8_HUGE / LLONG_MAX), which it does by default except for
preconnected units, and when INQUIRE(RECL=) is used with a 4 byte
integer, the value is truncated and the 4 byte value is thus
-1. Fixing this to generate an error is a lot of work, as currently
the truncation is done by the frontend, the library sees only an 8
byte value with no indication that the frontend is going to copy it to
a 4 byte one. Instead, this patch does a bit twiddling trick such that
the truncated 4 byte value is GFC_INTEGER_4_HUGE while still being
0.99999999 * GFC_INTEGER_8_HUGE which is large enough for all
practical purposes.

Finally, the patch removes GFORTRAN_DEFAULT_RECL which was used only
for preconnected units, and instead uses the same approach as describe
above.

Regtested on x86_64-pc-linux-gnu, Ok for trunk.

gcc/fortran/ChangeLog:

2017-11-28  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/53796
	* gfortran.texi: Remove mentions of GFORTRAN_DEFAULT_RECL.

libgfortran/ChangeLog:

2017-11-28  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/53796
	* io/inquire.c (inquire_via_unit): Set recl to -1 for unconnected
	units.
	* io/io.h (default_recl): New variable.
	* io/open.c (new_unit): Set recl to default_recl for sequential,
	-2 for stream access.
	* io/transfer.c (read_block_form): Test against default_recl
	instead of DEFAULT_RECL.
	(write_block): Likewise.
	* io/unit.c (init_units): Calculate max_offset, default_recl.
	* libgfortran.h (DEFAULT_RECL): Remove.
	* runtime/environ.c: Remove GFORTRAN_DEFAULT_RECL.

gcc/testsuite/ChangeLog:

2017-11-28  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/53796
	* gfortran.dg/inquire_recl_f2018.f90: New test.

From-SVN: r255215
2017-11-28 21:28:50 +02:00
Janne Blomqvist
5675291ddb PR 83097 Use __BYTE_ORDER__ predefined macro instead of runtime check
By using the __BYTE_ORDER__ predefined macro we don't need the
determine_endianness function anymore.

Regtested on x86_64-pc-linux-gnu.

libgfortran/ChangeLog:

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

        PR libfortran/83097
	* io/inquire.c (inquire_via_unit): Use __BYTE_ORDER__ predefined
	macro.
	* io/open.c (st_open): Likewise.
	* io/transfer.c (data_transfer_init): Likewise.
	* io/write.c (btoa_big): Likewise.
	(otoa_big): Likewise.
	(ztoa_big): Likewise.
	* libgfortran.h (big_endian): Remove variable.
	(GFOR_POINTER_TO_L1): Use __BYTE_ORDER__ macro.
	* runtime/main.c (determine_endianness): Remove function.
	(init): Remove call to determine_endianness.
	* runtime/minimal.c: Remove setting big_endian variable.

From-SVN: r255072
2017-11-22 21:19:13 +02:00
Thomas Koenig
ddc9995b13 re PR fortran/36313 ([F03] {MIN,MAX}{LOC,VAL} should accept character arguments)
2017-11-22  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/36313
	* Makefile.am: Add i_maxloc0s_c, i_maxloc1s_c, i_maxloc2s_c,
	i_minloc0s_c, i_minloc1s_c and i_minloc2s_c.
	* Makefile.in: Regenerated.
        * generated/maxloc0_16_s1.c: New file.
        * generated/maxloc0_16_s4.c: New file.
        * generated/maxloc0_4_s1.c: New file.
        * generated/maxloc0_4_s4.c: New file.
        * generated/maxloc0_8_s1.c: New file.
        * generated/maxloc0_8_s4.c: New file.
        * generated/maxloc1_16_s1.c: New file.
        * generated/maxloc1_16_s4.c: New file.
        * generated/maxloc1_4_s1.c: New file.
        * generated/maxloc1_4_s4.c: New file.
        * generated/maxloc1_8_s1.c: New file.
        * generated/maxloc1_8_s4.c: New file.
        * generated/maxloc2_16_s1.c: New file.
        * generated/maxloc2_16_s4.c: New file.
        * generated/maxloc2_4_s1.c: New file.
        * generated/maxloc2_4_s4.c: New file.
        * generated/maxloc2_8_s1.c: New file.
        * generated/maxloc2_8_s4.c: New file.
        * generated/minloc0_16_s1.c: New file.
        * generated/minloc0_16_s4.c: New file.
        * generated/minloc0_4_s1.c: New file.
        * generated/minloc0_4_s4.c: New file.
        * generated/minloc0_8_s1.c: New file.
        * generated/minloc0_8_s4.c: New file.
        * generated/minloc1_16_s1.c: New file.
        * generated/minloc1_16_s4.c: New file.
        * generated/minloc1_4_s1.c: New file.
        * generated/minloc1_4_s4.c: New file.
        * generated/minloc1_8_s1.c: New file.
        * generated/minloc1_8_s4.c: New file.
        * generated/minloc2_16_s1.c: New file.
        * generated/minloc2_16_s4.c: New file.
        * generated/minloc2_4_s1.c: New file.
        * generated/minloc2_4_s4.c: New file.
        * generated/minloc2_8_s1.c: New file.
        * generated/minloc2_8_s4.c: New file.
        * m4/iforeach-s.m4: New file.
        * m4/ifunction-s.m4: New file.
        * m4/maxloc0s.m4: New file.
        * m4/maxloc1s.m4: New file.
        * m4/maxloc2s.m4: New file.
        * m4/minloc0s.m4: New file.
        * m4/minloc1s.m4: New file.
        * m4/minloc2s.m4: New file.
	* gfortran.map: Add new functions.
	* libgfortran.h: Add gfc_array_s1 and gfc_array_s4.

2017-11-22  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/36313
	* check.c (int_or_real_or_char_check_f2003): New function.
	* iresolve.c (gfc_resolve_maxloc): Add number "2" for
	character arguments and rank-zero return value.
	(gfc_resolve_minloc): Likewise.
	* trans-intrinsic.c (gfc_conv_intrinsic_minmaxloc): Handle case of
	character arguments and rank-zero return value by removing
	unneeded arguments and calling the library function.

2017-11-22  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/36313
	* gfortran.dg/maxloc_string_1.f90: New test.
	* gfortran.dg/minloc_string_1.f90: New test.

From-SVN: r255070
2017-11-22 18:08:07 +00:00
Paul Thomas
ff3598bc73 re PR fortran/34640 (ICE when assigning item of a derived-component to a pointer)
2017-09-10  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/34640
	PR fortran/40737
	PR fortran/55763
	PR fortran/57019
	PR fortran/57116

	* expr.c (is_subref_array): Add class pointer array dummies
	to the list of expressions that return true.
	* trans-array.c: Add SPAN_FIELD and update indices for
	subsequent fields.
	(gfc_conv_descriptor_span, gfc_conv_descriptor_span_get,
	gfc_conv_descriptor_span_set, is_pointer_array,
	get_array_span): New functions.
	(gfc_get_descriptor_offsets_for_info): New function to preserve
	API for access to descriptor fields for trans-types.c.
	(gfc_conv_scalarized_array_ref): If the expression is a subref
	array, make sure that info->descriptor is a descriptor type.
	Otherwise, if info->descriptor is a pointer array, set 'decl'
	and fix it if it is a component reference.
	(build_array_ref): Simplify handling of class array refs by
	passing the vptr to gfc_build_array_ref rather than generating
	the pointer arithmetic in this function.
	(gfc_conv_array_ref): As in gfc_conv_scalarized_array_ref, set
	'decl'.
	(gfc_array_allocate): Set the span field if this is a pointer
	array. Use the expr3 element size if it is available, so that
	the dynamic type element size is used.
	(gfc_conv_expr_descriptor): Set the span field for pointer
	assignments.
	* trans-array.h: Prototypes for gfc_conv_descriptor_span_get
	gfc_conv_descriptor_span_set and
	gfc_get_descriptor_offsets_for_info added.
	trans-decl.c (gfc_get_symbol_decl): If a non-class pointer
	array, mark the declaration as a GFC_DECL_PTR_ARRAY_P. Remove
	the setting of GFC_DECL_SPAN.
	(gfc_trans_deferred_vars): Set the span field to zero in thge
	originating scope.
	* trans-expr.c (gfc_conv_procedure_call): Do not use copy-in/
	copy-out to pass subref expressions to a pointer dummy.
	(gfc_trans_pointer_assignment): Remove code for setting of
	GFC_DECL_SPAN. Set the 'span' field for non-class pointers to
	class function results. Likewise for rank remap. In the case
	that the target is not a whole array, use the target array ref
	for remap and, since the 'start' indices are missing, set the
	lbounds to one, as required by the standard.
	* trans-intrinsic.c (conv_expr_ref_to_caf_ref): Pick up the
	'token' offset from the field decl in the descriptor.
	(conv_isocbinding_subroutine): Set the 'span' field.
	* trans-io.c (gfc_trans_transfer): Always scalarize pointer
	array io.
	* trans-stmt.c (trans_associate_var): Set the 'span' field.
	* trans-types.c (gfc_get_array_descriptor_base): Add the 'span'
	field to the array descriptor.
	(gfc_get_derived_type): Pointer array components are marked as
	GFC_DECL_PTR_ARRAY_P.
	(gfc_get_array_descr_info): Replaced API breaking code for
	descriptor offset calling gfc_get_descriptor_offsets_for_info.
	* trans.c (get_array_span): New function.
	(gfc_build_array_ref): Simplify by calling get_array_span and
	obtain 'span' if 'decl' or 'vptr' present.
	* trans.h : Rename DECL_LANG_FLAG_6, GFC_DECL_SUBREF_ARRAY_P,
	as GFC_DECL_PTR_ARRAY_P.


2017-09-10  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/34640
	* gfortran.dg/associate_24.f90: New test.
	* gfortran.dg/assumed_type_2.f90: Adjust some of the tree dump
	checks.
	* gfortran.dg/no_arg_check_2.f90: Likewise.
	* gfortran.dg/pointer_array_1.f90: New test.
	* gfortran.dg/pointer_array_2.f90: New test.
	* gfortran.dg/pointer_array_7.f90: New test.
	* gfortran.dg/pointer_array_8.f90: New test.
	* gfortran.dg/pointer_array_component_1.f90: New test.
	* gfortran.dg/pointer_array_component_2.f90: New test.
	* gfortran.dg/goacc/kernels-alias-4.f95: Bump up both tree scan
	counts by 1.

	PR fortran/40737
	* gfortran.dg/pointer_array_3.f90: New test.

	PR fortran/57116
	* gfortran.dg/pointer_array_4.f90: New test.

	PR fortran/55763
	* gfortran.dg/pointer_array_5.f90: New test.

	PR fortran/57019
	* gfortran.dg/pointer_array_6.f90: New test.

2017-09-10  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/34640
	* libgfortran/libgfortran.h: Add span field to descriptor.
	* libgfortran/libtool-version : Bump up version number to 5:0:0.

From-SVN: r251949
2017-09-10 17:02:53 +00:00
Thomas Koenig
e56e3fda60 re PR fortran/52473 (CSHIFT slow - inline it?)
2017-06-24  Thomas Koenig  <tkoenig@gcc.gnu.org>

        PR fortran/52473
	* Makefile.am:  Add i_cshift1a_c.  Add rules to generate files
	from cshift1a.m4.
	* Makefile.in: Regenerated.
	* m4/cshift1a.m4: New file.
	* m4/cshift.m4 (cshift1): Split up inner loop by removing
	condition. Use memcpy where possible.  Call helper functions
	based on dtype.
	* libgfortran.h: Add prototypes for cshift1_16_c10,
	cshift1_16_c16, cshift1_16_c4, cshift1_16_c8, cshift1_16_i1,
	cshift1_16_i16, cshift1_16_i2, cshift1_16_i4, cshift1_16_i8,
	cshift1_16_r10, cshift1_16_r16, cshift1_16_r4, cshift1_16_r8,
	cshift1_4_c10, cshift1_4_c16, cshift1_4_c4, cshift1_4_c8,
	cshift1_4_i1, cshift1_4_i16, cshift1_4_i2, cshift1_4_i4,
	cshift1_4_i8, cshift1_4_r10, cshift1_4_r16, cshift1_4_r4,
	cshift1_4_r8, cshift1_8_c10, cshift1_8_c16, cshift1_8_c4,
	cshift1_8_c8, cshift1_8_i1, cshift1_8_i16, cshift1_8_i2,
	cshift1_8_i4, cshift1_8_i8, cshift1_8_r10, cshift1_8_r16,
	cshift1_8_r4 and cshift1_8_r8.
	* generated/cshift1_16_c10.c: New file, generated from cshift1a.m4.
	* generated/cshift1_16_c16.c: New file, generated from cshift1a.m4.
	* generated/cshift1_16_c4.c: New file, generated from cshift1a.m4.
	* generated/cshift1_16_c8.c: New file, generated from cshift1a.m4.
	* generated/cshift1_16_i1.c: New file, generated from cshift1a.m4.
	* generated/cshift1_16_i16.c: New file, generated from cshift1a.m4.
	* generated/cshift1_16_i2.c: New file, generated from cshift1a.m4.
	* generated/cshift1_16_i4.c: New file, generated from cshift1a.m4.
	* generated/cshift1_16_i8.c: New file, generated from cshift1a.m4.
	* generated/cshift1_16_r10.c: New file, generated from cshift1a.m4.
	* generated/cshift1_16_r16.c: New file, generated from cshift1a.m4.
	* generated/cshift1_16_r4.c: New file, generated from cshift1a.m4.
	* generated/cshift1_16_r8.c: New file, generated from cshift1a.m4.
	* generated/cshift1_4_c10.c: New file, generated from cshift1a.m4.
	* generated/cshift1_4_c16.c: New file, generated from cshift1a.m4.
	* generated/cshift1_4_c4.c: New file, generated from cshift1a.m4.
	* generated/cshift1_4_c8.c: New file, generated from cshift1a.m4.
	* generated/cshift1_4_i1.c: New file, generated from cshift1a.m4.
	* generated/cshift1_4_i16.c: New file, generated from cshift1a.m4.
	* generated/cshift1_4_i2.c: New file, generated from cshift1a.m4.
	* generated/cshift1_4_i4.c: New file, generated from cshift1a.m4.
	* generated/cshift1_4_i8.c: New file, generated from cshift1a.m4.
	* generated/cshift1_4_r10.c: New file, generated from cshift1a.m4.
	* generated/cshift1_4_r16.c: New file, generated from cshift1a.m4.
	* generated/cshift1_4_r4.c: New file, generated from cshift1a.m4.
	* generated/cshift1_4_r8.c: New file, generated from cshift1a.m4.
	* generated/cshift1_8_c10.c: New file, generated from cshift1a.m4.
	* generated/cshift1_8_c16.c: New file, generated from cshift1a.m4.
	* generated/cshift1_8_c4.c: New file, generated from cshift1a.m4.
	* generated/cshift1_8_c8.c: New file, generated from cshift1a.m4.
	* generated/cshift1_8_i1.c: New file, generated from cshift1a.m4.
	* generated/cshift1_8_i16.c: New file, generated from cshift1a.m4.
	* generated/cshift1_8_i2.c: New file, generated from cshift1a.m4.
	* generated/cshift1_8_i4.c: New file, generated from cshift1a.m4.
	* generated/cshift1_8_i8.c: New file, generated from cshift1a.m4.
	* generated/cshift1_8_r10.c: New file, generated from cshift1a.m4.
	* generated/cshift1_8_r16.c: New file, generated from cshift1a.m4.
	* generated/cshift1_8_r4.c: New file, generated from cshift1a.m4.
	* generated/cshift1_8_r8.c: New file, generated from cshift1a.m4.

2017-06-24  Thomas Koenig  <tkoenig@gcc.gnu.org>

        PR fortran/52473
	* gfortran.dg/cshift_2.f90:  New test.

From-SVN: r249620
2017-06-24 07:07:56 +00:00
Janne Blomqvist
d86e68e207 Don't assume __secure_getenv is available
Glibc 2.17 made __secure_getenv an officially supported function, and
renamed it secure_getenv. The libgfortran configure has checked for
both of these, per
https://sourceware.org/glibc/wiki/Tips_and_Tricks/secure_getenv.

Unfortunately, while the dynamical library (libc.so) retains the
__secure_getenv symbol for backwards compatibility, the static library
(libc.a) does not. This means that a libgfortran.a compiled against an
older glibc will not work if one tries to link against a newer
libc.a. This creates problems for providing gfortran binary
distributions that work on as many target systems as possible.

Thus, retain the support for __secure_getenv but call it only via a
weak reference.

Regtested on x86_64-pc-linux-gnu.

2017-05-11  Janne Blomqvist  <jb@gcc.gnu.org>

	* libgfortran.h: HAVE_SECURE_GETENV: Don't check
	HAVE___SECURE_GETENV.
	* environ/runtime.c (secure_getenv): Use __secure_getenv via a
        weak reference.

From-SVN: r247927
2017-05-11 23:04:53 +03:00
Thomas Koenig
20305b5047 re PR libfortran/79956 (many new -Wmaybe-uninitialized warnings with bootstrap-O3)
2017-03-15  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR libfortran/79956
	* libgfortran.h (GFC_ASSERT):  New macro.
	* m4/reshape.m4 (reshape_'rtype_ccode`):  Use GFC_ASSERT
	to specify that sdim > 0 and rdim > 0.
	* intrinsic/reshape_generic.c (reshape_internal):  Likweise.
	* 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: r246153
2017-03-15 07:45:39 +00:00
Janne Blomqvist
c1e9bbcc49 Revert r244448
From-SVN: r244454
2017-01-13 21:53:16 +02:00
Janne Blomqvist
a6ab4e077b PR 78534 Change character length from int to size_t
In order to handle large character lengths on (L)LP64 targets, switch
the GFortran character length from an int to a size_t.

This is an ABI change, as procedures with character arguments take
hidden arguments with the character length.

I also changed the _size member in vtables from int to size_t, as
there were some cases where character lengths and sizes were
apparently mixed up and caused regressions otherwise. Although I
haven't tested, this might enable very large derived types as well.

Also, as there are some places in the frontend were negative character
lengths are used as special flag values, in the frontend the character
length is handled as a signed variable of the same size as a size_t,
although in the runtime library it really is size_t.

I haven't changed the character length variables for the co-array
intrinsics, as this is something that may need to be synchronized with
OpenCoarrays.

This is v4 of the patch. v3 was applied but had to reverted due to
breaking bootstrap. The fix is in resolve.c:resolve_charlen, where
it's necessary to check that an expression is constant before using
mpz_sgn.

Overview of v3 of the patch: All the issues pointed out by FX's review
of v2 have been fixed. In particular, there are now new functions
gfc_mpz_get_hwi and gfc_mpz_set_hwi, similar to the GMP functions
mpz_get_si and mpz_set_si, except that they get/set a HOST_WIDE_INT
instead of a long value. Similarly, gfc_get_int_expr now takes a
HOST_WIDE_INT instead of a long, gfc_extract_long is replaced by
gfc_extract_hwi. Also, the preliminary work to handle
gfc_charlen_type_node being unsigned has been removed.

Regtested on x86_64-pc-linux-gnu and i686-pc-linux-gnu.

frontend:

2017-01-13  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/78534
	PR fortran/66310
	* class.c (gfc_find_derived_vtab): Use gfc_size_kind instead of
	hardcoded kind.
	(find_intrinsic_vtab): Likewise.
	* expr.c (gfc_get_character_expr): Length parameter of type
	gfc_charlen_t.
	(gfc_get_int_expr): Value argument of type HOST_WIDE_INT.
	(gfc_extract_hwi): New function.
	(simplify_const_ref): Make string_len of type gfc_charlen_t.
	(gfc_simplify_expr): Use HOST_WIDE_INT for substring refs.
	* gfortran.h (gfc_mpz_get_hwi): New prototype.
	(gfc_mpz_set_hwi): Likewise.
	(gfc_charlen_t): New typedef.
	(gfc_expr): Use gfc_charlen_t for character lengths.
	(gfc_size_kind): New extern variable.
	(gfc_extract_hwi): New prototype.
	(gfc_get_character_expr): Use gfc_charlen_t for character length.
	(gfc_get_int_expr): Use HOST_WIDE_INT type for value argument.
	* iresolve.c (gfc_resolve_repeat): Pass string length directly without
	temporary, use gfc_charlen_int_kind.
	* match.c (select_intrinsic_set_tmp): Use HOST_WIDE_INT for charlen.
	* misc.c (gfc_mpz_get_hwi): New function.
	(gfc_mpz_set_hwi): New function.
	* module.c (atom_int): Change type from int to HOST_WIDE_INT.
	(parse_integer): Don't complain about large integers.
	(write_atom): Use HOST_WIDE_INT for integers.
	(mio_integer): Handle integer type mismatch.
	(mio_hwi): New function.
	(mio_intrinsic_op): Use HOST_WIDE_INT.
	(mio_array_ref): Likewise.
	(mio_expr): Likewise.
	* resolve.c (resolve_select_type): Use HOST_WIDE_INT for charlen,
	use snprintf.
	(resolve_substring_charlen): Use gfc_charlen_int_kind.
	(resolve_charlen): Use mpz_sgn to determine sign.
	* simplify.c (gfc_simplify_repeat): Use HOST_WIDE_INT/gfc_charlen_t
	instead of long.
	* target-memory.c (size_character): Length argument of type
	gfc_charlen_t.
	(gfc_encode_character): Likewise.
	(gfc_interpret_character): Use gfc_charlen_t.
	* target-memory.h (gfc_encode_character): Modify prototype.
	* trans-array.c (get_array_ctor_var_strlen): Use
	gfc_conv_mpz_to_tree_type.
	* trans-const.c (gfc_conv_mpz_to_tree_type): New function.
	* trans-const.h (gfc_conv_mpz_to_tree_type): New prototype.
	* trans-expr.c (gfc_class_len_or_zero_get): Build const of type
	gfc_charlen_type_node.
	(gfc_conv_intrinsic_to_class): Use gfc_charlen_int_kind instead of
	4, fold_convert to correct type.
	(gfc_conv_class_to_class): Build const of type size_type_node for
	size.
	(gfc_copy_class_to_class): Likewise.
	(gfc_conv_string_length): Use same type in expression.
	(gfc_conv_substring): Likewise, use HOST_WIDE_INT for charlen.
	(gfc_conv_string_tmp): Make sure len is of the right type.
	(gfc_conv_concat_op): Use same type in expression.
	(gfc_conv_procedure_call): Likewise.
	(alloc_scalar_allocatable_for_subcomponent_assignment):
	fold_convert to right type.
	(gfc_trans_subcomponent_assign): Likewise.
	(trans_class_vptr_len_assignment): Build const of correct type.
	(gfc_trans_pointer_assignment): Likewise.
	(alloc_scalar_allocatable_for_assignment): fold_convert to right
	type in expr.
	(trans_class_assignment): Build const of correct type.
	* trans-intrinsic.c (gfc_conv_associated): Likewise.
	(gfc_conv_intrinsic_repeat): Do calculation in sizetype.
	* trans-io.c (gfc_build_io_library_fndecls): Use
	gfc_charlen_type_node for character lengths.
	* trans-stmt.c (gfc_trans_label_assign): Build const of
	gfc_charlen_type_node.
	(gfc_trans_character_select): Likewise.
	(gfc_trans_allocate): Likewise, don't typecast strlen result.
	(gfc_trans_deallocate): Don't typecast strlen result.
	* trans-types.c (gfc_size_kind): New variable.
	(gfc_init_types): Determine gfc_charlen_int_kind and gfc_size_kind
	from size_type_node.

testsuite:

2017-01-13  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/78534
	PR fortran/66310
	* gfortran.dg/repeat_4.f90: Use integers of kind C_SIZE_T.
	* gfortran.dg/repeat_7.f90: New test for PR 66310.
	* gfortran.dg/scan_2.f90: Handle potential cast in assignment.
	* gfortran.dg/string_1.f90: Limit to ilp32 targets.
	* gfortran.dg/string_1_lp64.f90: New test.
	* gfortran.dg/string_3.f90: Limit to ilp32 targets.
	* gfortran.dg/string_3_lp64.f90: New test.

libgfortran:

2017-01-13  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/78534
	* intrinsics/args.c (getarg_i4): Use gfc_charlen_type.
	(get_command_argument_i4): Likewise.
	(get_command_i4): Likewise.
	* intrinsics/chmod.c (chmod_internal): Likewise.
	* intrinsics/env.c (get_environment_variable_i4): Likewise.
	* intrinsics/extends_type_of.c (struct vtype): Use size_t for size
	member.
	* intrinsics/gerror.c (gerror): Use gfc_charlen_type.
	* intrinsics/getlog.c (getlog): Likewise.
	* intrinsics/hostnm.c (hostnm_0): Likewise.
	* intrinsics/string_intrinsics_inc.c (string_len_trim): Rework to
	work if gfc_charlen_type is unsigned.
	(string_scan): Likewise.
	* io/transfer.c (transfer_character): Modify prototype.
	(transfer_character_write): Likewise.
	(transfer_character_wide): Likewise.
	(transfer_character_wide_write): Likewise.
	(transfer_array): Typecast to avoid signed-unsigned comparison.
	* io/unit.c (is_trim_ok): Use gfc_charlen_type.
	* io/write.c (namelist_write): Likewise.
	* libgfortran.h (gfc_charlen_type): Change typedef to size_t.

From-SVN: r244448
2017-01-13 19:05:48 +02:00
Janne Blomqvist
84aff3c2d4 PR 78534 Revert r244011
r244011 caused regressions on 32-bit hosts.

From-SVN: r244027
2017-01-03 20:01:30 +02:00
Janne Blomqvist
994e4aca2c PR 78534 Change character length from int to size_t
In order to handle large character lengths on (L)LP64 targets, switch
the GFortran character length from an int to a size_t.

This is an ABI change, as procedures with character arguments take
hidden arguments with the character length.

I also changed the _size member in vtables from int to size_t, as
there were some cases where character lengths and sizes were
apparently mixed up and caused regressions otherwise. Although I
haven't tested, this might enable very large derived types as well.

Also, as there are some places in the frontend were negative character
lengths are used as special flag values, in the frontend the character
length is handled as a signed variable of the same size as a size_t,
although in the runtime library it really is size_t.

I haven't changed the character length variables for the co-array
intrinsics, as this is something that may need to be synchronized with
OpenCoarrays.

This is v3 of the patch. All the issues pointed out by FX's review of
v2 have been fixed. In particular, there are now new functions
gfc_mpz_get_hwi and gfc_mpz_set_hwi, similar to the GMP functions
mpz_get_si and mpz_set_si, except that they get/set a HOST_WIDE_INT
instead of a long value. Similarly, gfc_get_int_expr now takes a
HOST_WIDE_INT instead of a long, gfc_extract_long is replaced by
gfc_extract_hwi. Also, the preliminary work to handle
gfc_charlen_type_node being unsigned has been removed.

Regtested on x86_64-pc-linux-gnu.

frontend:

2017-01-03  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/78534
	PR fortran/66310
	* class.c (gfc_find_derived_vtab): Use gfc_size_kind instead of
	hardcoded kind.
	(find_intrinsic_vtab): Likewise.
	* expr.c (gfc_get_character_expr): Length parameter of type
	gfc_charlen_t.
	(gfc_get_int_expr): Value argument of type HOST_WIDE_INT.
	(gfc_extract_hwi): New function.
	(simplify_const_ref): Make string_len of type gfc_charlen_t.
	(gfc_simplify_expr): Use HOST_WIDE_INT for substring refs.
	* gfortran.h (gfc_mpz_get_hwi): New prototype.
	(gfc_mpz_set_hwi): Likewise.
	(gfc_charlen_t): New typedef.
	(gfc_expr): Use gfc_charlen_t for character lengths.
	(gfc_size_kind): New extern variable.
	(gfc_extract_hwi): New prototype.
	(gfc_get_character_expr): Use gfc_charlen_t for character length.
	(gfc_get_int_expr): Use HOST_WIDE_INT type for value argument.
	* iresolve.c (gfc_resolve_repeat): Pass string length directly without
	temporary, use gfc_charlen_int_kind.
	* match.c (select_intrinsic_set_tmp): Use HOST_WIDE_INT for charlen.
	* misc.c (gfc_mpz_get_hwi): New function.
	(gfc_mpz_set_hwi): New function.
	* module.c (atom_int): Change type from int to HOST_WIDE_INT.
	(parse_integer): Don't complain about large integers.
	(write_atom): Use HOST_WIDE_INT for integers.
	(mio_integer): Handle integer type mismatch.
	(mio_hwi): New function.
	(mio_intrinsic_op): Use HOST_WIDE_INT.
	(mio_array_ref): Likewise.
	(mio_expr): Likewise.
	* resolve.c (resolve_select_type): Use HOST_WIDE_INT for charlen,
	use snprintf.
	(resolve_charlen): Use mpz_sgn to determine sign.
	* simplify.c (gfc_simplify_repeat): Use HOST_WIDE_INT/gfc_charlen_t
	instead of long.
	* target-memory.c (size_character): Length argument of type
	gfc_charlen_t.
	(gfc_encode_character): Likewise.
	(gfc_interpret_character): Use gfc_charlen_t.
	* target-memory.h (gfc_encode_character): Modify prototype.
	* trans-array.c (get_array_ctor_var_strlen): Use
	gfc_conv_mpz_to_tree_type.
	* trans-const.c (gfc_conv_mpz_to_tree_type): New function.
	* trans-const.h (gfc_conv_mpz_to_tree_type): New prototype.
	* trans-expr.c (gfc_class_len_or_zero_get): Build const of type
	gfc_charlen_type_node.
	(gfc_conv_intrinsic_to_class): Use gfc_charlen_int_kind instead of
	4, fold_convert to correct type.
	(gfc_conv_class_to_class): Build const of type size_type_node for
	size.
	(gfc_copy_class_to_class): Likewise.
	(gfc_conv_string_length): Use same type in expression.
	(gfc_conv_substring): Likewise, use HOST_WIDE_INT for charlen.
	(gfc_conv_string_tmp): Make sure len is of the right type.
	(gfc_conv_concat_op): Use same type in expression.
	(gfc_conv_procedure_call): Likewise.
	(alloc_scalar_allocatable_for_subcomponent_assignment):
	fold_convert to right type.
	(gfc_trans_subcomponent_assign): Likewise.
	(trans_class_vptr_len_assignment): Build const of correct type.
	(gfc_trans_pointer_assignment): Likewise.
	(alloc_scalar_allocatable_for_assignment): fold_convert to right
	type in expr.
	(trans_class_assignment): Build const of correct type.
	* trans-intrinsic.c (gfc_conv_associated): Likewise.
	(gfc_conv_intrinsic_repeat): Do calculation in sizetype.
	* trans-io.c (gfc_build_io_library_fndecls): Use
	gfc_charlen_type_node for character lengths.
	* trans-stmt.c (gfc_trans_label_assign): Build const of
	gfc_charlen_type_node.
	(gfc_trans_character_select): Likewise.
	(gfc_trans_allocate): Likewise, don't typecast strlen result.
	(gfc_trans_deallocate): Don't typecast strlen result.
	* trans-types.c (gfc_size_kind): New variable.
	(gfc_init_types): Determine gfc_charlen_int_kind and gfc_size_kind
	from size_type_node.

testsuite:

2017-01-03  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/78534
	PR fortran/66310
	* gfortran.dg/dependency_49.f90: Change scan-tree-dump-times
          due to gfc_trans_string_copy change to avoid
          -Wstringop-overflow.
	* gfortran.dg/repeat_4.f90: Use integers of kind C_SIZE_T.
	* gfortran.dg/repeat_7.f90: New test for PR 66310.
	* gfortran.dg/scan_2.f90: Handle potential cast in assignment.
	* gfortran.dg/string_1.f90: Limit to ilp32 targets.
	* gfortran.dg/string_1_lp64.f90: New test.
	* gfortran.dg/string_3.f90: Limit to ilp32 targets.
	* gfortran.dg/string_3_lp64.f90: New test.
	* gfortran.dg/transfer_intrinsic_1.f90: Change
          scan-tree-dump-times due to gfc_trans_string_copy change to
          avoid -Wstringop-overflow.

libgfortran:

2017-01-03  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/78534
	* intrinsics/args.c (getarg_i4): Use gfc_charlen_type.
	(get_command_argument_i4): Likewise.
	(get_command_i4): Likewise.
	* intrinsics/chmod.c (chmod_internal): Likewise.
	* intrinsics/env.c (get_environment_variable_i4): Likewise.
	* intrinsics/extends_type_of.c (struct vtype): Use size_t for size
	member.
	* intrinsics/gerror.c (gerror): Use gfc_charlen_type.
	* intrinsics/getlog.c (getlog): Likewise.
	* intrinsics/hostnm.c (hostnm_0): Likewise.
	* intrinsics/string_intrinsics_inc.c (string_len_trim): Rework to
	work if gfc_charlen_type is unsigned.
	(string_scan): Likewise.
	* io/transfer.c (transfer_character): Modify prototype.
	(transfer_character_write): Likewise.
	(transfer_character_wide): Likewise.
	(transfer_character_wide_write): Likewise.
	(transfer_array): Typecast to avoid signed-unsigned comparison.
	* io/unit.c (is_trim_ok): Use gfc_charlen_type.
	* io/write.c (namelist_write): Likewise.
	* libgfortran.h (gfc_charlen_type): Change typedef to size_t.

From-SVN: r244011
2017-01-03 09:04:01 +02:00
Jakub Jelinek
cbe34bb5ed Update copyright years.
From-SVN: r243994
2017-01-01 13:07:43 +01:00
Francois-Xavier Coudert
887d9b8b6d libgfortran.h: Include <stdlib.h> header.
* libgfortran.h: Include <stdlib.h> header.
	* intrinsics/access.c: Do not include <stdlib.h> header.
	* intrinsics/chdir.c: Do not include <stdlib.h> header.
	* intrinsics/chmod.c: Do not include <stdlib.h> header.
	* intrinsics/date_and_time.c: Do not include <stdlib.h> header.
	* intrinsics/env.c: Do not include <stdlib.h> header.
	* intrinsics/execute_command_line.c: Do not include <stdlib.h> header.
	* intrinsics/exit.c: Do not include <stdlib.h> header.
	* intrinsics/getcwd.c: Do not include <stdlib.h> header.
	* intrinsics/getlog.c: Do not include <stdlib.h> header.
	* intrinsics/link.c: Do not include <stdlib.h> header.
	* intrinsics/move_alloc.c: Do not include <stdlib.h> header.
	* intrinsics/perror.c: Do not include <stdlib.h> header.
	* intrinsics/random.c: Do not include <stdlib.h> header.
	* intrinsics/rename.c: Do not include <stdlib.h> header.
	* intrinsics/reshape_generic.c: Do not include <stdlib.h> header.
	* intrinsics/stat.c: Do not include <stdlib.h> header.
	* intrinsics/symlnk.c: Do not include <stdlib.h> header.
	* intrinsics/system.c: Do not include <stdlib.h> header.
	* intrinsics/unlink.c: Do not include <stdlib.h> header.
	* io/fbuf.c: Do not include <stdlib.h> header.
	* io/format.c: Do not include <stdlib.h> header.
	* io/intrinsics.c: Do not include <stdlib.h> header.
	* io/list_read.c: Do not include <stdlib.h> header.
	* io/lock.c: Do not include <stdlib.h> header.
	* io/open.c: Do not include <stdlib.h> header.
	* io/read.c: Do not include <stdlib.h> header.
	* io/transfer.c: Do not include <stdlib.h> header.
	* io/unit.c: Do not include <stdlib.h> header.
	* io/unix.c: Do not include <stdlib.h> header.
	* io/write.c: Do not include <stdlib.h> header.
	* m4/all.m4: Do not include <stdlib.h> header.
	* m4/any.m4: Do not include <stdlib.h> header.
	* m4/bessel.m4: Do not include <stdlib.h> header.
	* m4/count.m4: Do not include <stdlib.h> header.
	* m4/cshift0.m4: Do not include <stdlib.h> header.
	* m4/cshift1.m4: Do not include <stdlib.h> header.
	* m4/eoshift1.m4: Do not include <stdlib.h> header.
	* m4/eoshift3.m4: Do not include <stdlib.h> header.
	* m4/iall.m4: Do not include <stdlib.h> header.
	* m4/iany.m4: Do not include <stdlib.h> header.
	* m4/in_pack.m4: Do not include <stdlib.h> header.
	* m4/in_unpack.m4: Do not include <stdlib.h> header.
	* m4/iparity.m4: Do not include <stdlib.h> header.
	* m4/matmul.m4: Do not include <stdlib.h> header.
	* m4/matmull.m4: Do not include <stdlib.h> header.
	* m4/maxloc0.m4: Do not include <stdlib.h> header.
	* m4/maxloc1.m4: Do not include <stdlib.h> header.
	* m4/maxval.m4: Do not include <stdlib.h> header.
	* m4/minloc0.m4: Do not include <stdlib.h> header.
	* m4/minloc1.m4: Do not include <stdlib.h> header.
	* m4/minval.m4: Do not include <stdlib.h> header.
	* m4/norm2.m4: Do not include <stdlib.h> header.
	* m4/pack.m4: Do not include <stdlib.h> header.
	* m4/parity.m4: Do not include <stdlib.h> header.
	* m4/product.m4: Do not include <stdlib.h> header.
	* m4/reshape.m4: Do not include <stdlib.h> header.
	* m4/shape.m4: Do not include <stdlib.h> header.
	* m4/spread.m4: Do not include <stdlib.h> header.
	* m4/sum.m4: Do not include <stdlib.h> header.
	* m4/unpack.m4: Do not include <stdlib.h> header.
	* runtime/environ.c: Do not include <stdlib.h> header.
	* runtime/error.c: Do not include <stdlib.h> header.
	* runtime/memory.c: Do not include <stdlib.h> header.
	* runtime/minimal.c: Do not include <stdlib.h> header.
	* runtime/string.c: Do not include <stdlib.h> header.
	* generated/all_l1.c: Regenerate.
	* generated/all_l16.c: Regenerate.
	* generated/all_l2.c: Regenerate.
	* generated/all_l4.c: Regenerate.
	* generated/all_l8.c: Regenerate.
	* generated/any_l1.c: Regenerate.
	* generated/any_l16.c: Regenerate.
	* generated/any_l2.c: Regenerate.
	* generated/any_l4.c: Regenerate.
	* generated/any_l8.c: Regenerate.
	* generated/bessel_r10.c: Regenerate.
	* generated/bessel_r16.c: Regenerate.
	* generated/bessel_r4.c: Regenerate.
	* generated/bessel_r8.c: Regenerate.
	* generated/count_16_l.c: Regenerate.
	* generated/count_1_l.c: Regenerate.
	* generated/count_2_l.c: Regenerate.
	* generated/count_4_l.c: Regenerate.
	* generated/count_8_l.c: Regenerate.
	* generated/cshift0_c10.c: Regenerate.
	* generated/cshift0_c16.c: Regenerate.
	* generated/cshift0_c4.c: Regenerate.
	* generated/cshift0_c8.c: Regenerate.
	* generated/cshift0_i1.c: Regenerate.
	* generated/cshift0_i16.c: Regenerate.
	* generated/cshift0_i2.c: Regenerate.
	* generated/cshift0_i4.c: Regenerate.
	* generated/cshift0_i8.c: Regenerate.
	* generated/cshift0_r10.c: Regenerate.
	* generated/cshift0_r16.c: Regenerate.
	* generated/cshift0_r4.c: Regenerate.
	* generated/cshift0_r8.c: Regenerate.
	* generated/cshift1_16.c: Regenerate.
	* generated/cshift1_4.c: Regenerate.
	* generated/cshift1_8.c: Regenerate.
	* generated/eoshift1_16.c: Regenerate.
	* generated/eoshift1_4.c: Regenerate.
	* generated/eoshift1_8.c: Regenerate.
	* generated/eoshift3_16.c: Regenerate.
	* generated/eoshift3_4.c: Regenerate.
	* generated/eoshift3_8.c: Regenerate.
	* generated/iall_i1.c: Regenerate.
	* generated/iall_i16.c: Regenerate.
	* generated/iall_i2.c: Regenerate.
	* generated/iall_i4.c: Regenerate.
	* generated/iall_i8.c: Regenerate.
	* generated/iany_i1.c: Regenerate.
	* generated/iany_i16.c: Regenerate.
	* generated/iany_i2.c: Regenerate.
	* generated/iany_i4.c: Regenerate.
	* generated/iany_i8.c: Regenerate.
	* generated/in_pack_c10.c: Regenerate.
	* generated/in_pack_c16.c: Regenerate.
	* generated/in_pack_c4.c: Regenerate.
	* generated/in_pack_c8.c: Regenerate.
	* generated/in_pack_i1.c: Regenerate.
	* generated/in_pack_i16.c: Regenerate.
	* generated/in_pack_i2.c: Regenerate.
	* generated/in_pack_i4.c: Regenerate.
	* generated/in_pack_i8.c: Regenerate.
	* generated/in_pack_r10.c: Regenerate.
	* generated/in_pack_r16.c: Regenerate.
	* generated/in_pack_r4.c: Regenerate.
	* generated/in_pack_r8.c: Regenerate.
	* generated/in_unpack_c10.c: Regenerate.
	* generated/in_unpack_c16.c: Regenerate.
	* generated/in_unpack_c4.c: Regenerate.
	* generated/in_unpack_c8.c: Regenerate.
	* generated/in_unpack_i1.c: Regenerate.
	* generated/in_unpack_i16.c: Regenerate.
	* generated/in_unpack_i2.c: Regenerate.
	* generated/in_unpack_i4.c: Regenerate.
	* generated/in_unpack_i8.c: Regenerate.
	* generated/in_unpack_r10.c: Regenerate.
	* generated/in_unpack_r16.c: Regenerate.
	* generated/in_unpack_r4.c: Regenerate.
	* generated/in_unpack_r8.c: Regenerate.
	* generated/iparity_i1.c: Regenerate.
	* generated/iparity_i16.c: Regenerate.
	* generated/iparity_i2.c: Regenerate.
	* generated/iparity_i4.c: Regenerate.
	* generated/iparity_i8.c: Regenerate.
	* generated/matmul_c10.c: Regenerate.
	* generated/matmul_c16.c: Regenerate.
	* generated/matmul_c4.c: Regenerate.
	* generated/matmul_c8.c: Regenerate.
	* generated/matmul_i1.c: Regenerate.
	* generated/matmul_i16.c: Regenerate.
	* generated/matmul_i2.c: Regenerate.
	* generated/matmul_i4.c: Regenerate.
	* generated/matmul_i8.c: Regenerate.
	* generated/matmul_l16.c: Regenerate.
	* generated/matmul_l4.c: Regenerate.
	* generated/matmul_l8.c: Regenerate.
	* generated/matmul_r10.c: Regenerate.
	* generated/matmul_r16.c: Regenerate.
	* generated/matmul_r4.c: Regenerate.
	* generated/matmul_r8.c: Regenerate.
	* generated/maxloc0_16_i1.c: Regenerate.
	* generated/maxloc0_16_i16.c: Regenerate.
	* generated/maxloc0_16_i2.c: Regenerate.
	* generated/maxloc0_16_i4.c: Regenerate.
	* generated/maxloc0_16_i8.c: Regenerate.
	* generated/maxloc0_16_r10.c: Regenerate.
	* generated/maxloc0_16_r16.c: Regenerate.
	* generated/maxloc0_16_r4.c: Regenerate.
	* generated/maxloc0_16_r8.c: Regenerate.
	* generated/maxloc0_4_i1.c: Regenerate.
	* generated/maxloc0_4_i16.c: Regenerate.
	* generated/maxloc0_4_i2.c: Regenerate.
	* generated/maxloc0_4_i4.c: Regenerate.
	* generated/maxloc0_4_i8.c: Regenerate.
	* generated/maxloc0_4_r10.c: Regenerate.
	* generated/maxloc0_4_r16.c: Regenerate.
	* generated/maxloc0_4_r4.c: Regenerate.
	* generated/maxloc0_4_r8.c: Regenerate.
	* generated/maxloc0_8_i1.c: Regenerate.
	* generated/maxloc0_8_i16.c: Regenerate.
	* generated/maxloc0_8_i2.c: Regenerate.
	* generated/maxloc0_8_i4.c: Regenerate.
	* generated/maxloc0_8_i8.c: Regenerate.
	* generated/maxloc0_8_r10.c: Regenerate.
	* generated/maxloc0_8_r16.c: Regenerate.
	* generated/maxloc0_8_r4.c: Regenerate.
	* generated/maxloc0_8_r8.c: Regenerate.
	* generated/maxloc1_16_i1.c: Regenerate.
	* generated/maxloc1_16_i16.c: Regenerate.
	* generated/maxloc1_16_i2.c: Regenerate.
	* generated/maxloc1_16_i4.c: Regenerate.
	* generated/maxloc1_16_i8.c: Regenerate.
	* generated/maxloc1_16_r10.c: Regenerate.
	* generated/maxloc1_16_r16.c: Regenerate.
	* generated/maxloc1_16_r4.c: Regenerate.
	* generated/maxloc1_16_r8.c: Regenerate.
	* generated/maxloc1_4_i1.c: Regenerate.
	* generated/maxloc1_4_i16.c: Regenerate.
	* generated/maxloc1_4_i2.c: Regenerate.
	* generated/maxloc1_4_i4.c: Regenerate.
	* generated/maxloc1_4_i8.c: Regenerate.
	* generated/maxloc1_4_r10.c: Regenerate.
	* generated/maxloc1_4_r16.c: Regenerate.
	* generated/maxloc1_4_r4.c: Regenerate.
	* generated/maxloc1_4_r8.c: Regenerate.
	* generated/maxloc1_8_i1.c: Regenerate.
	* generated/maxloc1_8_i16.c: Regenerate.
	* generated/maxloc1_8_i2.c: Regenerate.
	* generated/maxloc1_8_i4.c: Regenerate.
	* generated/maxloc1_8_i8.c: Regenerate.
	* generated/maxloc1_8_r10.c: Regenerate.
	* generated/maxloc1_8_r16.c: Regenerate.
	* generated/maxloc1_8_r4.c: Regenerate.
	* generated/maxloc1_8_r8.c: Regenerate.
	* generated/maxval_i1.c: Regenerate.
	* generated/maxval_i16.c: Regenerate.
	* generated/maxval_i2.c: Regenerate.
	* generated/maxval_i4.c: Regenerate.
	* generated/maxval_i8.c: Regenerate.
	* generated/maxval_r10.c: Regenerate.
	* generated/maxval_r16.c: Regenerate.
	* generated/maxval_r4.c: Regenerate.
	* generated/maxval_r8.c: Regenerate.
	* generated/minloc0_16_i1.c: Regenerate.
	* generated/minloc0_16_i16.c: Regenerate.
	* generated/minloc0_16_i2.c: Regenerate.
	* generated/minloc0_16_i4.c: Regenerate.
	* generated/minloc0_16_i8.c: Regenerate.
	* generated/minloc0_16_r10.c: Regenerate.
	* generated/minloc0_16_r16.c: Regenerate.
	* generated/minloc0_16_r4.c: Regenerate.
	* generated/minloc0_16_r8.c: Regenerate.
	* generated/minloc0_4_i1.c: Regenerate.
	* generated/minloc0_4_i16.c: Regenerate.
	* generated/minloc0_4_i2.c: Regenerate.
	* generated/minloc0_4_i4.c: Regenerate.
	* generated/minloc0_4_i8.c: Regenerate.
	* generated/minloc0_4_r10.c: Regenerate.
	* generated/minloc0_4_r16.c: Regenerate.
	* generated/minloc0_4_r4.c: Regenerate.
	* generated/minloc0_4_r8.c: Regenerate.
	* generated/minloc0_8_i1.c: Regenerate.
	* generated/minloc0_8_i16.c: Regenerate.
	* generated/minloc0_8_i2.c: Regenerate.
	* generated/minloc0_8_i4.c: Regenerate.
	* generated/minloc0_8_i8.c: Regenerate.
	* generated/minloc0_8_r10.c: Regenerate.
	* generated/minloc0_8_r16.c: Regenerate.
	* generated/minloc0_8_r4.c: Regenerate.
	* generated/minloc0_8_r8.c: Regenerate.
	* generated/minloc1_16_i1.c: Regenerate.
	* generated/minloc1_16_i16.c: Regenerate.
	* generated/minloc1_16_i2.c: Regenerate.
	* generated/minloc1_16_i4.c: Regenerate.
	* generated/minloc1_16_i8.c: Regenerate.
	* generated/minloc1_16_r10.c: Regenerate.
	* generated/minloc1_16_r16.c: Regenerate.
	* generated/minloc1_16_r4.c: Regenerate.
	* generated/minloc1_16_r8.c: Regenerate.
	* generated/minloc1_4_i1.c: Regenerate.
	* generated/minloc1_4_i16.c: Regenerate.
	* generated/minloc1_4_i2.c: Regenerate.
	* generated/minloc1_4_i4.c: Regenerate.
	* generated/minloc1_4_i8.c: Regenerate.
	* generated/minloc1_4_r10.c: Regenerate.
	* generated/minloc1_4_r16.c: Regenerate.
	* generated/minloc1_4_r4.c: Regenerate.
	* generated/minloc1_4_r8.c: Regenerate.
	* generated/minloc1_8_i1.c: Regenerate.
	* generated/minloc1_8_i16.c: Regenerate.
	* generated/minloc1_8_i2.c: Regenerate.
	* generated/minloc1_8_i4.c: Regenerate.
	* generated/minloc1_8_i8.c: Regenerate.
	* generated/minloc1_8_r10.c: Regenerate.
	* generated/minloc1_8_r16.c: Regenerate.
	* generated/minloc1_8_r4.c: Regenerate.
	* generated/minloc1_8_r8.c: Regenerate.
	* generated/minval_i1.c: Regenerate.
	* generated/minval_i16.c: Regenerate.
	* generated/minval_i2.c: Regenerate.
	* generated/minval_i4.c: Regenerate.
	* generated/minval_i8.c: Regenerate.
	* generated/minval_r10.c: Regenerate.
	* generated/minval_r16.c: Regenerate.
	* generated/minval_r4.c: Regenerate.
	* generated/minval_r8.c: Regenerate.
	* generated/norm2_r10.c: Regenerate.
	* generated/norm2_r16.c: Regenerate.
	* generated/norm2_r4.c: Regenerate.
	* generated/norm2_r8.c: Regenerate.
	* generated/pack_c10.c: Regenerate.
	* generated/pack_c16.c: Regenerate.
	* generated/pack_c4.c: Regenerate.
	* generated/pack_c8.c: Regenerate.
	* generated/pack_i1.c: Regenerate.
	* generated/pack_i16.c: Regenerate.
	* generated/pack_i2.c: Regenerate.
	* generated/pack_i4.c: Regenerate.
	* generated/pack_i8.c: Regenerate.
	* generated/pack_r10.c: Regenerate.
	* generated/pack_r16.c: Regenerate.
	* generated/pack_r4.c: Regenerate.
	* generated/pack_r8.c: Regenerate.
	* generated/parity_l1.c: Regenerate.
	* generated/parity_l16.c: Regenerate.
	* generated/parity_l2.c: Regenerate.
	* generated/parity_l4.c: Regenerate.
	* generated/parity_l8.c: Regenerate.
	* generated/product_c10.c: Regenerate.
	* generated/product_c16.c: Regenerate.
	* generated/product_c4.c: Regenerate.
	* generated/product_c8.c: Regenerate.
	* generated/product_i1.c: Regenerate.
	* generated/product_i16.c: Regenerate.
	* generated/product_i2.c: Regenerate.
	* generated/product_i4.c: Regenerate.
	* generated/product_i8.c: Regenerate.
	* generated/product_r10.c: Regenerate.
	* generated/product_r16.c: Regenerate.
	* generated/product_r4.c: Regenerate.
	* generated/product_r8.c: Regenerate.
	* generated/reshape_c10.c: Regenerate.
	* generated/reshape_c16.c: Regenerate.
	* generated/reshape_c4.c: Regenerate.
	* generated/reshape_c8.c: Regenerate.
	* generated/reshape_i16.c: Regenerate.
	* generated/reshape_i4.c: Regenerate.
	* generated/reshape_i8.c: Regenerate.
	* generated/reshape_r10.c: Regenerate.
	* generated/reshape_r16.c: Regenerate.
	* generated/reshape_r4.c: Regenerate.
	* generated/reshape_r8.c: Regenerate.
	* generated/shape_i1.c: Regenerate.
	* generated/shape_i16.c: Regenerate.
	* generated/shape_i2.c: Regenerate.
	* generated/shape_i4.c: Regenerate.
	* generated/shape_i8.c: Regenerate.
	* generated/spread_c10.c: Regenerate.
	* generated/spread_c16.c: Regenerate.
	* generated/spread_c4.c: Regenerate.
	* generated/spread_c8.c: Regenerate.
	* generated/spread_i1.c: Regenerate.
	* generated/spread_i16.c: Regenerate.
	* generated/spread_i2.c: Regenerate.
	* generated/spread_i4.c: Regenerate.
	* generated/spread_i8.c: Regenerate.
	* generated/spread_r10.c: Regenerate.
	* generated/spread_r16.c: Regenerate.
	* generated/spread_r4.c: Regenerate.
	* generated/spread_r8.c: Regenerate.
	* generated/sum_c10.c: Regenerate.
	* generated/sum_c16.c: Regenerate.
	* generated/sum_c4.c: Regenerate.
	* generated/sum_c8.c: Regenerate.
	* generated/sum_i1.c: Regenerate.
	* generated/sum_i16.c: Regenerate.
	* generated/sum_i2.c: Regenerate.
	* generated/sum_i4.c: Regenerate.
	* generated/sum_i8.c: Regenerate.
	* generated/sum_r10.c: Regenerate.
	* generated/sum_r16.c: Regenerate.
	* generated/sum_r4.c: Regenerate.
	* generated/sum_r8.c: Regenerate.
	* generated/unpack_c10.c: Regenerate.
	* generated/unpack_c16.c: Regenerate.
	* generated/unpack_c4.c: Regenerate.
	* generated/unpack_c8.c: Regenerate.
	* generated/unpack_i1.c: Regenerate.
	* generated/unpack_i16.c: Regenerate.
	* generated/unpack_i2.c: Regenerate.
	* generated/unpack_i4.c: Regenerate.
	* generated/unpack_i8.c: Regenerate.
	* generated/unpack_r10.c: Regenerate.
	* generated/unpack_r16.c: Regenerate.
	* generated/unpack_r4.c: Regenerate.
	* generated/unpack_r8.c: Regenerate.

From-SVN: r243846
2016-12-21 10:41:57 +00:00
Janne Blomqvist
7e294024ad Remove unused libgfortran functions
Now that the libgfortran ABI major version has been bumped, we can
remove functions for which the frontend nowadays generates inline
code.

This removes the malloc, free, exponent, fraction, nearest, rrspacing,
spacing, set_exponent and transpose intrinsics. Also the unused
store_exe_path function is removed.

2016-12-19  Janne Blomqvist  <jb@gcc.gnu.org>

	* Makefile.am: Remove exponent, fraction, nearest, rrspacing,
	set_exponent, spacing, transpose, malloc, transpose_generic.
	* Makefile.in: Regenerate.
	* generated/exponent_r10.c: Remove.
	* generated/exponent_r16.c: Remove.
	* generated/exponent_r4.c: Remove.
	* generated/exponent_r8.c: Remove.
	* generated/fraction_r10.c: Remove.
	* generated/fraction_r16.c: Remove.
	* generated/fraction_r4.c: Remove.
	* generated/fraction_r8.c: Remove.
	* generated/nearest_r10.c: Remove.
	* generated/nearest_r16.c: Remove.
	* generated/nearest_r4.c: Remove.
	* generated/nearest_r8.c: Remove.
	* generated/rrspacing_r10.c: Remove.
	* generated/rrspacing_r16.c: Remove.
	* generated/rrspacing_r4.c: Remove.
	* generated/rrspacing_r8.c: Remove.
	* generated/set_exponent_r10.c: Remove.
	* generated/set_exponent_r16.c: Remove.
	* generated/set_exponent_r4.c: Remove.
	* generated/set_exponent_r8.c: Remove.
	* generated/spacing_r10.c: Remove.
	* generated/spacing_r16.c: Remove.
	* generated/spacing_r4.c: Remove.
	* generated/spacing_r8.c: Remove.
	* generated/transpose_c10.c: Remove.
	* generated/transpose_c16.c: Remove.
	* generated/transpose_c4.c: Remove.
	* generated/transpose_c8.c: Remove.
	* generated/transpose_i16.c: Remove.
	* generated/transpose_i4.c: Remove.
	* generated/transpose_i8.c: Remove.
	* generated/transpose_r10.c: Remove.
	* generated/transpose_r16.c: Remove.
	* generated/transpose_r4.c: Remove.
	* generated/transpose_r8.c: Remove.
	* gfortran.map: Remove exponent, fraction, nearest, rrspacing,
	set_exponent, spacing, transpose, malloc, free, transpose_generic,
	store_exe_path.
	* intrinsics/malloc.c: Remove.
	* intrinsics/transpose_generic.c: Remove.
	* libgfortran.h (store_exe_path): Remove.
	* m4/exponent.m4: Remove.
	* m4/fraction.m4: Remove.
	* m4/nearest.m4: Remove.
	* m4/rrspacing.m4: Remove.
	* m4/set_exponent.m4: Remove.
	* m4/spacing.m4: Remove.
	* m4/transpose.m4: Remove.
	* runtime/main.c (store_exe_path): Remove.

From-SVN: r243799
2016-12-19 17:32:17 +02:00
Fritz Reese
0ef33d4462 New I/O specifiers CARRIAGECONTROL, READONLY, SHARE with -fdec.
gcc/fortran/
	* gfortran.texi: Document.
	* frontend-passes.c (gfc_code_walker): Add SHARE and CARRIAGECONTROL.
	* io.c (gfc_free_open, gfc_resolve_open, gfc_match_open): Ditto.
	* gfortran.h (gfc_open): Add SHARE, CARRIAGECONTROL, and READONLY.
	* io.c (io_tag, match_open_element): Ditto.
	* ioparm.def: Ditto.
	* trans-io.c (gfc_trans_open): Ditto.
	* io.c (match_dec_etag, match_dec_ftag): New functions.

	libgfortran/io/
	* libgfortran.h (IOPARM_OPEN_HAS_READONLY, IOPARM_OPEN_HAS_SHARE,
	IOPARM_OPEN_HAS_CC): New for READONLY, SHARE, and CARRIAGECONTROL.
	* close.c (st_close): Support READONLY.
	* io.h (st_parameter_open, unit_flags): Support SHARE, CARRIAGECONTROL,
	and READONLY.
	* open.c (st_open): Ditto.
	* transfer.c (data_transfer_init): Ditto.
	* io.h (st_parameter_dt): New member 'cc' for CARRIAGECONTROL.
	* write.c (write_check_cc, write_cc): New functions for CARRIAGECONTROL.
	* transfer.c (next_record_cc): Ditto.
	* file_pos.c (st_endfile): Support SHARE and CARRIAGECONTROL.
	* io.h (st_parameter_inquire): Ditto.
	* open.c (edit_modes, new_unit): Ditto.
	* inquire.c (inquire_via_unit, inquire_via_filename): Ditto.
	* io.h (unit_share, unit_cc, cc_fortran, IOPARM_INQUIRE_HAS_SHARE,
	IOPARM_INQUIRE_HAS_CC): New for SHARE and CARRIAGECONTROL.
	* open.c (share_opt, cc_opt): Ditto.
	* read.c (read_x): Support CARRIAGECONTROL.
	* transfer.c (read_sf, next_record_r, next_record_w): Ditto.
	* write.c (list_formatted_write_scalar, write_a): Ditto.
	* unix.h (close_share): New prototype.
	* unix.c (open_share, close_share): New functions to handle SHARE.
	* unix.c (open_external): Handle READONLY. Call open_share.
	* close.c (st_close): Call close_share.

	gcc/testsuite/
	* dec_io_1.f90: New test.
        * dec_io_2.f90: New test.
        * dec_io_3.f90: New test.
        * dec_io_4.f90: New test.
        * dec_io_5.f90: New test.
        * dec_io_6.f90: New test.

From-SVN: r241550
2016-10-26 12:11:44 +00:00
Jakub Jelinek
818ab71a41 Update copyright years.
From-SVN: r232055
2016-01-04 15:30:50 +01:00
Janne Blomqvist
71cda9cac8 PR 53379 Print backtrace on error termination.
2015-09-05  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/53379
	* libgfortran.h (exit_error): New prototype.
	* runtime/error.c (exit_error): New function.
	(os_error): Call exit_error instead of exit.
	(runtime_error): Likewise.
	(runtime_error_at): Likewise.
	(internal_error): Likewise.
	(generate_error): Likewise.
	(notify_std): Likewise.
	* runtime/stop.c (error_stop_string): Likewise.
	(error_stop_numeric): Likewise.

From-SVN: r227503
2015-09-05 01:17:11 +03:00
Janne Blomqvist
1b0b9fcb92 PR 67414 Better diagnostics on backtrace failure, gf_strerror bugfix
2015-09-02  Janne Blomqvist  <jb@gcc.gnu.org>

	PR libfortran/67414
	* io/write.c (gfc_itoa): Move to runtime/string.c.
	* libgfortran.h (show_backtrace): Make arg bool.
	(gfc_itoa): New prototype.
	* runtime/backtrace.c (struct mystate): Change type of try_simple
	field, add in_signal_handler field.
	(error_callback): Print out error number, or if not in a signal
	handler, the error message.
	(show_backtrace): Change type of arg, change initialization of
	struct mystate.
	(backtrace): Call show_backtrace with correct arg type.
	* runtime/compile_options.c (backtrace_handler): Call with correct
	arg type.
	* runtime/error.c (sys_abort): Likewise.
	(gf_strerror): Handle newlocale() failure.
	* runtime/string.c (gfc_itoa): Function moved here from
	io/write.c.

From-SVN: r227404
2015-09-02 17:51:40 +03:00