aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
AgeCommit message (Collapse)AuthorFilesLines
2020-11-02Further improve Fortran column location information [PR92793]Thomas Schwinge1-2/+5
Building on top of commit 9c81750c5bedd7883182ee2684a012c6210ebe1d "Fortran] PR 92793 - fix column used for error diagnostic", there is another place where we have to use 'gfc_get_location' returning column-corrected locations. For example, this improves column location information for OMP constructs. gcc/fortran/ PR fortran/92793 * trans.c (gfc_set_backend_locus): Use 'gfc_get_location'. (gfc_restore_backend_locus): Adjust. gcc/testsuite/ PR fortran/92793 * gfortran.dg/goacc/pr92793-1.f90: Adjust.
2020-11-02Fortran: OpenMP - fixes for omp atomic [PR97655]Tobias Burnus1-9/+11
gcc/fortran/ChangeLog: PR fortran/97655 * openmp.c (gfc_match_omp_atomic): Fix mem-order handling; reject specifying update + capture together. gcc/testsuite/ChangeLog: PR fortran/97655 * gfortran.dg/gomp/atomic.f90: Update tree-dump counts; move invalid OMP 5.0 code to ... * gfortran.dg/gomp/atomic-2.f90: ... here; update dg-error. * gfortran.dg/gomp/requires-9.f90: Update tree dump scan.
2020-10-30Fortran: Update omp atomic for OpenMP 5Tobias Burnus7-110/+266
gcc/fortran/ChangeLog: * dump-parse-tree.c (show_omp_clauses): Handle atomic clauses. (show_omp_node): Call it for atomic. * gfortran.h (enum gfc_omp_atomic_op): Add GFC_OMP_ATOMIC_UNSET, remove GFC_OMP_ATOMIC_SEQ_CST and GFC_OMP_ATOMIC_ACQ_REL. (enum gfc_omp_memorder): Replace OMP_MEMORDER_LAST by OMP_MEMORDER_UNSET, add OMP_MEMORDER_SEQ_CST/OMP_MEMORDER_RELAXED. (gfc_omp_clauses): Add capture and atomic_op. (gfc_code): remove omp_atomic. * openmp.c (enum omp_mask1): Add atomic, capture, memorder clauses. (gfc_match_omp_clauses): Match them. (OMP_ATOMIC_CLAUSES): Add. (gfc_match_omp_flush): Update for 'last' to 'unset' change. (gfc_match_omp_oacc_atomic): Removed and placed content .. (gfc_match_omp_atomic): ... here. Update for OpenMP 5 clauses. (gfc_match_oacc_atomic): Match directly here. (resolve_omp_atomic, gfc_resolve_omp_directive): Update. * parse.c (parse_omp_oacc_atomic): Update for struct gfc_code changes. * resolve.c (gfc_resolve_blocks): Update assert. * st.c (gfc_free_statement): Also call for EXEC_O{ACC,MP}_ATOMIC. * trans-openmp.c (gfc_trans_omp_atomic): Update. (gfc_trans_omp_flush): Update for 'last' to 'unset' change. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/atomic-2.f90: New test. * gfortran.dg/gomp/atomic.f90: New test.
2020-10-30Disable TBAA for array descriptors.Jan Hubicka1-0/+5
* trans-types.c: Include alias.h (gfc_get_array_type_bounds): Set typeless storage.
2020-10-28Daily bump.GCC Administrator1-0/+22
2020-10-27PR fortran/97491 - Wrong restriction for VALUE arguments of pure proceduresHarald Anlauf1-0/+1
A dummy argument with the VALUE attribute may be redefined in a PURE or ELEMENTAL procedure. Adjust the associated purity check. gcc/fortran/ChangeLog: * resolve.c (gfc_impure_variable): A dummy argument with the VALUE attribute may be redefined without making a procedure impure. gcc/testsuite/ChangeLog: * gfortran.dg/value_8.f90: New test.
2020-10-27Refactor array descriptor field accessRichard Biener1-128/+56
This refactors the array descriptor component access tree building to commonize code into new helpers to provide a single place to fix correctness issues with respect to TBAA. The only interesting part is the gfc_conv_descriptor_data_get change to drop broken special-casing of REFERENCE_TYPE desc which, when hit, would build invalid GENERIC trees, missing an INDIRECT_REF before subsetting the descriptor with a COMPONENT_REF. 2020-10-16 Richard Biener <rguenther@suse.de> gcc/fortran/ChangeLog: * trans-array.c (gfc_get_descriptor_field): New helper. (gfc_conv_descriptor_data_get): Use it - drop strange REFERENCE_TYPE handling and make sure we don't trigger it. (gfc_conv_descriptor_data_addr): Use gfc_get_descriptor_field. (gfc_conv_descriptor_data_set): Likewise. (gfc_conv_descriptor_offset): Likewise. (gfc_conv_descriptor_dtype): Likewise. (gfc_conv_descriptor_span): Likewise. (gfc_get_descriptor_dimension): Likewise. (gfc_conv_descriptor_token): Likewise. (gfc_conv_descriptor_subfield): New helper. (gfc_conv_descriptor_stride): Use it. (gfc_conv_descriptor_lbound): Likewise. (gfc_conv_descriptor_ubound): Likewise.
2020-10-26Daily bump.GCC Administrator1-0/+22
2020-10-25Correct decls for functions which do not pass actual arguments.Thomas Koenig5-40/+155
A wrong decl for findloc caused segfaults at runtime on Darwin for ARM; however, this is only a symptom of a larger disease: The declarations for our library functions are often inconsistent. This patch solves that problem for the functions specifically for the functions for which we do not pass optional arguments, i.e. findloc and (min|max)loc. It works by saving the symbols of the specific functions in gfc_intrinsic_namespace and by generating the formal argument lists from the actual argument lists. Because symbols are re-used, so are the backend decls. gcc/fortran/ChangeLog: PR fortran/97454 * gfortran.h (gfc_symbol): Add pass_as_value flag. (gfc_copy_formal_args_intr): Add optional argument copy_type. (gfc_get_intrinsic_function_symbol): Add prototype. (gfc_find_intrinsic_symbol): Add prototype. * intrinsic.c (gfc_get_intrinsic_function_symbol): New function. (gfc_find_intrinsic_symbol): New function. * symbol.c (gfc_copy_formal_args_intr): Add argument. Handle case where the type needs to be copied from the actual argument. * trans-intrinsic.c (remove_empty_actual_arguments): New function. (specific_intrinsic_symbol): New function. (gfc_conv_intrinsic_funcall): Use it. (strip_kind_from_actual): Adjust so that the expression pointer is set to NULL. (gfc_conv_intrinsic_minmaxloc): Likewise. (gfc_conv_intrinsic_minmaxval): Adjust removal of dim. * trans-types.c (gfc_sym_type): If sym->pass_as_value is set, do not pass by reference.
2020-10-23Daily bump.GCC Administrator1-0/+8
2020-10-22OpenMP: Fortran - support omp flush's memorder clausesTobias Burnus3-4/+64
gcc/fortran/ChangeLog: * gfortran.h (enum gfc_omp_memorder): Add. (gfc_omp_clauses): Use it. * openmp.c (gfc_match_omp_flush): Match memorder clauses. * trans-openmp.c (gfc_trans_omp_flush): Handle them. (gfc_trans_omp_directive): Update call. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/flush-1.f90: New test. * gfortran.dg/gomp/flush-2.f90: New test.
2020-10-22Daily bump.GCC Administrator1-0/+6
2020-10-21Fortran: class.c - update vtable commentTobias Burnus1-0/+2
gcc/fortran/ PR fortran/45516 * class.c: Add _deallocate to the vtable documentation comment.
2020-10-17Daily bump.GCC Administrator1-0/+10
2020-10-16PR fortran/95979 - ICE in get_kind, at fortran/simplify.c:129Harald Anlauf3-6/+7
Simplification of the elemental intrinsic INDEX with constant array-valued arguments failed with an ICE or did not reduce to a constant array, depending also on the presence of the optional KIND argument. Add a further attempt of simplification in the case of elemental intrinsics, and make sure the KIND argument is not removed prematurely during simplification of INDEX. gcc/fortran/ChangeLog: PR fortran/95979 * expr.c (gfc_check_init_expr): Fix check of return code from gfc_intrinsic_func_interface. * intrinsic.c (gfc_intrinsic_func_interface): Add further attempt of simplification of elemental intrinsics with array arguments. * iresolve.c (gfc_resolve_index_func): Keep optional KIND argument for simplification of elemental use of INDEX. gcc/testsuite/ChangeLog: PR fortran/95979 * gfortran.dg/index_4.f90: New test.
2020-10-16Daily bump.GCC Administrator1-0/+4
2020-10-15Fix fndecl's for fortran coarray calls.Andre Vehreschild1-38/+38
gcc/fortran/ChangeLog: * trans-decl.c (gfc_build_builtin_function_decls): Fix the coarray fndecls.
2020-10-15Daily bump.GCC Administrator1-0/+22
2020-10-14Fortran: Fix line-truncation warning for !$acc and !gcc$Tobias Burnus1-2/+2
gcc/fortran/ChangeLog: PR fortran/97390 * scanner.c (load_line): Fix line-truncation warning for !$acc and !gcc$ in free-form source code. gcc/testsuite/ChangeLog: PR fortran/97390 * gfortran.dg/goacc/warn_truncated.f90: New test.
2020-10-14Fortran : ICE in build_field PR95614Mark Eggleston4-8/+14
Local identifiers can not be the same as a module name. Original patch by Steve Kargl resulted in name clashes between common block names and local identifiers. A local identifier can be the same as a global identier if that identifier is not a module or a program. The original patch was modified to reject global identifiers that represent a module or a program. 2020-10-14 Steven G. Kargl <kargl@gcc.gnu.org> Mark Eggleston <markeggleston@gcc.gnu.org> gcc/fortran/ChangeLog: PR fortran/95614 * decl.c (gfc_get_common): Use gfc_match_common_name instead of match_common_name. * decl.c (gfc_bind_idents): Use gfc_match_common_name instead of match_common_name. * match.c : Rename match_common_name to gfc_match_common_name. * match.c (gfc_match_common): Use gfc_match_common_name instead of match_common_name. * match.h : Rename match_common_name to gfc_match_common_name. * resolve.c (resolve_common_vars): Check each symbol in a common block has a global symbol. If there is a global symbol issue an error if the symbol type is a module or a program. 2020-10-14 Mark Eggleston <markeggleston@gcc.gnu.org> gcc/testsuite/ChangeLog: PR fortran/95614 * gfortran.dg/pr95614_1.f90: New test. * gfortran.dg/pr95614_2.f90: New test. * gfortran.dg/pr95614_3.f90: New test. * gfortran.dg/pr95614_4.f90: New test.
2020-10-13Daily bump.GCC Administrator1-0/+6
2020-10-12Fortran : ICE in gfc_validate_kind PR96099Mark Eggleston1-1/+1
Only check for kind if the type supports kind. 2020-10-12 Mark Eggleston <markeggleston@gcc.gnu.org> gcc/fortran/ChangeLog: PR fortran/96099 * decl.c (gfc_match_implicit): Check for numeric and logical types. 2020-10-12 Mark Eggleston <markeggleston@gcc.gnu.org> gcc/testsuite/ChangeLog: PR fortran/96099 * gfortran.dg/pr96099_1.f90: New test. * gfortran.dg/pr96099_2.f90: New test.
2020-10-08Daily bump.GCC Administrator1-0/+6
2020-10-07This patch fixes PR47469 - a trivial bit of tidying up.Paul Thomas1-6/+2
2020-07-10 Paul Thomas <pault@gcc.gnu.org> gcc/fortran PR fortran/47469 * trans-expr.c (arrayfunc_assign_needs_temporary): Tidy detection of pointer and allocatable functions.
2020-10-05Daily bump.GCC Administrator1-0/+8
2020-10-04PR fortran/97272 - Wrong answer from MAXLOC with character argHarald Anlauf1-0/+19
The optional KIND argument to the MINLOC/MAXLOC intrinsic must not be passed to the library function, as the kind conversion of the result is treated explicitly elsewhere. gcc/fortran/ChangeLog: PR fortran/97272 * trans-intrinsic.c (strip_kind_from_actual): Helper function for removal of KIND argument. (gfc_conv_intrinsic_minmaxloc): Ignore KIND argument here, as it is treated elsewhere. gcc/testsuite/ChangeLog: PR fortran/97272 * gfortran.dg/pr97272.f90: New test.
2020-10-03Daily bump.GCC Administrator1-0/+9
2020-10-02Perforate fnspec stringsJan Hubicka3-126/+160
gcc/ChangeLog: 2020-10-02 Jan Hubicka <hubicka@ucw.cz> * attr-fnspec.h: Update documentation. (attr_fnsec::return_desc_size): Set to 2 (attr_fnsec::arg_desc_size): Set to 2 * builtin-attrs.def (STR1): Update fnspec. * internal-fn.def (UBSAN_NULL): Update fnspec. (UBSAN_VPTR): Update fnspec. (UBSAN_PTR): Update fnspec. (ASAN_CHECK): Update fnspec. (GOACC_DIM_SIZE): Remove fnspec. (GOACC_DIM_POS): Remove fnspec. * tree-ssa-alias.c (attr_fnspec::verify): Update verification. gcc/fortran/ChangeLog: 2020-10-02 Jan Hubicka <hubicka@ucw.cz> * trans-decl.c (gfc_build_library_function_decl_with_spec): Verify fnspec. (gfc_build_intrinsic_function_decls): Update fnspecs. (gfc_build_builtin_function_decls): Update fnspecs. * trans-io.c (gfc_build_io_library_fndecls): Update fnspecs. * trans-types.c (create_fn_spec): Update fnspecs.
2020-10-01Daily bump.GCC Administrator1-0/+37
2020-09-30Fix some fnspec strings in trans-decl.cJan Hubicka1-13/+13
* trans-decl.c (gfc_build_intrinsic_function_decls): Add traling dots to spec strings so they match the number of parameters; do not use R and W for non-pointer parameters. Drop pointless specifier on caf_stop_numeric and caf_get_team.
2020-09-30Add trailing dots so length of spec string matches number of arguments.Jan Hubicka1-23/+23
2020-09-30 Jan Hubicka <hubicka@ucw.cz> * trans-io.c (gfc_build_io_library_fndecls): Add trailing dots so length of spec string matches number of arguments.
2020-09-30Fortran: add contiguous check for ptr assignment, fix non-contig check (PR97242)Tobias Burnus1-7/+19
gcc/fortran/ChangeLog: PR fortran/97242 * expr.c (gfc_is_not_contiguous): Fix check. (gfc_check_pointer_assign): Use it. gcc/testsuite/ChangeLog: PR fortran/97242 * gfortran.dg/contiguous_11.f90: New test. * gfortran.dg/contiguous_4.f90: Update. * gfortran.dg/contiguous_7.f90: Update.
2020-09-30This patch fixes PR97045 - unlimited polymorphic array element selectors.Paul Thomas4-3/+39
2020-30-09 Paul Thomas <pault@gcc.gnu.org> gcc/fortran PR fortran/97045 * trans-array.c (gfc_conv_array_ref): Make sure that the class decl is passed to build_array_ref in the case of unlimited polymorphic entities. * trans-expr.c (gfc_conv_derived_to_class): Ensure that array refs do not preceed the _len component. Free the _len expr. * trans-stmt.c (trans_associate_var): Reset 'need_len_assign' for polymorphic scalars. * trans.c (gfc_build_array_ref): When the vptr size is used for span, multiply by the _len field of unlimited polymorphic entities, when non-zero. gcc/testsuite/ PR fortran/97045 * gfortran.dg/select_type_50.f90 : New test.
2020-09-30[nvptx] Add type arg to TARGET_LIBC_HAS_FUNCTIONTom de Vries1-2/+2
GCC has a target hook TARGET_LIBC_HAS_FUNCTION, which tells the compiler which functions it can expect to be present in libc. The default target hook does not include the sincos functions. The nvptx port of newlib does include sincos and sincosf, but not sincosl. The target hook TARGET_LIBC_HAS_FUNCTION does not distinguish between sincos, sincosf and sincosl, so if we enable it for the sincos functions, then for test.c: ... long double x, a, b; int main (void) { x = 0.5; a = sinl (x); b = cosl (x); printf ("a: %f\n", (double)a); printf ("b: %f\n", (double)b); return 0; } ... we introduce a regression: ... $ gcc test.c -lm -O2 unresolved symbol sincosl collect2: error: ld returned 1 exit status ... Add a type argument to target hook TARGET_LIBC_HAS_FUNCTION_TYPE, and use it in nvptx_libc_has_function_type to enable sincos and sincosf, but not sincosl. Build and reg-tested on x86_64-linux. Build and tested on nvptx. gcc/ChangeLog: 2020-09-28 Tobias Burnus <tobias@codesourcery.com> Tom de Vries <tdevries@suse.de> * builtins.c (expand_builtin_cexpi, fold_builtin_sincos): Update targetm.libc_has_function call. * builtins.def (DEF_C94_BUILTIN, DEF_C99_BUILTIN, DEF_C11_BUILTIN): (DEF_C2X_BUILTIN, DEF_C99_COMPL_BUILTIN, DEF_C99_C90RES_BUILTIN): Same. * config/darwin-protos.h (darwin_libc_has_function): Update prototype. * config/darwin.c (darwin_libc_has_function): Add arg. * config/linux-protos.h (linux_libc_has_function): Update prototype. * config/linux.c (linux_libc_has_function): Add arg. * config/i386/i386.c (ix86_libc_has_function): Update targetm.libc_has_function call. * config/nvptx/nvptx.c (nvptx_libc_has_function): New function. (TARGET_LIBC_HAS_FUNCTION): Redefine to nvptx_libc_has_function. * convert.c (convert_to_integer_1): Update targetm.libc_has_function call. * match.pd: Same. * target.def (libc_has_function): Add arg. * doc/tm.texi: Regenerate. * targhooks.c (default_libc_has_function, gnu_libc_has_function) (no_c99_libc_has_function): Add arg. * targhooks.h (default_libc_has_function, no_c99_libc_has_function) (gnu_libc_has_function): Update prototype. * tree-ssa-math-opts.c (pass_cse_sincos::execute): Update targetm.libc_has_function call. gcc/fortran/ChangeLog: 2020-09-30 Tom de Vries <tdevries@suse.de> * f95-lang.c (gfc_init_builtin_functions): Update targetm.libc_has_function call.
2020-09-29Daily bump.GCC Administrator1-0/+20
2020-09-28Revert "Fortran : ICE in build_field PR95614"Mark Eggleston4-14/+8
This reverts commit e5a76af3a2f3324efc60b4b2778ffb29d5c377bc.
2020-09-28Daily bump.GCC Administrator1-0/+17
2020-09-27Fortran : ICE in build_field PR95614Mark Eggleston4-8/+14
Local identifiers can not be the same as a module name. Original patch by Steve Kargl resulted in name clashes between common block names and local identifiers. A local identifier can be the same as a global identier if that identifier represents a common. The patch was modified to allow global identifiers that represent a common block. 2020-09-27 Steven G. Kargl <kargl@gcc.gnu.org> Mark Eggleston <markeggleston@gcc.gnu.org> gcc/fortran/ PR fortran/95614 * decl.c (gfc_get_common): Use gfc_match_common_name instead of match_common_name. * decl.c (gfc_bind_idents): Use gfc_match_common_name instead of match_common_name. * match.c : Rename match_common_name to gfc_match_common_name. * match.c (gfc_match_common): Use gfc_match_common_name instead of match_common_name. * match.h : Rename match_common_name to gfc_match_common_name. * resolve.c (resolve_common_vars): Check each symbol in a common block has a global symbol. If there is a global symbol issue an error if the symbol type is known as is not a common block name. 2020-09-27 Mark Eggleston <markeggleston@gcc.gnu.org> gcc/testsuite/ PR fortran/95614 * gfortran.dg/pr95614_1.f90: New test. * gfortran.dg/pr95614_2.f90: New test.
2020-09-25Daily bump.GCC Administrator1-0/+7
2020-09-24This patch fixes PR96495 - frees result components outside loop.Paul Thomas1-1/+25
2020-24-09 Paul Thomas <pault@gcc.gnu.org> gcc/fortran PR fortran/96495 * trans-expr.c (gfc_conv_procedure_call): Take the deallocation of allocatable result components of a scalar result outside the scalarization loop. Find and use the stored result. gcc/testsuite/ PR fortran/96495 * gfortran.dg/alloc_comp_result_2.f90 : New test.
2020-09-22Daily bump.GCC Administrator1-0/+16
2020-09-21PR fortran/90903 [part2] - Add runtime checking for the MVBITS intrinsicHarald Anlauf4-24/+209
Implement inline expansion of the intrinsic elemental subroutine MVBITS with optional runtime checks for valid argument range. gcc/fortran/ChangeLog: * iresolve.c (gfc_resolve_mvbits): Remove unneeded conversion of FROMPOS, LEN and TOPOS arguments to fit a C int. * trans-intrinsic.c (gfc_conv_intrinsic_mvbits): Add inline expansion of MVBITS intrinsic elemental subroutine and add code for runtime argument checking. (gfc_conv_intrinsic_subroutine): Recognise MVBITS intrinsic, but defer handling to gfc_trans_call. * trans-stmt.c (replace_ss): (gfc_trans_call): Adjust to handle inline expansion, scalarization of intrinsic subroutine MVBITS in gfc_conv_intrinsic_mvbits. * trans.h (gfc_conv_intrinsic_mvbits): Add prototype for gfc_conv_intrinsic_mvbits. gcc/testsuite/ChangeLog: * gfortran.dg/check_bits_2.f90: New test. Co-authored-by: Paul Thomas <pault@gcc.gnu.org>
2020-09-20Daily bump.GCC Administrator1-0/+10
2020-09-19Work around bootstrap failure in Fortran front end.Sandra Loosemore1-0/+4
Switching the C++ front end to lower loops the same was as the C front end triggered this error when bootstrapping the Fortran front end: /path/to/gcc/fortran/interface.c:3546:12: error: '*new_arg' may be used uninitialized [-Werror=maybe-uninitialized] 3546 | new_arg[i]->next = NULL; | ~~~~~~~~~^ Work around this by adding an assertion, which seems appropriate for documentation and good coding practices anyway. 2020-08-12 Sandra Loosemore <sandra@codesourcery.com> gcc/fortran/ * interface.c (gfc_compare_actual_formal): Add assertion after main processing loop to silence maybe-uninitialized error.
2020-09-19PR fortran/97036 - [F2018] Allow ELEMENTAL RECURSIVE procedure prefixHarald Anlauf1-1/+1
gcc/fortran/ChangeLog: * symbol.c (gfc_check_conflict): Allow ELEMENTAL RECURSIVE procedure prefix for -std=f2018. gcc/testsuite/ChangeLog: * gfortran.dg/pr97036.f90: New test.
2020-09-18Daily bump.GCC Administrator1-0/+7
2020-09-17Fortran: Avoid double-free with parse error (PR96041, PR93423)Tobias Burnus1-0/+9
gcc/fortran/ PR fortran/96041 PR fortran/93423 * decl.c (gfc_match_submod_proc): Avoid later double-free in the error case.
2020-09-17Daily bump.GCC Administrator1-0/+5
2020-09-16Fortran: OpenMP - fix simd with (last)private (PR97061)Tobias Burnus1-14/+23
gcc/fortran/ChangeLog: PR fortran/97061 * trans-openmp.c (gfc_trans_omp_do): Handle simd with (last)private. gcc/testsuite/ChangeLog: PR fortran/97061 * gfortran.dg/gomp/openmp-simd-6.f90: New test.
2020-09-16Daily bump.GCC Administrator1-0/+9