aboutsummaryrefslogtreecommitdiff
path: root/libgfortran/intrinsics
AgeCommit message (Collapse)AuthorFilesLines
2023-02-27Fortran: Eliminate nuisance warnings by initializing.Jerry DeLisle3-0/+9
Set sstride[0] and mstride[0] to zero, eliminating some warnings. libgfortran/ChangeLog: * generated/pack_c10.c (pack_c10): Regenerated. * generated/pack_c16.c (pack_c16): Regenerated. * generated/pack_c17.c (pack_c17): Regenerated. * generated/pack_c4.c (pack_c4): Regenerated. * generated/pack_c8.c (pack_c8): Regenerated. * generated/pack_i1.c (pack_i1): Regenerated. * generated/pack_i16.c (pack_i16): Regenerated. * generated/pack_i2.c (pack_i2): Regenerated. * generated/pack_i4.c (pack_i4): Regenerated. * generated/pack_i8.c (pack_i8): Regenerated. * generated/pack_r10.c (pack_r10): Regenerated. * generated/pack_r16.c (pack_r16): Regenerated. * generated/pack_r17.c (pack_r17): Regenerated. * generated/pack_r4.c (pack_r4): Regenerated. * generated/pack_r8.c (pack_r8): Regenerated. * generated/spread_c10.c (spread_c10): Regenerated. * generated/spread_c16.c (spread_c16): Regenerated. * generated/spread_c17.c (spread_c17): Regenerated. * generated/spread_c4.c (spread_c4): Regenerated. * generated/spread_c8.c (spread_c8): Regenerated. * generated/spread_i1.c (spread_i1): Regenerated. * generated/spread_i16.c (spread_i16): Regenerated. * generated/spread_i2.c (spread_i2): Regenerated. * generated/spread_i4.c (spread_i4): Regenerated. * generated/spread_i8.c (spread_i8): Regenerated. * generated/spread_r10.c (spread_r10): Regenerated. * generated/spread_r16.c (spread_r16): Regenerated. * generated/spread_r17.c (spread_r17): Regenerated. * generated/spread_r4.c (spread_r4): Regenerated. * generated/spread_r8.c (spread_r8): Regenerated. * intrinsics/execute_command_line.c (execute_command_line_i4), (execute_command_line_i8): Set estat_initial to zero. * intrinsics/pack_generic.c (pack_internal): Set sstride[0] and mstride[0] to zero. * intrinsics/spread_generic.c (spread_internal): Set sstride[0]. * m4/pack.m4: Set sstride[0] and mstride[0]. * m4/spread.m4: Set sstride[0].
2023-01-18libfortran: Fix execute_command_line for WindowsTobias Burnus1-0/+5
On Windows, 'system' is called - that fails with -1 if the command interpreter could not be started; on POSIX systems, if the child process could not be started by the shell, exit(127)/_exit(127) is called/returned. On Windows, cmd.exe (and also the PowerShell) return errorlevel 9009. libgfortran/ChangeLog: * intrinsics/execute_command_line.c (execute_command_line): On Windows, regard system()'s return value of 9009 as EXEC_INVALIDCOMMAND.
2023-01-16Update copyright years.Jakub Jelinek66-66/+66
2023-01-07Always define `WIN32_LEAN_AND_MEAN` before <windows.h>LIU Hao1-0/+1
Recently, mingw-w64 has got updated <msxml.h> from Wine which is included indirectly by <windows.h> if `WIN32_LEAN_AND_MEAN` is not defined. The `IXMLDOMDocument` class has a member function named `abort()`, which gets affected by our `abort()` macro in "system.h". `WIN32_LEAN_AND_MEAN` should, nevertheless, always be defined. This can exclude 'APIs such as Cryptography, DDE, RPC, Shell, and Windows Sockets' [1], and speed up compilation of these files a bit. [1] https://learn.microsoft.com/en-us/windows/win32/winprog/using-the-windows-headers gcc/ PR middle-end/108300 * config/xtensa/xtensa-dynconfig.c: Define `WIN32_LEAN_AND_MEAN` before <windows.h>. * diagnostic-color.cc: Likewise. * plugin.cc: Likewise. * prefix.cc: Likewise. gcc/ada/ PR middle-end/108300 * adaint.c: Define `WIN32_LEAN_AND_MEAN` before `#include <windows.h>`. * cio.c: Likewise. * ctrl_c.c: Likewise. * expect.c: Likewise. * gsocket.h: Likewise. * mingw32.h: Likewise. * mkdir.c: Likewise. * rtfinal.c: Likewise. * rtinit.c: Likewise. * seh_init.c: Likewise. * sysdep.c: Likewise. * terminals.c: Likewise. * tracebak.c: Likewise. gcc/jit/ PR middle-end/108300 * jit-w32.h: Define `WIN32_LEAN_AND_MEAN` before <windows.h>. libatomic/ PR middle-end/108300 * config/mingw/lock.c: Define `WIN32_LEAN_AND_MEAN` before <windows.h>. libffi/ PR middle-end/108300 * src/aarch64/ffi.c: Define `WIN32_LEAN_AND_MEAN` before <windows.h>. libgcc/ PR middle-end/108300 * config/i386/enable-execute-stack-mingw32.c: Define `WIN32_LEAN_AND_MEAN` before <windows.h>. * libgcc2.c: Likewise. * unwind-generic.h: Likewise. libgfortran/ PR middle-end/108300 * intrinsics/sleep.c: Define `WIN32_LEAN_AND_MEAN` before <windows.h>. libgomp/ PR middle-end/108300 * config/mingw32/proc.c: Define `WIN32_LEAN_AND_MEAN` before <windows.h>. libiberty/ PR middle-end/108300 * make-temp-file.c: Define `WIN32_LEAN_AND_MEAN` before <windows.h>. * pex-win32.c: Likewise. libssp/ PR middle-end/108300 * ssp.c: Define `WIN32_LEAN_AND_MEAN` before <windows.h>. libstdc++-v3/ PR middle-end/108300 * src/c++11/system_error.cc: Define `WIN32_LEAN_AND_MEAN` before <windows.h>. * src/c++11/thread.cc: Likewise. * src/c++17/fs_ops.cc: Likewise. * src/filesystem/ops.cc: Likewise. libvtv/ PR middle-end/108300 * vtv_malloc.cc: Define `WIN32_LEAN_AND_MEAN` before <windows.h>. * vtv_rts.cc: Likewise. * vtv_utils.cc: Likewise.
2022-06-28fortran, libgfortran: Avoid using libquadmath for glibc 2.26+Jakub Jelinek6-19/+48
As mentioned by Joseph in PR105101, glibc 2.26 or later has on x86 (both -m32/-m64), powerpc64le, ia64 and mips support for *f128 math/complex APIs plus strtof128 and strfromf128, and these APIs allow us to avoid libquadmath for Fortran purposes on these architectures, replace *q math/complex APIs, strtof128 instead of strtoflt128 and, while strfromf128 unfortunately isn't a perfect replacement to quadmath_snprintf, it can be made to work. The advantage of this is that when configured against such glibcs (2.26 is now almost 5 years old), we can avoid linking against an extra shared library and the math support in glibc is maintained better than libquadmath. We need both a compiler change (so that for glibc 2.26+ it uses *f128 APIs instead of *q) and library change. The above mentioned problem with strfromf128 is that the strfrom* functions are severely restricted versions of snprintf. In libgfortran, we handle !isfinite differently and just use snprintf/quadmath_snprintf for %+-#.*{L,Q}{f,e} printing. strfrom* doesn't allow +, -, # modifiers and it only supports .34 or similar precision, not .* . The L/Q etc. letters are omitted. The + is there to force + sign at the start if it is positive. Workaround in the patch is to add the + at the start manually for !signbit (val). The - (left alignment instead of right) I don't understand why we need it, when minimum field width isn't specified (for strfrom* can't be specified), no padding is ever added anywhere I believe. The # is to force adding . - workaround is to search for first . or e or '\0' character, if it is '\0', just append ., if it is e, insert . before e and memmove the rest (which is just a few bytes, e, +/- and at most a few digits) one byte later. The .* case is handled by creating the format string for strfrom* by snprintf into a temporary buffer. As requested, this patch also switches from using __float128 type in libgfortran to _Float128 which is equivalent on all arches that support __float128. The change is done in a backwards compatible change, when GCC is configured against glibc 2.26 or newer, libgfortran.so.5 itself doesn't link against -lquadmath nor uses any libquadmath APIs, libgfortran.a doesn't use any libquadmath APIs either. User programs and libraries when being linked by gfortran driver are linked against -lgfortran and -lquadmath, but the latter only in the --as-needed linker mode, which means it needs to be around during linking and will be linked in if there are any calls to math/complex functions with real(kind=16) or complex(kind=16) in compilation units compiled by older versions of gcc, but if either user code doesn't call those math/complex functions for the largest supported kind, or the code is recompiled by gcc with this change in, libquadmath won't be linked in. 2022-06-28 Jakub Jelinek <jakub@redhat.com> gcc/fortran/ * gfortran.h (gfc_real_info): Add use_iec_60559 bitfield. * trans-types.h (gfc_real16_use_iec_60559): Declare. * trans-types.cc (gfc_real16_use_iec_60559): Define. (gfc_init_kinds): When building powerpc64le-linux libgfortran on glibc 2.26 to 2.31, set gfc_real16_use_iec_60559 and use_iec_60559. (gfc_build_real_type): Set gfc_real16_use_iec_60559 and use_iec_60559 on glibc 2.26 or later. * trans-intrinsic.cc (gfc_build_intrinsic_lib_fndecls): Adjust comment. Handle gfc_real16_use_iec_60559. (gfc_get_intrinsic_lib_fndecl): Handle use_iec_60559. libgfortran/ * configure.ac: Check for strtof128 and strfromf128. Check for math and complex *f128 functions. Set have_iec_60559_libc_support to yes if *f128 support is around, for --enable-libquadmath-support default to "default" rather than yes if have_iec_60559_libc_support is yes. * acinclude.m4 (LIBGFOR_CHECK_FLOAT128): Test _Float128/_Complex _Float128 rather than __float128 and _Complex float __attribute__((mode(TC))). If libquadmath support is defaulted and have_iec_60559_libc_support is yes, define and subst USE_IEC_60559. Remove unused LIBGFOR_BUILD_QUAD conditional. * Makefile.am (kinds.h): Pass @USE_IEC_60559@ as an extra mk-kinds-h.sh argument. * mk-kinds-h.sh: Accept 4th use_iec_60559 argument. Use _Float128/_Complex _Float128 types instead of __float128 and _Complex float __attribute__((mode(TC))), and if use_iec_60559 is yes, use f128 suffix instead of q and define GFC_REAL_16_USE_IEC_60559. * kinds-override.h: Use _Float128/_Complex _Float128 types instead of __float128 and _Complex float __attribute__((mode(TC))), if USE_IEC_60559 is defined, use f128 suffixes instead of q and define GFC_REAL_17_USE_IEC_60559. * libgfortran.h: Don't include quadmath_weak.h if USE_IEC_60559 is defined. (GFC_REAL_16_INFINITY, GFC_REAL_16_QUIET_NAN): Define for GFC_REAL_16_USE_IEC_60559 differently. * caf/single.c (convert_type): Use _Float128/_Complex _Float128 instead of __float128 and _Complex float __attribute__((mode(TC))). For HAVE_GFC_REAL_10 when HAVE_GFC_REAL_16 isn't defined use _Complex long double instead of long double. * ieee/issignaling_fallback.h (ieee854_float128_shape_type): Use _Float128 instead of __float128. (__issignalingf128): Change argument type to _Float128. (issignaling): Use _Float128 instead of __float128 in _Generic. * intrinsics/cshift0.c (cshift0): Use _Float128 instead of __float128 in a comment. Fix a comment typo, logn double -> long double. * intrinsics/erfc_scaled.c (_THRESH, _M_2_SQRTPI, _INF, _ERFC, _EXP): Use different definitions if GFC_REAL_16_USE_IEC_60559. (_THRESH, _M_2_SQRTPI): Use GFC_REAL_17_LITERAL macro. (_ERFC, _EXP): Use different definitions if GFC_REAL_17_USE_IEC_60559. * intrinsics/spread_generic.c (spread, spread_scalar): Use _Float128 instead of __float128 in a comment. Fix a comment typo, logn double -> long double. * intrinsics/trigd.c (ENABLE_SIND, ENABLE_COSD, ENABLE_TAND): Handle GFC_REAL_16_USE_IEC_60559. * intrinsics/pack_generic.c (pack): Use _Float128 instead of __float128 in a comment. Fix a comment typo, logn double -> long double. * intrinsics/unpack_generic.c (unpack1, unpack0): Likewise. * runtime/in_pack_generic.c (internal_pack): Likewise. * runtime/in_unpack_generic.c (internal_unpack): Likewise. * io/read.c (convert_real, convert_infnan): Handle GFC_REAL_16_USE_IEC_60559 and GFC_REAL_17_USE_IEC_60559. * io/transfer128.c (tmp1, tmp2): Don't define if libquadmath isn't needed. * io/write_float.def (gfor_strfromf128): New function. (DTOA2Q, FDTOA2Q): Define differently if GFC_REAL_16_USE_IEC_60559 or GFC_REAL_17_USE_IEC_60559. * m4/mtype.m4: Use different suffix if GFC_REAL_16_USE_IEC_60559 or GFC_REAL_17_USE_IEC_60559. * config.h.in: Regenerated. * configure: Regenerated. * Makefile.in: Regenerated. * generated/bessel_r16.c: Regenerated. * generated/bessel_r17.c: Regenerated. * generated/norm2_r16.c: Regenerated. * generated/norm2_r17.c: Regenerated.
2022-01-11libgfortran: Avoid using libquadmath APIs on powerpc64le on glibc 2.32+Jakub Jelinek2-0/+12
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-11fortran, libgfortran: Add remaining missing *_r17 symbolsJakub Jelinek3-40/+242
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-03Update copyright years.Jakub Jelinek66-66/+66
2021-12-16Fix timezone handling near year boundariesFrancois-Xavier Coudert2-14/+24
PR libfortran/98507 libgfortran/ChangeLog: * intrinsics/time_1.h: Prefer clock_gettime() over gettimeofday(). * intrinsics/date_and_time.c: Fix timezone wrapping. gcc/testsuite/ChangeLog: * gfortran.dg/date_and_time_1.f90: New file.
2021-12-14Fortran: PACK intrinsic should not try to read from zero-sized arrayHarald Anlauf1-0/+9
libgfortran/ChangeLog: PR libfortran/103634 * intrinsics/pack_generic.c (pack_internal): Handle case when the array argument of PACK has one or more extents of size zero to avoid invalid reads. gcc/testsuite/ChangeLog: PR libfortran/103634 * gfortran.dg/intrinsic_pack_6.f90: New test.
2021-09-27Fortran: Fix assumed-size to assumed-rank passing [PR94070]Tobias Burnus1-0/+4
This code inlines the size0 and size1 libgfortran calls, the former is still used by libgfortan itself (and by old code). Besides permitting more optimizations, it also permits to handle assumed-rank dummies better: If the dummy argument is a nonpointer/nonallocatable, an assumed-size actual arg is repesented by having ubound == -1 for the last dimension. However, for allocatable/pointers, this value can also exist. Hence, the dummy arg attr has to be honored. For that reason, when calling an assumed-rank procedure with nonpointer, nonallocatable dummy arguments, the bounds have to be updated to avoid the case ubound == -1 for the last dimension. PR fortran/94070 gcc/fortran/ChangeLog: * trans-array.c (gfc_tree_array_size): New function to find size inline (whole array or one dimension). (array_parameter_size): Use it, take stmt_block as arg. (gfc_conv_array_parameter): Update call. * trans-array.h (gfc_tree_array_size): Add prototype. * trans-decl.c (gfor_fndecl_size0, gfor_fndecl_size1): Remove these global vars. (gfc_build_intrinsic_function_decls): Remove their initialization. * trans-expr.c (gfc_conv_procedure_call): Update bounds of pointer/allocatable actual args to nonallocatable/nonpointer dummies to be one based. * trans-intrinsic.c (gfc_conv_intrinsic_shape): Fix case for assumed rank with allocatable/pointer dummy. (gfc_conv_intrinsic_size): Update to use inline function. * trans.h (gfor_fndecl_size0, gfor_fndecl_size1): Remove var decl. libgfortran/ChangeLog: * intrinsics/size.c (size0, size1): Comment that now not used by newer compiler code. libgomp/ChangeLog: * testsuite/libgomp.oacc-fortran/privatized-ref-2.f90: Update expected dg-note output. gcc/testsuite/ChangeLog: * gfortran.dg/c-interop/cf-out-descriptor-6.f90: Remove xfail. * gfortran.dg/c-interop/size.f90: Remove xfail. * gfortran.dg/intrinsic_size_3.f90: Update scan-tree-dump-times. * gfortran.dg/transpose_optimization_2.f90: Likewise. * gfortran.dg/size_optional_dim_1.f90: Add scan-tree-dump-not. * gfortran.dg/assumed_rank_22.f90: New test. * gfortran.dg/assumed_rank_22_aux.c: New test.
2021-09-26Fortran: Fix associated intrinsic with assumed rank [PR101334]Tobias Burnus1-1/+2
ASSOCIATE (ptr, tgt) takes as first argument also an assumed-rank array; however, using it together with a tgt (required to be non assumed rank) had issues for both scalar and nonscalar tgt. PR fortran/101334 gcc/fortran/ChangeLog: * trans-intrinsic.c (gfc_conv_associated): Support assumed-rank 'pointer' with scalar/array 'target' argument. libgfortran/ChangeLog: * intrinsics/associated.c (associated): Also check for same rank. gcc/testsuite/ChangeLog: * gfortran.dg/associated_assumed_rank.f90: New test.
2021-06-08Fix "tailing" typo.Martin Liska1-1/+1
gcc/fortran/ChangeLog: * intrinsic.texi: Fix typo. * trans-expr.c (gfc_trans_pointer_assignment): Likewise. gcc/ChangeLog: * genautomata.c (create_automata): Fix typo. libgfortran/ChangeLog: * intrinsics/chmod.c (chmod_internal): Fix typo. * io/transfer.c (read_sf): Likewise. libquadmath/ChangeLog: * libquadmath.texi: Fix typo. gcc/testsuite/ChangeLog: * gcc.dg/format/strfmon-1.c: Fix typo. * gfortran.dg/char4-subscript.f90: Likewise.
2021-06-05Fortran: Fix some issues with pointers to character.José Rui Faustino de Sousa1-1/+1
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-05-22Steve Kargl <kargl@gcc.gnu.org>Andre Vehreschild1-54/+60
PR fortran/98301 - random_init() is broken Correct implementation of random_init() when -fcoarray=lib is given. gcc/fortran/ChangeLog: PR fortran/98301 * trans-decl.c (gfc_build_builtin_function_decls): Move decl. * trans-intrinsic.c (conv_intrinsic_random_init): Use bool for lib-call of caf_random_init instead of logical (4-byte). * trans.h: Add tree var for random_init. libgfortran/ChangeLog: PR fortran/98301 * caf/libcaf.h (_gfortran_caf_random_init): New function. * caf/single.c (_gfortran_caf_random_init): New function. * gfortran.map: Added fndecl. * intrinsics/random_init.f90: Implement random_init.
2021-05-05libgfortran/intrinsics/chmod.c: Silence unused var warningTobias Burnus1-1/+4
libgfortran/ChangeLog: * intrinsics/chmod.c (chmod_internal): Only declare mode_mask var if HAVE_UMASK.
2021-01-04Update copyright years.Jakub Jelinek66-66/+66
2020-11-21Darwin, libgfortran : Do not use environ directly from the library.Iain Sandoe1-0/+5
On macOS / Darwin, the environ variable can be used directly in the code of an executable, but cannot be used in the code of a shared library (i.e. libgfortran.dylib), in this case. In such cases, the function _NSGetEnviron should be called to get the address of 'environ'. libgfortran/ChangeLog: * intrinsics/execute_command_line.c (environ): Use _NSGetEnviron to get the environment pointer on Darwin.
2020-10-30PR libfortran/97581 - clean up size calculation of random generator stateHarald Anlauf1-15/+17
The random number generator internal state may be saved to/restored from an array of integers. Clean up calculation of needed number of elements to avoid redefiniton of auxiliary macro SZ. libgfortran/ChangeLog: * intrinsics/random.c (SZ_IN_INT_4): Define size of state in int32_t. (SZ_IN_INT_8): Define size of state in int64_t. (SZ): Remove. (random_seed_i4): Use size SZ_IN_INT_4 instead of SZ. (random_seed_i8): Use size SZ_IN_INT_8 instead of SZ.
2020-08-24Fortran : get_environment_variable runtime error PR96486Mark Eggleston1-5/+2
Runtime error occurs when the type of the value argument is character(0): "Zero-length string passed as value...". The status argument, intent(out), will contain -1 if the value of the environment is too large to fit in the value argument, this is the case if the type is character(0) so there is no reason to produce a runtime error if the value argument is zero length. 2020-08-24 Mark Eggleston <markeggleston@gcc.gnu.org> libgfortran/ PR fortran/96486 * intrinsics/env.c: If value_len is > 0 blank the string. Copy the result only if its length is > 0. 2020-08-24 Mark Eggleston <markeggleston@gcc.gnu.org> gcc/testsuite/ PR fortran/96486 * gfortran.dg/pr96486.f90: New test.
2020-04-23Protect the trigd functions in libgfortran from unavailable math functions.Fritz Reese3-117/+310
libgfortran/ChangeLog: 2020-04-22 Fritz Reese <foreese@gcc.gnu.org> PR libfortran/94694 PR libfortran/94586 * intrinsics/trigd.c, intrinsics/trigd_lib.inc, intrinsics/trigd.inc: Guard against unavailable math functions. Use suffixes from kinds.h based on the REAL kind. gcc/fortran/ChangeLog: 2020-04-22 Fritz Reese <foreese@gcc.gnu.org> * trigd_fe.inc: Use mpfr to compute cosd(30) rather than a host- precision floating point literal based on an invalid macro.
2020-04-22libgfortran: Provide some further math library fallbacks [PR94694]Jakub Jelinek1-0/+77
The following patch provides some further math library fallbacks. fmaf can be implemented using fma if available, fma and fmal can use x * y + z as fallback, it is not perfect, but e.g. glibc on various arches has been using that as fallback for many years, and copysign/copysignl/fabs/fabsl can be implemented using corresponding __builtin_* if we make sure that gcc expands it inline instead of using a library call (these days it is expanded inline on most targets). 2020-04-22 Jakub Jelinek <jakub@redhat.com> PR libfortran/94694 PR libfortran/94586 * configure.ac: Add math func checks for fmaf, fma and fmal. Add HAVE_INLINE_BUILTIN_COPYSIGN check. * c99_protos.h (copysign, fmaf, fma, fmal): Provide fallback prototypes. (HAVE_COPYSIGN, HAVE_FMAF, HAVE_FMA, HAVE_FMAL): Define if not defined and fallback version is provided. * intrinsics/c99_functions.c (copysign, fmaf, fma, fmal): Provide fallback implementations if possible * configure: Regenerated. * config.h.in: Regenerated. * math.m4 (GCC_CHECK_MATH_INLINE_BUILTIN_FALLBACK1, GCC_CHECK_MATH_INLINE_BUILTIN_FALLBACK2): New.
2020-04-07Fix PR fortran/93871 and re-implement degree-valued trigonometric intrinsics.Fritz Reese3-0/+816
2020-04-01 Fritz Reese <foreese@gcc.gnu.org> Steven G. Kargl <kargl@gcc.gnu.org> gcc/fortran/ChangeLog PR fortran/93871 * gfortran.h (GFC_ISYM_ACOSD, GFC_ISYM_ASIND, GFC_ISYM_ATAN2D, GFC_ISYM_ATAND, GFC_ISYM_COSD, GFC_ISYM_COTAND, GFC_ISYM_SIND, GFC_ISYM_TAND): New. * intrinsic.c (add_functions): Remove check for flag_dec_math. Give degree trig functions simplification and name resolution functions (e.g, gfc_simplify_atrigd () and gfc_resolve_atrigd ()). (do_simplify): Remove special casing of degree trig functions. * intrinsic.h (gfc_simplify_acosd, gfc_simplify_asind, gfc_simplify_atand, gfc_simplify_cosd, gfc_simplify_cotand, gfc_simplify_sind, gfc_simplify_tand, gfc_resolve_trigd2): Add new prototypes. (gfc_simplify_atrigd, gfc_simplify_trigd, gfc_resolve_cotan, resolve_atrigd): Remove prototypes of deleted functions. * iresolve.c (is_trig_resolved, copy_replace_function_shallow, gfc_resolve_cotan, get_radians, get_degrees, resolve_trig_call, gfc_resolve_atrigd, gfc_resolve_atan2d): Delete functions. (gfc_resolve_trigd, gfc_resolve_trigd2): Resolve to library functions. * simplify.c (rad2deg, deg2rad, gfc_simplify_acosd, gfc_simplify_asind, gfc_simplify_atand, gfc_simplify_atan2d, gfc_simplify_cosd, gfc_simplify_sind, gfc_simplify_tand, gfc_simplify_cotand): New functions. (gfc_simplify_atan2): Fix error message. (simplify_trig_call, gfc_simplify_trigd, gfc_simplify_atrigd, radians_f): Delete functions. * trans-intrinsic.c: Add LIB_FUNCTION decls for sind, cosd, tand. (rad2deg, gfc_conv_intrinsic_atrigd, gfc_conv_intrinsic_cotan, gfc_conv_intrinsic_cotand, gfc_conv_intrinsic_atan2d): New functions. (gfc_conv_intrinsic_function): Handle ACOSD, ASIND, ATAND, COTAN, COTAND, ATAN2D. * trigd_fe.inc: New file. Included by simplify.c to implement simplify_sind, simplify_cosd, simplify_tand with code common to the libgfortran implementation. gcc/testsuite/ChangeLog PR fortran/93871 * gfortran.dg/dec_math.f90: Extend coverage to real(10) and real(16). * gfortran.dg/dec_math_2.f90: New test. * gfortran.dg/dec_math_3.f90: Likewise. * gfortran.dg/dec_math_4.f90: Likewise. * gfortran.dg/dec_math_5.f90: Likewise. libgfortran/ChangeLog PR fortran/93871 * Makefile.am, Makefile.in: New make rule for intrinsics/trigd.c. * gfortran.map: New routines for {sind, cosd, tand}X{r4, r8, r10, r16}. * intrinsics/trigd.c, intrinsics/trigd_lib.inc, intrinsics/trigd.inc: New files. Defines native degree-valued trig functions.
2020-01-01Update copyright years.Jakub Jelinek63-63/+63
From-SVN: r279813
2019-09-05Improve PRNG jumping when using threadsJanne Blomqvist1-27/+19
Currently, when a new thread needs to use the RANDOM_NUMBER intrinsic, the per-thread PRNG state is initialized by copying the master state and then jumping forwards N*2**128 entries in the stream so that the PRNG streams for different threads don't alias each other, where N is the number of threads that have so far initialized the PRNG. With this patch the master state itself is jumped forwards once each time a new thread initializes the PRNG, thus obviating the need to jump through all the N-1 previous streams. Effectively turning an O(N) algorithm into an O(1) one. Regtested on x86_64-pc-linux-gnu. libgfortran/ChangeLog: 2019-09-05 Janne Blomqvist <jb@gcc.gnu.org> * intrinsics/random.c (master_init): Replace with master_state.init. (njumps): Remove variable. (master_state): Make instance of struct prng_state. (init_rand_state): When jumping, update the master_state once instead of keeping track of how many jumps need to be done. (SZU64): Modify to handle new master_state. (SZ): Likewise. (random_seed_i4): Likewise. (random_seed_i8): Likewise. From-SVN: r275397
2019-08-13PR fortran/91414 Bugfix for previous commitJanne Blomqvist1-1/+4
Correctly fill master_seed from os_seed. From-SVN: r274365
2019-08-13PR fortran/91414: Improved PRNGJanne Blomqvist1-114/+99
Update the PRNG from xorshift1024* to xoshiro256** by the same author. For details see http://prng.di.unimi.it/ and the paper at https://arxiv.org/abs/1805.01407 Also the seeding is slightly improved, by reading only 8 bytes from the operating system and using the simple splitmix64 PRNG to fill in the rest of the PRNG state (as recommended by the xoshiro author), instead of reading the entire state from the OS. Regtested on x86_64-pc-linux-gnu, Ok for trunk? gcc/fortran/ChangeLog: 2019-08-13 Janne Blomqvist <jb@gcc.gnu.org> PR fortran/91414 * check.c (gfc_check_random_seed): Reduce seed_size. * intrinsic.texi (RANDOM_NUMBER): Update to match new PRNG. gcc/testsuite/ChangeLog: 2019-08-13 Janne Blomqvist <jb@gcc.gnu.org> PR fortran/91414 * gfortran.dg/random_seed_1.f90: Update to match new seed size. libgfortran/ChangeLog: 2019-08-13 Janne Blomqvist <jb@gcc.gnu.org> PR fortran/91414 * intrinsics/random.c (prng_state): Update state struct. (master_state): Update to match new size. (get_rand_state): Update to match new PRNG. (rotl): New function. (xorshift1024star): Replace with prng_next. (prng_next): New function. (jump): Update for new PRNG. (lcg_parkmiller): Replace with splitmix64. (splitmix64): New function. (getosrandom): Fix return value, simplify. (init_rand_state): Use getosrandom only to get 8 bytes, splitmix64 to fill rest of state. (random_r4): Update to new function and struct names. (random_r8): Likewise. (random_r10): Likewise. (random_r16): Likewise. (arandom_r4): Liekwise. (arandom_r8): Likewise. (arandom_r10): Likwewise. (arandom_r16): Likewise. (xor_keys): Reduce size to match new PRNG. (random_seed_i4): Update to new function and struct names, remove special handling of variable p used in previous PRNG. (random_seed_i8): Likewise. From-SVN: r274361
2019-05-19libfortran/90038 Reap dead children when wait=.false.Janne Blomqvist1-0/+25
When using posix_spawn or fork to launch a child process, the parent needs to wait for the child, otherwise the dead child is left as a zombie process. For this purpose one can install a signal handler for SIGCHLD. 2019-05-19 Janne Blomqvist <jb@gcc.gnu.org> PR libfortran/90038 * intrinsics/execute_command_line (sigchld_handler): New function. (execute_command_line): Install handler for SIGCHLD. * configure.ac: Check for presence of sigaction and waitpid. * config.h.in: Regenerated. * configure: Regenerated. Regtested on x86_64-pc-linux-gnu. From-SVN: r271384
2019-05-17libfortran/90038: Use posix_spawn instead of forkJanne Blomqvist1-4/+14
fork() semantics can be problematic. Most unix style OS'es have posix_spawn which can be used to replace fork + exec in many cases. For more information see e.g. https://www.microsoft.com/en-us/research/uploads/prod/2019/04/fork-hotos19.pdf This replaces the one use of fork in libgfortran with posix_spawn. 2019-05-17 Janne Blomqvist <jb@gcc.gnu.org> PR libfortran/90038 * configure.ac (AC_CHECK_FUNCS_ONCE): Check for posix_spawn. * intrinsics/execute_command_line (execute_command_line): Use posix_spawn. * Makefile.in: Regenerated. * config.h.in: Regenerated. * configure: Regenerated. Regtested on x86_64-pc-linux-gnu. From-SVN: r271340
2019-01-07re PR fortran/45424 ([F08] Add IS_CONTIGUOUS intrinsic)Thomas Koenig1-0/+49
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-01Update copyright years.Jakub Jelinek62-62/+62
From-SVN: r267494
2018-12-28re PR libfortran/81984 (NULL string pointer dereferencing forces undefined ↵Steven G. Kargl1-0/+8
behaviour in libgfortran) 2018-12-28 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/81984 * intrinsics/string_intrinsics_inc.c: Placate the sanitizer. From-SVN: r267452
2018-08-14Include <sys/random.h> for getentropy on SolarisRainer Orth1-0/+3
* configure.ac: Check for <sys/random.h>. * configure, config.h.in: Regenerate. * intrinsics/random.c [HAVE_SYS_RANDOM_H]: Include <sys/random.h>. From-SVN: r263543
2018-08-13Use getentropy() for seeding PRNGJanne Blomqvist1-5/+4
The getentropy function, found on Linux, OpenBSD, and recently also FreeBSD, can be used to get random bytes to initialize the PRNG. It is similar to the traditional way of reading from /dev/urandom, but being a system call rather than a special file, it doesn't suffer from problems like running out of file descriptors, or failure when running in a container where /dev/urandom may not be available. Regtested on x86_64-pc-linux-gnu, Ok for trunk? 2018-08-13 Janne Blomqvist <jb@gcc.gnu.org> * configure.ac: Check for getentropy. * intrinsics/random.c (getosrandom): Use getentropy if available. * config.h.in: Regenerated. * configure: Regenerated. From-SVN: r263522
2018-06-01re PR fortran/85816 (nested spread fails with "Integer overflow in ↵Steven G. Kargl2-3/+3
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-01re PR fortran/63570 ([F2018] Implement 13.7.137 RANDOM INIT (REPEATABLE, ↵Steven G. Kargl1-0/+94
IMAGE DISTINCT)) 2018-06-01 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/63570 * check.c (gfc_check_random_init): New function. Check arguments of RANDOM_INIT. * gfortran.h (GFC_ISYM_RANDOM_INIT): New enum token. * intrinsic.c (add_subroutines): Add RANDOM_INIT to list of subroutines. (gfc_check_intrinsic_standard): Introduce Fortran 2018 check. * intrinsic.h: Add prototypes for gfc_check_random_init and gfc_resolve_random_init * intrinsic.texi: Document new intrinsic subprogram. * iresolve.c (gfc_resolve_random_init): Resolve routine name. * trans-decl.c: Declare gfor_fndecl_random_init * trans-intrinsic.c (conv_intrinsic_random_init): New function. Translate call to RANDOM_INIT. (gfc_conv_intrinsic_subroutine): Call it. * trans.h: Declare gfor_fndecl_random_init 2018-06-01 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/63570 * gfortran.dg/random_init_1.f90: New test. * gfortran.dg/random_init_2.f90: New test. * gfortran.dg/random_init_3.f90: New test. * gfortran.dg/random_init_4.f90: New test. * gfortran.dg/random_init_5.f90: New test. * gfortran.dg/random_init_6.f90: New test. 2018-06-01 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/63570 * libgfortran/Makefile.am: Add random_init.f90 to build. * libgfortran/Makefile.in: Regenerated. * libgfortran/gfortran.map: Expose symbol for _gfortran_random_init. * libgfortran/intrinsics/random_init.f90: Implementation. From-SVN: r261075
2018-03-15re PR libfortran/84880 (libgfortran fail to build on aarch64/arm 32bit cross ↵Jakub Jelinek1-3/+3
toolchain) PR libgfortran/84880 * intrinsics/kill.c (kill): Rename to... (PREFIX (kill)): ... this. Use export_proto_np instead of export_proto. From-SVN: r258571
2018-03-14check.c (gfc_check_kill_sub): Remove check for INTEGER(4) or (8).Steven G. Kargl1-39/+12
2018-03-13 Steven G. Kargl <kargl@gcc.gnu.org> * check.c (gfc_check_kill_sub): Remove check for INTEGER(4) or (8). * intrinsic.c (add_functions): Remove reference to gfc_resolve_kill. (add_subroutines): Remove reference to gfc_resolve_kill_sub. * intrinsic.texi: Update documentation. * iresolve.c (gfc_resolve_kill, gfc_resolve_kill_sub): Remove. * trans-decl.c (gfc_build_intrinsic_function_decls): Add gfor_fndecl_kill and gfor_fndecl_kill_sub * trans-intrinsic.c (conv_intrinsic_kill, conv_intrinsic_kill_sub): new functions. (gfc_conv_intrinsic_function): Use conv_intrinsic_kill. (gfc_conv_intrinsic_subroutine): Use conv_intrinsic_kill_sub. * trans.h: Declare gfor_fndecl_kill and gfor_fndecl_kill_sub. 2018-03-13 Steven G. Kargl <kargl@gcc.gnu.org> * libgfortran/gfortran.map: Remove _gfortran_kill_i4, _gfortran_kill_i4_sub, _gfortran_kill_i8, and _gfortran_kill_i8_sub. Add _gfortran_kill and _gfortran_kill_sub. * libgfortran/intrinsics/kill.c: Eliminate _gfortran_kill_i4, _gfortran_kill_i4_sub, _gfortran_kill_i8, and _gfortran_kill_i8_sub. Add _gfortran_kill and _gfortran_kill_sub. From-SVN: r258511
2018-02-12libgfortran.h (GFC_ARRAY_DESCRIPTOR): Remove dimension of descriptor to use ↵Thomas Koenig2-4/+6
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-01-31Use pointer sized array indices.Janne Blomqvist1-16/+11
Using pointer sized variables (e.g. size_t / ptrdiff_t) when the variables are used as array indices allows accessing larger arrays, and can be a slight performance improvement due to no need for sign or zero extending, or masking. Regtested on x86_64-pc-linux-gnu. libgfortran/ChangeLog: 2018-01-31 Janne Blomqvist <jb@gcc.gnu.org> * generated/cshift1_16.c (cshift1): Regenerated. * generated/cshift1_4.c (cshift1): Regenerated. * generated/cshift1_8.c (cshift1): Regenerated. * generated/eoshift1_16.c (eoshift1): Regenerated. * generated/eoshift1_4.c (eoshift1): Regenerated. * generated/eoshift1_8.c (eoshift1): Regenerated. * generated/eoshift3_16.c (eoshift3): Regenerated. * generated/eoshift3_4.c (eoshift3): Regenerated. * generated/eoshift3_8.c (eoshift3): Regenerated. * generated/in_pack_c10.c (internal_pack_c10): Regenerated. * generated/in_pack_c16.c (internal_pack_c16): Regenerated. * generated/in_pack_c4.c (internal_pack_c4): Regenerated. * generated/in_pack_c8.c (internal_pack_c8): Regenerated. * generated/in_pack_i1.c (internal_pack_1): Regenerated. * generated/in_pack_i16.c (internal_pack_16): Regenerated. * generated/in_pack_i2.c (internal_pack_2): Regenerated. * generated/in_pack_i4.c (internal_pack_4): Regenerated. * generated/in_pack_i8.c (internal_pack_8): Regenerated. * generated/in_pack_r10.c (internal_pack_r10): Regenerated. * generated/in_pack_r16.c (internal_pack_r16): Regenerated. * generated/in_pack_r4.c (internal_pack_r4): Regenerated. * generated/in_pack_r8.c (internal_pack_r8): Regenerated. * generated/in_unpack_c10.c (internal_unpack_c10): Regenerated. * generated/in_unpack_c16.c (internal_unpack_c16): Regenerated. * generated/in_unpack_c4.c (internal_unpack_c4): Regenerated. * generated/in_unpack_c8.c (internal_unpack_c8): Regenerated. * generated/in_unpack_i1.c (internal_unpack_1): Regenerated. * generated/in_unpack_i16.c (internal_unpack_16): Regenerated. * generated/in_unpack_i2.c (internal_unpack_2): Regenerated. * generated/in_unpack_i4.c (internal_unpack_4): Regenerated. * generated/in_unpack_i8.c (internal_unpack_8): Regenerated. * generated/in_unpack_r10.c (internal_unpack_r10): Regenerated. * generated/in_unpack_r16.c (internal_unpack_r16): Regenerated. * generated/in_unpack_r4.c (internal_unpack_r4): Regenerated. * generated/in_unpack_r8.c (internal_unpack_r8): Regenerated. * generated/reshape_c10.c (reshape_c10): Regenerated. * generated/reshape_c16.c (reshape_c16): Regenerated. * generated/reshape_c4.c (reshape_c4): Regenerated. * generated/reshape_c8.c (reshape_c8): Regenerated. * generated/reshape_i16.c (reshape_16): Regenerated. * generated/reshape_i4.c (reshape_4): Regenerated. * generated/reshape_i8.c (reshape_8): Regenerated. * generated/reshape_r10.c (reshape_r10): Regenerated. * generated/reshape_r16.c (reshape_r16): Regenerated. * generated/reshape_r4.c (reshape_r4): Regenerated. * generated/reshape_r8.c (reshape_r8): Regenerated. * generated/shape_i1.c (shape_1): Regenerated. * generated/shape_i16.c (shape_16): Regenerated. * generated/shape_i2.c (shape_2): Regenerated. * generated/shape_i4.c (shape_4): Regenerated. * generated/shape_i8.c (shape_8): Regenerated. * generated/spread_c10.c (spread_scalar_c10): Regenerated. * generated/spread_c16.c (spread_scalar_c16): Regenerated. * generated/spread_c4.c (spread_scalar_c4): Regenerated. * generated/spread_c8.c (spread_scalar_c8): Regenerated. * generated/spread_i1.c (spread_scalar_i1): Regenerated. * generated/spread_i16.c (spread_scalar_i16): Regenerated. * generated/spread_i2.c (spread_scalar_i2): Regenerated. * generated/spread_i4.c (spread_scalar_i4): Regenerated. * generated/spread_i8.c (spread_scalar_i8): Regenerated. * generated/spread_r10.c (spread_scalar_r10): Regenerated. * generated/spread_r16.c (spread_scalar_r16): Regenerated. * generated/spread_r4.c (spread_scalar_r4): Regenerated. * generated/spread_r8.c (spread_scalar_r8): Regenerated. * intrinsics/random.c (jump): Use size_t for array index in loop. (getosrandom): Likewise. (arandom_r4): Make n an index_type. (arandom_r8): Likewise. (arandom_r10): Likewise. (arandom_r16): Likewise. (scramble_seed): Use size_t for array index in loop. * m4/cshift1.m4: Make i an index_type. * m4/eoshift1.m4: Likewise. * m4/eoshift3.m4: Likewise. * m4/in_pack.m4: Make n an index_type. * m4/in_unpack.m4: Likewise. * m4/reshape.m4: Make n and dim index_type's. * m4/shape.m4: Make n an index_type. * m4/spread.m4: Likewise, use index_type argument rather than copying to int. * runtime/bounds.c (bounds_ifunction_return): Make n an index_type. * runtime/in_pack_generic.c (internal_pack): Likewise. * runtime/in_unpack_generic.c (internal_unpack): Make n and size index_type's. From-SVN: r257234
2018-01-30re PR fortran/37577 ([meta-bug] change internal array descriptor format for ↵Thomas Koenig4-36/+77
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-25re PR fortran/37577 ([meta-bug] change internal array descriptor format for ↵Paul Thomas2-5/+6
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-07libgfortran.h (GFC_DTYPE_COPY): New macro.Thomas Koenig7-12/+12
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-05PR 78534 Change character length from int to size_tJanne Blomqvist8-28/+29
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-03Update copyright years.Jakub Jelinek61-61/+61
From-SVN: r256169
2017-11-22Make shift argument to eoshift0 and eoshift2 be of type index_typeJanne Blomqvist2-6/+2
Test case that requires 4 GB RAM that exercises eoshift0: program main implicit none integer(1) :: line(2_8**31+10) line = 42 line = eoshift(line, 2_8**31+7) print *, line(1:4) print *, line((ubound(line, 1, kind=8)-4):ubound(line, 1, kind=8)) end program main Before patch: ❯ ./a.out 0 0 0 0 42 42 42 42 42 With patch: ❯ ./a.out 42 42 42 0 0 0 0 0 0 Regtested on x86_64-pc-linux-gnu. libgfortran/ChangeLog: 2017-11-22 Janne Blomqvist <jb@gcc.gnu.org> * intrinsics/eoshift0.c (eoshift0): Make shift an index_type. * intrinsics/eoshift2.c (eoshift2): Make shift an index_type. From-SVN: r255077
2017-11-22PR 83070 Fix -Wsign-compare warningJanne Blomqvist1-1/+1
2017-11-22 Janne Blomqvist <jb@gcc.gnu.org> PR libfortran/83070 * intrinsics/eoshift0.c (eoshift0): Fix -Wsign-compare warning by making a_ex and r_ex index_type instead of size_t. From-SVN: r255045
2017-10-10re PR libfortran/82233 (execute_command_line causes program to stop when ↵Thomas Koenig1-8/+2
command fails (or does not exist)) 2017-10-10 Thomas Koenig <tkoenig@gcc.gnu.org> PR libfortran/82233 * intrinsics/execute_command_line.c (execute_command_line): No call to runtime_error if cmdstat is present. 2017-10-10 Thomas Koenig <tkoenig@gcc.gnu.org> PR libfortran/82233 * gfortran.dg/execute_command_line_3.f90: New test. From-SVN: r253593
2017-07-09eoshift2.c (eoshift2): Use memcpy for innermost copy where possible.Thomas Koenig1-6/+17
2017-06-09 Thomas Koenig <tkoenig@gcc.gnu.org> * intrinsics/eoshift2.c (eoshift2): Use memcpy for innermost copy where possible. * m4/eoshift1.m4 (eoshift1): Likewise. * m4/eoshift3.m4 (eoshift3): Likewise. * 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. 2017-06-09 Thomas Koenig <tkoenig@gcc.gnu.org> * gfortran.dg/eoshift_4.f90: New test. * gfortran.dg/eoshift_5.f90: New test. * gfortran.dg/eoshift_6.f90: New test. From-SVN: r250085
2017-07-02eoshift0.c: For contiguous arrays, use block algorithm.Thomas Koenig1-36/+108
2017-07-02 Thomas Koenig <tkoenig@gcc.gnu.org> * intrinsics/eoshift0.c: For contiguous arrays, use block algorithm. Use memcpy where possible. 2017-07-02 Thomas Koenig <tkoenig@gcc.gnu.org> * gfortran/eoshift_3.f90: New test. From-SVN: r249882