aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
AgeCommit message (Collapse)AuthorFilesLines
43 hoursDaily bump.GCC Administrator1-0/+7
2 daysFortran: pure subroutine with pure procedure as dummy [PR106948]Harald Anlauf1-0/+7
PR fortran/106948 gcc/fortran/ChangeLog: * resolve.cc (gfc_pure_function): If a function has been resolved, but esym is not yet set, look at its attributes to see whether it is pure or elemental. gcc/testsuite/ChangeLog: * gfortran.dg/pure_formal_proc_4.f90: New test.
3 daysDaily bump.GCC Administrator1-0/+29
3 daysFortran/OpenMP: Support automatic mapping allocatable components (deep mapping)Tobias Burnus5-88/+972
When mapping an allocatable variable (or derived-type component), explicitly or implicitly, all its allocated allocatable components will automatically be mapped. The patch implements the target hooks, added for this feature to omp-low.cc with commit r15-3895-ge4a58b6f28383c. Namely, there is a check whether there are allocatable components at all: gfc_omp_deep_mapping_p. Then gfc_omp_deep_mapping_cnt, counting the number of required mappings; this is a dynamic value as it depends on array bounds and whether an allocatable is allocated or not. And, finally, the actual mapping: gfc_omp_deep_mapping. Polymorphic variables are partially supported: the mapping of the _data component is fully supported, but only components of the declared type are processed for additional allocatables. Additionally, _vptr is not touched. This means that everything needing _vtab information requires unified shared memory; in particular, _size data is required when accessing elements of polymorphic arrays. However, for scalar arrays, accessing components of the declare type should work just fine. As polymorphic variables are not (really) supported and OpenMP 6 explicitly disallows them, there is now a warning (-Wopenmp) when they are encountered. Unlimited polymorphics are rejected (error). Additionally, PRIVATE and FIRSTPRIVATE are not quite supported for allocatable components, polymorphic components and as polymorphic variable. Thus, those are now rejected as well. gcc/fortran/ChangeLog: * f95-lang.cc (LANG_HOOKS_OMP_DEEP_MAPPING, LANG_HOOKS_OMP_DEEP_MAPPING_P, LANG_HOOKS_OMP_DEEP_MAPPING_CNT): Define. * openmp.cc (gfc_match_omp_clause_reduction): Fix location setting. (resolve_omp_clauses): Permit allocatable components, reject them and polymorphic variables in PRIVATE/FIRSTPRIVATE. * trans-decl.cc (add_clause): Set clause location. * trans-openmp.cc (gfc_has_alloc_comps): Add ptr_ok and shallow_alloc_only Boolean arguments. (gfc_omp_replace_alloc_by_to_mapping): New. (gfc_omp_private_outer_ref, gfc_walk_alloc_comps, gfc_omp_clause_default_ctor, gfc_omp_clause_copy_ctor, gfc_omp_clause_assign_op, gfc_omp_clause_dtor): Update call to it. (gfc_omp_finish_clause): Minor cleanups, improve location data, handle allocatable components. (gfc_omp_deep_mapping_map, gfc_omp_deep_mapping_item, gfc_omp_deep_mapping_comps, gfc_omp_gen_simple_loop, gfc_omp_get_array_size, gfc_omp_elmental_loop, gfc_omp_deep_map_kind_p, gfc_omp_deep_mapping_int_p, gfc_omp_deep_mapping_p, gfc_omp_deep_mapping_do, gfc_omp_deep_mapping_cnt, gfc_omp_deep_mapping): New. (gfc_trans_omp_array_section): Save array descriptor in case deep-mapping lang hook will need it. (gfc_trans_omp_clauses): Likewise; use better clause location data. * trans.h (gfc_omp_deep_mapping_p, gfc_omp_deep_mapping_cnt, gfc_omp_deep_mapping): Add function prototypes. libgomp/ChangeLog: * libgomp.texi (5.0 Impl. Status): Mark mapping alloc comps as 'Y'. * testsuite/libgomp.fortran/allocatable-comp.f90: New test. * testsuite/libgomp.fortran/map-alloc-comp-3.f90: New test. * testsuite/libgomp.fortran/map-alloc-comp-4.f90: New test. * testsuite/libgomp.fortran/map-alloc-comp-5.f90: New test. * testsuite/libgomp.fortran/map-alloc-comp-6.f90: New test. * testsuite/libgomp.fortran/map-alloc-comp-7.f90: New test. * testsuite/libgomp.fortran/map-alloc-comp-8.f90: New test. * testsuite/libgomp.fortran/map-alloc-comp-9.f90: New test. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/map-alloc-comp-1.f90: Remove dg-error. * gfortran.dg/gomp/polymorphic-mapping-2.f90: Update warn wording. * gfortran.dg/gomp/polymorphic-mapping.f90: Change expected diagnostic; some tests moved to ... * gfortran.dg/gomp/polymorphic-mapping-1.f90: ... here as new test. * gfortran.dg/gomp/polymorphic-mapping-3.f90: New test. * gfortran.dg/gomp/polymorphic-mapping-4.f90: New test. * gfortran.dg/gomp/polymorphic-mapping-5.f90: New test.
5 daysDaily bump.GCC Administrator1-0/+7
5 daysFix ICE in compare_parameter.Thomas Koenig1-7/+24
This patch fixes an ICE by setting the typespec of a dummy argument from a global function if known. plus setting the correct flag. This also removes the corresponding assert. I'm not quite sure that the code with the subroutine attribute can be reached, but I thought better safe than sorry. gcc/fortran/ChangeLog: PR fortran/119669 * interface.cc (compare_parameter): Error when mismatch between formal argument as subroutine and function. If the dummy argument is a known function, set its typespec. gcc/testsuite/ChangeLog: PR fortran/119669 * gfortran.dg/interface_59.f90: New test.
6 daysDaily bump.GCC Administrator1-0/+6
6 daysFortran: Add code gen for do,concurrent's LOCAL/LOCAL_INIT: Fix ↵Thomas Schwinge1-1/+1
'static_assert' [PR101602] Fix-up for commit 2d7e1d6e40a13a5f160b584336795b80f193ec3b "Fortran: Add code gen for do,concurrent's LOCAL/LOCAL_INIT [PR101602]": ../../source-gcc/gcc/fortran/trans-stmt.cc: In function ‘void gfc_trans_concurrent_locality_spec(bool, stmtblock_t*, std::vector<symbol_and_tree_t>*, gfc_expr_list**)’: ../../source-gcc/gcc/fortran/trans-stmt.cc:5157:59: error: expected ‘,’ before ‘)’ token static_assert (LOCALITY_LOCAL_INIT - LOCALITY_LOCAL == 1); ^ ../../source-gcc/gcc/fortran/trans-stmt.cc:5157:59: error: expected string-literal before ‘)’ token make[2]: *** [Makefile:1210: fortran/trans-stmt.o] Error 1 PR fortran/101602 gcc/fortran/ * trans-stmt.cc (gfc_trans_concurrent_locality_spec): Fix 'static_assert'.
9 daysDaily bump.GCC Administrator1-0/+35
9 daysFortran: fix issue with impure elemental subroutine and interface [PR119656]Harald Anlauf2-7/+17
PR fortran/119656 gcc/fortran/ChangeLog: * interface.cc (gfc_compare_actual_formal): Fix front-end memleak when searching for matching interfaces. * trans-expr.cc (gfc_conv_procedure_call): If there is a formal dummy corresponding to an absent argument, use its type, and only fall back to inferred type otherwise. gcc/testsuite/ChangeLog: * gfortran.dg/optional_absent_13.f90: New test.
9 daysFortran: Fix some problems with the reduce intrinsic [PR119460]Paul Thomas4-28/+11
2025-04-09 Paul Thomas <pault@gcc.gnu.org> and Harald Anlauf <anlauf@gcc.gnu.org> gcc/fortran PR fortran/119460 * iresolve.cc (generate_reduce_op_wrapper): Increase the size of 'tname'. Change intent of 'a' and 'b' to intent_in. * trans-decl.cc (add_argument_checking): Do not test artificial formal symbols. * trans-expr.cc (gfc_conv_procedure_call): Remove reduce_scalar and the blocks triggered by it. * trans-intrinsic.cc (gfc_conv_intrinsic_function): Set the result of non-character, scalar reduce to be allocatable. gcc/testsuite/ PR fortran/119460 * gfortran.dg/reduce_2.f90: Add test to check that deferred len characters cannot slip through. * gfortran.dg/reduce_3.f90: New test * gfortran.dg/reduce_4.f90: New test libgfortran/ PR libfortran/119460 * intrinsics/reduce.c (reduce): Correct error message about mismatch between dim and the rank of array. Output the values of both. Correct the evaluation of the result stride and extent. (reduce_scalar): The front end treats the result as an allocatable so eliminate memcpy and free. Return the base-addr of the local descriptor. (reduce_c): Correct the type of the string lengths. (reduce_scalar_c): Correct the type of the string lengths.Test to see if 'res' is allocated. If not then return the base_addr of the local descriptor.
10 daysFortran: Add code gen for do,concurrent's LOCAL/LOCAL_INIT [PR101602]Tobias Burnus4-21/+167
Implement LOCAL and LOCAL_INIT; we locally replace the tree declaration by a local declaration of the outer variable. The 'local_init' then assigns the value at the beginning of each loop iteration from the outer declaration. Note that the current implementation does not handle LOCAL with types that have a default initializer and LOCAL/LOCAL_INIT for assumed-shape arrays; this is diagnosed with a sorry error. PR fortran/101602 gcc/fortran/ChangeLog: * resolve.cc (resolve_locality_spec): Remove 'sorry, unimplemented'. * trans-stmt.cc (struct symbol_and_tree_t): New. (gfc_trans_concurrent_locality_spec): New. (gfc_trans_forall_1): Call it; update to handle local and local_init. * trans-decl.cc (gfc_start_saved_local_decls, gfc_stop_saved_local_decls): New; moved code from ... (gfc_process_block_locals): ... here. Call it. * trans.h (gfc_start_saved_local_decls, gfc_stop_saved_local_decls): Declare. gcc/testsuite/ChangeLog: * gfortran.dg/do_concurrent_8_f2023.f90: Update for removed 'sorry, unimplemented'. * gfortran.dg/do_concurrent_9.f90: Likewise. * gfortran.dg/do_concurrent_all_clauses.f90: Likewise. * gfortran.dg/do_concurrent_local_init.f90: Likewise. * gfortran.dg/do_concurrent_locality_specs.f90: Likewise. * gfortran.dg/do_concurrent_11.f90: New test. * gfortran.dg/do_concurrent_12.f90: New test. * gfortran.dg/do_concurrent_13.f90: New test. * gfortran.dg/do_concurrent_14.f90: New test. * gfortran.dg/do_concurrent_15.f90: New test.
2025-04-03Daily bump.GCC Administrator1-0/+10
2025-04-02OpenMP: Require target and/or targetsync init modifier [PR118965]Sandra Loosemore1-42/+35
As noted in PR 118965, the initial interop implementation overlooked the requirement in the OpenMP spec that at least one of the "target" and "targetsync" modifiers is required in both the interop construct init clause and the declare variant append_args clause. Adding the check was fairly straightforward, but it broke about a gazillion existing test cases. In particular, things like "init (x, y)" which were previously accepted (and tested for being accepted) aren't supposed to be allowed by the spec, much less things like "init (target)" where target was previously interpreted as a variable name instead of a modifier. Since one of the effects of the change is that at least one modifier is always required, I found that deleting all the code that was trying to detect and handle the no-modifier case allowed for better diagnostics. gcc/c/ChangeLog PR middle-end/118965 * c-parser.cc (c_parser_omp_clause_init_modifiers): Adjust error message. (c_parser_omp_clause_init): Remove code for recognizing clauses without modifiers. Diagnose missing target/targetsync modifier. (c_finish_omp_declare_variant): Diagnose missing target/targetsync modifier. gcc/cp/ChangeLog PR middle-end/118965 * parser.cc (c_parser_omp_clause_init_modifiers): Adjust error message. (cp_parser_omp_clause_init): Remove code for recognizing clauses without modifiers. Diagnose missing target/targetsync modifier. (cp_finish_omp_declare_variant): Diagnose missing target/targetsync modifier. gcc/fortran/ChangeLog PR middle-end/118965 * openmp.cc (gfc_parser_omp_clause_init_modifiers): Fix some inconsistent code indentation. Remove code for recognizing clauses without modifiers. Diagnose prefer_type without a following paren. Adjust error message for an unrecognized modifier. Diagnose missing target/targetsync modifier. (gfc_match_omp_init): Fix more inconsistent code indentation. gcc/testsuite/ChangeLog PR middle-end/118965 * c-c++-common/gomp/append-args-1.c: Add target/targetsync modifiers so tests do what they were previously supposed to do. Adjust expected output. * c-c++-common/gomp/append-args-7.c: Likewise. * c-c++-common/gomp/append-args-8.c: Likewise. * c-c++-common/gomp/append-args-9.c: Likewise. * c-c++-common/gomp/interop-1.c: Likewise. * c-c++-common/gomp/interop-2.c: Likewise. * c-c++-common/gomp/interop-3.c: Likewise. * c-c++-common/gomp/interop-4.c: Likewise. * c-c++-common/gomp/pr118965-1.c: New. * c-c++-common/gomp/pr118965-2.c: New. * g++.dg/gomp/append-args-1.C: Add target/targetsync modifiers and adjust expected output. * g++.dg/gomp/append-args-2.C: Likewise. * g++.dg/gomp/append-args-6.C: Likewise. * g++.dg/gomp/append-args-7.C: Likewise. * g++.dg/gomp/append-args-8.C: Likewise. * g++.dg/gomp/interop-5.C: Likewise. * gfortran.dg/gomp/append_args-1.f90: Add target/targetsync modifiers and adjust expected output. * gfortran.dg/gomp/append_args-2.f90: Likewise. * gfortran.dg/gomp/append_args-3.f90: Likewise. * gfortran.dg/gomp/append_args-4.f90: Likewise. * gfortran.dg/gomp/interop-1.f90: Likewise. * gfortran.dg/gomp/interop-2.f90: Likewise. * gfortran.dg/gomp/interop-3.f90: Likewise. * gfortran.dg/gomp/interop-4.f90: Likewise. * gfortran.dg/gomp/pr118965-1.f90: New. * gfortran.dg/gomp/pr118965-2.f90: New.
2025-03-29Daily bump.GCC Administrator1-0/+5
2025-03-28Fortran: fix spelling of flag -fallow-invalid-bozHarald Anlauf1-1/+1
gcc/fortran/ChangeLog: * check.cc (gfc_invalid_boz): Correct spelling of compiler flag in hint to -fallow-invalid-boz.
2025-03-27Daily bump.GCC Administrator1-0/+6
2025-03-26Fortran: fix bogus recursion with DT default initialization [PR118796]Harald Anlauf1-1/+2
PR fortran/118796 gcc/fortran/ChangeLog: * resolve.cc: Do not apply default initialization to a derived-type function result if the resolved function is use-associated. gcc/testsuite/ChangeLog: * gfortran.dg/derived_result_4.f90: New test.
2025-03-26Daily bump.GCC Administrator1-0/+13
2025-03-25C prototypes for functions returning C function pointers.Thomas Koenig1-3/+23
This patch handles dumping prototypes for C functions returning function pointers. For the test case MODULE test USE, INTRINSIC :: ISO_C_BINDING CONTAINS FUNCTION lookup(idx) BIND(C) type(C_FUNPTR) :: lookup integer(C_INT), VALUE :: idx lookup = C_FUNLOC(x1) END FUNCTION lookup subroutine x1() end subroutine x1 END MODULE test the prototype is void (*lookup (int idx)) (); Regression-tested. Again no test case because I don't know how. During testing, I also found that vtabs were dumped, this is also corrected. gcc/fortran/ChangeLog: PR fortran/119419 * dump-parse-tree.cc (write_funptr_fcn): New function. (write_type): Invoke it for C_FUNPTR. (write_interop_decl): Do not dump vtabs.
2025-03-25OpenMP: Create additional interop objects with append_args.Sandra Loosemore1-2/+2
This patch adds support for the case where #pragma omp declare variant with append_args is used inside a #pragma omp dispatch interop that specifies fewer interop args than required by the variant; new interop objects are implicitly created and then destroyed around the call to the variant, using the GOMP_interop builtin. gcc/fortran/ChangeLog * trans-openmp.cc (gfc_trans_omp_declare_variant): Remove accidental redeclaration of pref. gcc/ChangeLog * gimplify.cc (modify_call_for_omp_dispatch): Adjust arguments. Remove the "sorry" for the case where new interop objects must be constructed, and add code to make it work instead. (expand_variant_call_expr): Adjust arguments and call to modify_call_for_omp_dispatch. (gimplify_variant_call_expr): Simplify logic for calling expand_variant_call_expr. gcc/testsuite/ChangeLog * c-c++-common/gomp/append-args-1.c: Adjust expected behavior. * c-c++-common/gomp/append-args-interop.c: New. * c-c++-common/gomp/dispatch-11.c: Adjust expected behavior. * g++.dg/gomp/append-args-1.C: Likewise. * gfortran.dg/gomp/append-args-interop.f90: New. * gfortran.dg/gomp/declare-variant-mod-2.f90: Adjust expected behavior. libgomp/ChangeLog * libgomp.texi (OpenMP 5.1): Mark append_args as fully supported. Co-Authored-By: Tobias Burnus <tburnus@baylibre.com>
2025-03-22Daily bump.GCC Administrator1-0/+66
2025-03-22Fix up some further cases of missing or extraneous spaces in diagnosticsJakub Jelinek1-1/+1
Given the recent PR119406 I've tried to grep for concatenated string literals without space at the end of one line and at the start of next line, unless it was obviously intentional. Furthermore, I've then looked through gcc.pot looking for 2 adjacent spaces and looking back if that wasn't the case of "something " " with spaces at both sides". Here is the result from that. I think just the c.opt change needs an explanation, the "" in the description is simply eaten up somewhere during the option processing and gcc -v --help before this patch was displaying -Wdeprecated-literal-operator Warn about deprecated space between and suffix in a user-defined literal operator. 2025-03-22 Jakub Jelinek <jakub@redhat.com> gcc/ * gimplify.cc (warn_switch_unreachable_and_auto_init_r): Add missing space in the middle of diagnostics. * tree-vect-stmts.cc (vectorizable_load): Add missing space in the middle of debug dump message. * sym-exec/sym-exec-state.cc (state::check_args_compatibility): Likewise. gcc/c-family/ * c.opt (Wdeprecated-literal-operator): Use \"\" rather than "" in option description. gcc/fortran/ * resolve.cc (resolve_procedure_expression): Remove extraneous space from the middle of diagnostics.
2025-03-21OpenMP: 'interop' construct - add ME support + target-independent libgompPaul-Antoine Arras2-3/+20
This patch partially enables use of the OpenMP interop construct by adding middle end support, mostly in the omplower pass, and in the target-independent part of the libgomp runtime. It follows up on previous patches for C, C++ and Fortran front ends support. The full interop feature requires another patch to enable foreign runtime support in libgomp plugins. gcc/ChangeLog: * builtin-types.def (BT_FN_VOID_INT_INT_PTR_PTR_PTR_INT_PTR_INT_PTR_UINT_PTR): New. * gimple-low.cc (lower_stmt): Handle GIMPLE_OMP_INTEROP. * gimple-pretty-print.cc (dump_gimple_omp_interop): New function. (pp_gimple_stmt_1): Handle GIMPLE_OMP_INTEROP. * gimple.cc (gimple_build_omp_interop): New function. (gimple_copy): Handle GIMPLE_OMP_INTEROP. * gimple.def (GIMPLE_OMP_INTEROP): Define. * gimple.h (gimple_build_omp_interop): Declare. (gimple_omp_interop_clauses): New function. (gimple_omp_interop_clauses_ptr): Likewise. (gimple_omp_interop_set_clauses): Likewise. (gimple_return_set_retval): Handle GIMPLE_OMP_INTEROP. * gimplify.cc (gimplify_scan_omp_clauses): Handle OMP_CLAUSE_INIT, OMP_CLAUSE_USE and OMP_CLAUSE_DESTROY. (gimplify_omp_interop): New function. (gimplify_expr): Replace sorry with call to gimplify_omp_interop. * omp-builtins.def (BUILT_IN_GOMP_INTEROP): Define. * omp-low.cc (scan_sharing_clauses): Handle OMP_CLAUSE_INIT, OMP_CLAUSE_USE and OMP_CLAUSE_DESTROY. (scan_omp_1_stmt): Handle GIMPLE_OMP_INTEROP. (lower_omp_interop_action_clauses): New function. (lower_omp_interop): Likewise. (lower_omp_1): Handle GIMPLE_OMP_INTEROP. gcc/c/ChangeLog: * c-parser.cc (c_parser_omp_clause_destroy): Make addressable. (c_parser_omp_clause_init): Make addressable. gcc/cp/ChangeLog: * parser.cc (cp_parser_omp_clause_init): Make addressable. gcc/fortran/ChangeLog: * trans-openmp.cc (gfc_trans_omp_clauses): Make OMP_CLAUSE_DESTROY and OMP_CLAUSE_INIT addressable. * types.def (BT_FN_VOID_INT_INT_PTR_PTR_PTR_INT_PTR_INT_PTR_UINT_PTR): New. include/ChangeLog: * gomp-constants.h (GOMP_DEVICE_DEFAULT_OMP_61, GOMP_INTEROP_TARGET, GOMP_INTEROP_TARGETSYNC, GOMP_INTEROP_FLAG_NOWAIT): Define. libgomp/ChangeLog: * icv-device.c (omp_set_default_device): Check GOMP_DEVICE_DEFAULT_OMP_61. * libgomp-plugin.h (struct interop_obj_t): New. (enum gomp_interop_flag): New. (GOMP_OFFLOAD_interop): Declare. (GOMP_OFFLOAD_get_interop_int): Declare. (GOMP_OFFLOAD_get_interop_ptr): Declare. (GOMP_OFFLOAD_get_interop_str): Declare. (GOMP_OFFLOAD_get_interop_type_desc): Declare. * libgomp.h (_LIBGOMP_OMP_LOCK_DEFINED): Define. (struct gomp_device_descr): Add interop_func, get_interop_int_func, get_interop_ptr_func, get_interop_str_func, get_interop_type_desc_func. * libgomp.map: Add GOMP_interop. * libgomp_g.h (GOMP_interop): Declare. * target.c (resolve_device): Handle GOMP_DEVICE_DEFAULT_OMP_61. (omp_get_interop_int): Replace stub with actual implementation. (omp_get_interop_ptr): Likewise. (omp_get_interop_str): Likewise. (omp_get_interop_type_desc): Likewise. (struct interop_data_t): Define. (gomp_interop_internal): New function. (GOMP_interop): Likewise. (gomp_load_plugin_for_device): Load symbols for get_interop_int, get_interop_ptr, get_interop_str and get_interop_type_desc. * testsuite/libgomp.c-c++-common/interop-1.c: New test. gcc/testsuite/ChangeLog: * c-c++-common/gomp/interop-1.c: Remove dg-prune-output "sorry". * c-c++-common/gomp/interop-2.c: Likewise. * c-c++-common/gomp/interop-3.c: Likewise. * c-c++-common/gomp/interop-4.c: Remove dg-message "not supported". * g++.dg/gomp/interop-5.C: Likewise. * gfortran.dg/gomp/interop-4.f90: Likewise. * c-c++-common/gomp/interop-5.c: New test. * gfortran.dg/gomp/interop-5.f90: New test. Co-authored-by: Tobias Burnus <tburnus@baylibre.com>
2025-03-21Fortran: Fix typo in error message.Jerry DeLisle1-1/+1
PR fortran/119406 gcc/fortran/ChangeLog: * resolve.cc (resolve_locality_spec): Add space in error message.
2025-03-21Fortran: Fix typo in error message.Jerry DeLisle1-1/+1
PR fortran/119403 gcc/fortran/ChangeLog: * interface.cc (compare_parameter): Fix typo.
2025-03-21Fortran: Implement the F2018 reduce intrinsic [PR85836]Paul Thomas7-51/+427
2025-03-21 Paul Thomas <pault@gcc.gnu.org> gcc/fortran PR fortran/85836 * check.cc (get_ul_from_cst_cl): New function used in check_operation. (check_operation): New function used in check_reduce and check_co_reduce. (gfc_check_co_reduce): Use it. (gfc_check_reduce): New function. (gfc_check_rename): Add prototype for intrinsic with 6 arguments. * gfortran.h : Add isym id for reduce and prototype for f6. * intrinsic.cc (do_check): Add another argument expression and use it in the call to the six argument specific check. (add_sym_6): New function. (add_functions): Add the discription of the reduce intrinsic and add it to the intrinsic list. * intrinsic.h : Add prototypes for gfc_check_reduce and gfc_resolve_reduce. * iresolve.cc (generate_reduce_op_wrapper): Generate a wrapper subroutine for the 'operation' function to enable the library implementation to be type agnostic and use pointer arithmetic throughout. (gfc_resolve_reduce): New function. * trans-expr.cc (gfc_conv_procedure_call): Add flag for scalar reduce. Generate a return variable 'sr' for scalar reduce, pass its address to the library function and return it as the scalar result. * trans-intrinsic.cc (gfc_conv_intrinsic_function): Array valued reduce is called in same way as reshape. Fall through for call to the scalar version. gcc/testsuite/ PR fortran/85836 * gfortran.dg/reduce_1.f90: New test * gfortran.dg/reduce_2.f90: New test libgfortran/ PR libfortran/85836 * Makefile.am : Add reduce.c * Makefile.in : Regenerated * gfortran.map : Add _gfortran_reduce, _gfortran_reduce_scalar, _gfortran_reduce_c and _gfortran_reduce_scalar_c to the list. * intrinsics/reduce.c (reduce, reduce_scalar, reduce_c, reduce_scalar_c): New functions and prototypes
2025-03-21Fortran: Fix freeing procedure pointer components [PR119380]Andre Vehreschild1-1/+1
PR fortran/119380 gcc/fortran/ChangeLog: * trans-array.cc (structure_alloc_comps): Prevent freeing of procedure pointer components. gcc/testsuite/ChangeLog: * gfortran.dg/proc_ptr_comp_54.f90: New test.
2025-03-21Fortran: Fix double free on polymorphic array dummy argument [PR119349]Andre Vehreschild1-1/+5
Calling elemental routines with polymorphic formals leads to generation of a temporary polymorphic variable and code for its deallocation. Sourcing this element from an array constructor the latter now is prevented from generating a second deallocation. PR fortran/119349 gcc/fortran/ChangeLog: * trans-expr.cc (gfc_conv_procedure_call): Prevent deallocation of array temporary for polymorphic temporary argument. gcc/testsuite/ChangeLog: * gfortran.dg/class_79.f90: New test.
2025-03-20Daily bump.GCC Administrator1-0/+12
2025-03-19Fortran: fix bogus bounds check for reallocation on assignment [PR116706]Harald Anlauf1-3/+1
PR fortran/116706 gcc/fortran/ChangeLog: * trans-array.cc (gfc_is_reallocatable_lhs): Fix check on allocatable components of derived type or class objects. gcc/testsuite/ChangeLog: * gfortran.dg/bounds_check_27.f90: New test.
2025-03-19Fortran: Fix comp call in associate [PR119272]Andre Vehreschild1-2/+3
PR fortran/119272 gcc/fortran/ChangeLog: * resolve.cc (resolve_compcall): Postpone error report when symbol is not resolved yet for component call resolve. gcc/testsuite/ChangeLog: * gfortran.dg/associate_74.f90: New test.
2025-03-19Daily bump.GCC Administrator1-0/+7
2025-03-18Fortran: check type-spec in ALLOCATE of dummy with assumed length [PR119338]Harald Anlauf1-0/+16
PR fortran/119338 gcc/fortran/ChangeLog: * resolve.cc (resolve_allocate_expr): Check F2003:C626: Type-spec in ALLOCATE of an assumed-length character dummy argument shall be an asterisk. gcc/testsuite/ChangeLog: * gfortran.dg/deferred_character_18.f90: Adjust testcase. * gfortran.dg/allocate_assumed_charlen_5.f90: New test.
2025-03-17Daily bump.GCC Administrator1-0/+10
2025-03-16Fortran: fix bogus dependency check in ALLOCATE statement [PR60560]Harald Anlauf2-14/+26
Restrict dependency check of ALLOCATE object to variables in the same statement, but exclude check of length type parameter that might be set in the declaration and could lead to a bogus cyclic dependency. PR fortran/60560 gcc/fortran/ChangeLog: * expr.cc (gfc_traverse_expr): Do not descend into length type parameter for negative values of auxiliary parameter f. * resolve.cc (gfc_find_var_in_expr): New helper function to check dependence of an expression on given variable. (resolve_allocate_expr): Use it to determine if array bounds in an ALLOCATE statement depend explicitly on a variable. gcc/testsuite/ChangeLog: * gfortran.dg/allocate_error_8.f90: New test.
2025-03-16Daily bump.GCC Administrator1-0/+17
2025-03-15Fortran: Store OpenMP's 'declare variant' in module file [PR115271]Tobias Burnus5-66/+365
Write the 'omp declare variant' data into the .mod file: Base function, variant function(s), supporting the clauses match, append_args, and adjust_args. PR fortran/115271 gcc/fortran/ChangeLog: * module.cc (mio_omp_declare_simd_clauses): New, moved from ... (mio_omp_declare_simd): ... here. Update call, write empty '( )' if there is no declare simd but a declare variant. (mio_omp_declare_variant): New. (mio_symbol): Call it. * openmp.cc (gfc_match_omp_context_selector): Add comment about module.cc to TODO note. * trans-stmt.h (gfc_trans_omp_declare_variant): Take additional parent_ns argument. * trans-decl.cc (create_function_arglist, gfc_create_function_decl): Update call. * trans-openmp.cc (gfc_trans_omp_declare_variant): Take new argument, add some special case handling for attr.use_assoc. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/declare-variant-mod-1-use.f90: New test. * gfortran.dg/gomp/declare-variant-mod-1.f90: New test. * gfortran.dg/gomp/declare-variant-mod-2-use.f90: New test. * gfortran.dg/gomp/declare-variant-mod-2.f90: New test.
2025-03-14Daily bump.GCC Administrator1-0/+8
2025-03-13Fortran: improve checking of substring bounds [PR119118]Harald Anlauf1-2/+4
Commit r15-7873 copy-pasted erroneous code containing a non-terminating loop that did not progress its control variable, and a switch statement with an unhandled case leading to a gcc_unreachable () with suitable input. PR fortran/119118 gcc/fortran/ChangeLog: * dependency.cc (contains_forall_index_p): Let loop over elements of a constructor update its control variable. Handle REF_INQUIRY in switch statement. (gfc_contains_implied_index_p): Likewise. gcc/testsuite/ChangeLog: * gfortran.dg/bounds_check_26.f90: Update test.
2025-03-13Daily bump.GCC Administrator1-0/+24
2025-03-12Fortran: Add F2018 TEAM_NUMBER to coindexed expressions [PR98903]Andre Vehreschild7-74/+255
Add missing parsing and code generation for a[..., TEAM_NUMBER=...] as defined from F2015 onwards. Because F2015 is not used as dedicated standard in GFortran add it to the F2018 standard feature set. PR fortran/98903 gcc/fortran/ChangeLog: * array.cc (gfc_copy_array_ref): Copy team, team_type and stat. (match_team_or_stat): Match a single team(_number)= or stat=. (gfc_match_array_ref): Add switching to image_selector_parsing and error handling when indices come after named arguments. * coarray.cc (move_coarray_ref): Move also team_type. * expr.cc (gfc_free_ref_list): Free team and stat expression. (gfc_find_team_co): Find team or team_number in array-ref. * gfortran.h (enum gfc_array_ref_team_type): New enum to distinguish unset, team or team_number expression. (gfc_find_team_co): Default searching to team= expressions. * resolve.cc (resolve_array_ref): Check for type correctness of team(_number) and stats in coindices. * trans-array.cc (gfc_conv_array_ref): Ensure stat is cleared when fcoarray=single is used. * trans-intrinsic.cc (conv_stat_and_team): Including team_number in conversion. (gfc_conv_intrinsic_caf_get): Propagate team_number to ABI routine. (conv_caf_send_to_remote): Same. (conv_caf_sendget): Same. gcc/testsuite/ChangeLog: * gfortran.dg/coarray/coindexed_2.f90: New test. * gfortran.dg/coarray/coindexed_3.f08: New test. * gfortran.dg/coarray/coindexed_4.f08: New test.
2025-03-12Daily bump.GCC Administrator1-0/+16
2025-03-11Fortran: reject SAVE of a COMMON in a BLOCK construct [PR119199]Harald Anlauf2-1/+10
PR fortran/119199 gcc/fortran/ChangeLog: * decl.cc (gfc_match_save): Reject SAVE statement of a COMMON block when in a BLOCK construct. * trans-common.cc (translate_common): Avoid NULL pointer dereference. gcc/testsuite/ChangeLog: * gfortran.dg/common_30.f90: New test. * gfortran.dg/common_31.f90: New test.
2025-03-11Abstract interfaces and dummy arguments are not global.Thomas Koenig2-3/+6
The attached patch makes sure that procedures from abstract interfaces and dummy arguments are not put into the global symbol table, and are not checked against global symbols. gcc/fortran/ChangeLog: PR fortran/119078 * frontend-passes.cc (check_against_globals): Do not check for abstract interfaces or dummy arguments. * resolve.cc (gfc_verify_binding_labels): Adjust comment. Do not put abstract interfaces or dummy argument into global namespace. gcc/testsuite/ChangeLog: PR fortran/119078 * gfortran.dg/interface_58.f90: New test.
2025-03-11Daily bump.GCC Administrator1-0/+6
2025-03-10Fortran: Fix gimplification error for pointer remapping in forall [PR107143]Andre Vehreschild1-1/+2
Enhance dependency checking for data pointers to check for same derived type and not only for a type being a derived type. This prevent generation of a descriptor for a function call, that is unsuitable in forall's pointer assignment. PR fortran/107143 gcc/fortran/ChangeLog: * dependency.cc (check_data_pointer_types): Do not just compare for derived type, but for same derived type. gcc/testsuite/ChangeLog: * gfortran.dg/forall_20.f90: New test.
2025-03-10Daily bump.GCC Administrator1-0/+8
2025-03-09Use gfc_commit_symbol() to remove UNDO status instead of new function.Thomas Koenig3-8/+2
This is a cleaner version, removing an unneeded function and making sure that no memory leaks can occur if callers change. gcc/fortran/ChangeLog: PR fortran/119157 * gfortran.h (gfc_pop_undo_symbol): Remove prototype. * interface.cc (gfc_get_formal_from_actual_arglist): Use gfc_commit_symbol() instead of gfc_pop_undo_symbol(). * symbol.cc (gfc_pop_undo_symbol): Remove.
2025-03-09Daily bump.GCC Administrator1-0/+17