aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
AgeCommit message (Collapse)AuthorFilesLines
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
2025-03-08Fix regression with -Wexternal-argument-mismatch.Thomas Koenig3-1/+9
The attached patch fixes an ICE regresseion where undo state was not handled properly when generating formal from actual arguments, which occurred under certain conditions with the newly introduced -Wexternal-argument-mismatch option. The fix is simple: When we are generating these symbols, we no longer need to undo anything, so we can just remove them. I had considered adding an extra optional argument, but decided against it on code clarity grounds. While looking at the code, I also saw that a member of gfc_symbol introduced with my patch should be a bitfield of width 1. gcc/fortran/ChangeLog: PR fortran/119157 * gfortran.h (gfc_symbol): Make ext_dummy_arglist_mismatch a one-bit bitfield (gfc_pop_undo_symbol): Declare prototype. * symbol.cc (gfc_pop_undo_symbol): New function. * interface.cc (gfc_get_formal_from_actual_arglist): Call it for artificially introduced formal variables. gcc/testsuite/ChangeLog: PR fortran/119157 * gfortran.dg/interface_57.f90: New test.
2025-03-07Fortran: Fix ICE in resolve.cc with -pedanticJerry DeLisle1-1/+3
Fixes an ICE in gfc_resolve_code when passing an optional array to an elemental procedure with `-pedantic` enabled. PR95446 added the original check, this patch fixes the case where the other actual argument is an array literal (or something else other than a variable). PR fortran/119054 gcc/fortran/ChangeLog: * resolve.cc (resolve_elemental_actual): When checking other actual arguments to elemental procedures, don't check attributes of literals and function calls. gcc/testsuite/ChangeLog: * gfortran.dg/pr95446.f90: Expand test case to literals and function calls. Signed-off-by: Peter Hill <peter.hill@york.ac.uk>
2025-03-07Daily bump.GCC Administrator1-0/+10
2025-03-06Fortran: improve checking of substring bounds [PR119118]Harald Anlauf3-2/+84
After the fix for pr98490 no substring bounds check was generated if the substring start was not a variable. While the purpose of that fix was to suppress a premature check before implied-do indices were substituted, this prevented a check if the substring start was an expression or a constant. A better solution is to defer the check until implied-do indices have been substituted in the start and end expressions. PR fortran/119118 gcc/fortran/ChangeLog: * dependency.cc (gfc_contains_implied_index_p): Helper function to determine if an expression has a dependence on an implied-do index. * dependency.h (gfc_contains_implied_index_p): Add prototype. * trans-expr.cc (gfc_conv_substring): Adjust logic to not generate substring bounds checks before implied-do indices have been substituted. gcc/testsuite/ChangeLog: * gfortran.dg/bounds_check_23.f90: Generalize test. * gfortran.dg/bounds_check_26.f90: New test.
2025-03-06Daily bump.GCC Administrator1-0/+11
2025-03-05Regenerate fortran/lang.opt.urlsMark Wielaard1-0/+3
fortran added a new -Wexternal-argument-mismatch option, but the lang.opt.urls file wasn't regenerated. Fixes: 21ca9153ebe5 ("C prototypes for external arguments; add warning for mismatch.") gcc/fortran/ChangeLog: * lang.opt.urls: Regenerated.
2025-03-05Fortran: Add view convert to pointer assign when only pointer/alloc attr ↵Andre Vehreschild1-1/+9
differs [PR104684] PR fortran/104684 gcc/fortran/ChangeLog: * trans-array.cc (gfc_conv_expr_descriptor): Look at the lang-specific akind and do a view convert when only the akind attribute differs between pointer and allocatable array. gcc/testsuite/ChangeLog: * gfortran.dg/coarray/ptr_comp_6.f08: New test.
2025-03-05Daily bump.GCC Administrator1-0/+40
2025-03-04C prototypes for external arguments; add warning for mismatch.Thomas Koenig5-37/+162
The problem was that we were not handling external dummy arguments with -fc-prototypes-external. In looking at this, I found that we were not warning about external procedures with different argument lists. This can actually be legal (see the two test cases) but creates a problem for the C prototypes: If we have something like subroutine foo(a,n) external a if (n == 1) call a(1) if (n == 2) call a(2,3) end subroutine foo then, pre-C23, we could just have written out the prototype as void foo_ (void (*a) (), int *n); but this is illegal in C23. What to do? I finally chose to warn about the argument mismatch, with a new option. Warn only because the code above is legal, but include in -Wall because such code seems highly suspect. This option is also implied in -fc-prototypes-external. I also put a warning in the generated header file in that case, so users have a chance to see what is going on (especially since gcc now defaults to C23). gcc/fortran/ChangeLog: PR fortran/119049 PR fortran/119074 * dump-parse-tree.cc (seen_conflict): New static varaible. (gfc_dump_external_c_prototypes): Initialize it. If it was set, write out a warning that -std=c23 will not work. (write_proc): Move the work of actually writing out the formal arglist to... (write_formal_arglist): New function. Handle external dummy parameters and their argument lists. If there were mismatched arguments, output an empty argument list in pre-C23 style. * gfortran.h (struct gfc_symbol): Add ext_dummy_arglist_mismatch flag and formal_at. * invoke.texi: Document -Wexternal-argument-mismatch. * lang.opt: Put it in. * resolve.cc (resolve_function): If warning about external argument mismatches, build a formal from actual arglist the first time around, and later compare and warn. (resolve_call): Likewise gcc/testsuite/ChangeLog: PR fortran/119049 PR fortran/119074 * gfortran.dg/interface_55.f90: New test. * gfortran.dg/interface_56.f90: New test.
2025-03-04Fortran: Fix gimplification error on assignment to pointer [PR103391]Andre Vehreschild1-8/+8
PR fortran/103391 gcc/fortran/ChangeLog: * trans-expr.cc (gfc_trans_assignment_1): Do not use poly assign for pointer arrays on lhs (as it is done for allocatables already). gcc/testsuite/ChangeLog: * gfortran.dg/assign_12.f90: New test.
2025-03-04Fortran: Prevent ICE when getting caf-token from abstract type [PR77872]Andre Vehreschild1-0/+5
PR fortran/77872 gcc/fortran/ChangeLog: * trans-expr.cc (gfc_get_tree_for_caf_expr): Pick up token from decl when it is present there for class types. gcc/testsuite/ChangeLog: * gfortran.dg/coarray/class_1.f90: New test.
2025-03-04Fortran: Reduce code complexity [PR77872]Andre Vehreschild1-11/+3
PR fortran/77872 gcc/fortran/ChangeLog: * trans-expr.cc (gfc_conv_procedure_call): Use attr instead of doing type check and branching for BT_CLASS.
2025-03-04Daily bump.GCC Administrator1-0/+16
2025-03-03Fortran: reject empty derived type with bind(C) attribute [PR101577]Harald Anlauf1-3/+20
PR fortran/101577 gcc/fortran/ChangeLog: * symbol.cc (verify_bind_c_derived_type): Generate error message for derived type with no components in standard conformance mode, indicating that this is a GNU extension. gcc/testsuite/ChangeLog: * gfortran.dg/empty_derived_type.f90: Adjust dg-options. * gfortran.dg/empty_derived_type_2.f90: New test.
2025-03-03Fortran: Fix regression on double free on elemental function [PR118747]Andre Vehreschild2-10/+14
Fix a regression were adding a temporary variable inserted a copy of the argument to the elemental function. That copy was then later used to free allocated memory, but the freeing was not tracked in the source array correctly. PR fortran/118747 gcc/fortran/ChangeLog: * trans-array.cc (gfc_trans_array_ctor_element): Remove copy to temporary variable. * trans-expr.cc (gfc_conv_procedure_call): Use references to array members instead of copies when freeing after use. Formatting fix. gcc/testsuite/ChangeLog: * gfortran.dg/alloc_comp_auto_array_4.f90: New test.
2025-03-03Daily bump.GCC Administrator1-0/+31
2025-03-02Fortran: Small fixes in intrinsic.texi.Sandra Loosemore1-13/+13
gcc/fortran/ChangeLog * intrinsic.texi: Fix inconsistent capitalization of argument names and other minor copy-editing.
2025-03-02Fortran: Move "Standard" subheading in documentation [PR47928]Sandra Loosemore1-923/+923
As noted in the issue, the version of the standard an intrinsic was introduced in is usually not the second-most-important thing a user needs to know. This patch moves it from near the beginning of each section towards the end, just ahead of "See also". gcc/fortran/ChangeLog PR fortran/47928 * intrinsic.texi: Move the "Standard" subheading farther down.
2025-03-02Fortran: Rename/move "Syntax" subheading in documentation [PR47928]Sandra Loosemore2-1159/+1159
As suggested in the issue, it makes more sense to describe the function call argument syntax before talking about the arguments in the description. gcc/fortran/ChangeLog PR fortran/47928 * gfortran.texi: Move all the "Syntax" subheadings ahead of "Description", and rename to "Synopsis". * intrinsic.texi: Likewise.
2025-03-02Fortran: Whitespace cleanup in documentation [PR47928]Sandra Loosemore1-19/+15
This is a preparatory patch for the main changes requested in the issue. gcc/fortran/ChangeLog PR fortran/47928 * intrinsic.texi: Put a blank line between "@item @emph{}" subheadings, but not more than one.
2025-03-02Fortran: Tidy subheadings in Fortran documentation [PR47928]Sandra Loosemore2-49/+48
This is a preparatory patch for the main documentation changes requested in the issue. gcc/fortran/ChangeLog PR fortran/47928 * gfortran.texi: Consistently use "@emph{Notes}:" instead of other spellings. * intrinsic.texi: Likewise. Also fix an inconsistent capitalization and remove a redundant "Standard" entry.
2025-03-02Daily bump.GCC Administrator1-0/+6
2025-03-01Fortran: fix front-end memleak after failure during parsing of NULLIFYHarald Anlauf2-0/+3
gcc/fortran/ChangeLog: * match.cc (gfc_match_nullify): Free matched expression when cleaning up. * primary.cc (match_variable): Initialize result to NULL.
2025-03-01Daily bump.GCC Administrator1-0/+6
2025-02-28Fortran: Ensure finalizer is called for unreferenced variable [PR118730]Andre Vehreschild1-0/+8
PR fortran/118730 gcc/fortran/ChangeLog: * resolve.cc: Mark unused derived type variable with finalizers referenced to execute finalizer when leaving scope. gcc/testsuite/ChangeLog: * gfortran.dg/class_array_15.f03: Remove unused variable. * gfortran.dg/coarray_poly_7.f90: Adapt scan-tree-dump expr. * gfortran.dg/coarray_poly_8.f90: Same. * gfortran.dg/finalize_60.f90: New test.
2025-02-28Daily bump.GCC Administrator1-0/+6
2025-02-27Fortran: Fix ICE on associate of pointer [PR118789]Andre Vehreschild1-1/+6
Fix ICE when associating a pointer to void (c_ptr) by looking at the compatibility of the type hierarchy. PR fortran/118789 gcc/fortran/ChangeLog: * trans-stmt.cc (trans_associate_var): Compare pointed to types when expr to associate is already a pointer. gcc/testsuite/ChangeLog: * gfortran.dg/associate_73.f90: New test.
2025-02-27Daily bump.GCC Administrator1-0/+5
2025-02-26Fortran: Remove SAVE_EXPR on lhs in assign [PR108233]Andre Vehreschild1-5/+8
With vectorial shaped datatypes like e.g. complex numbers, fold_convert inserts a SAVE_EXPR. Using that on the lhs in an assignment prevented the update of the variable, when in a coarray. PR fortran/108233 gcc/fortran/ChangeLog: * trans-expr.cc (gfc_trans_assignment_1): Remove SAVE_EXPR on lhs. gcc/testsuite/ChangeLog: * gfortran.dg/coarray/complex_1.f90: New test.
2025-02-26Daily bump.GCC Administrator1-0/+17
2025-02-25Fortran: Fix detection of descriptor arrays in coarray [PR107635]Andre Vehreschild2-11/+34
Look at the formal arguments generated type in the function declaration to figure if an argument is a descriptor arrays. Fix handling of class types while splitting coarray expressions. PR fortran/107635 gcc/fortran/ChangeLog: * coarray.cc (fixup_comp_refs): For class types set correct component (class) type. (split_expr_at_caf_ref): Provide location. * trans-intrinsic.cc (conv_caf_send_to_remote): Look at generated formal argument and not declared one to detect descriptor arrays. (conv_caf_sendget): Same.
2025-02-25Fortran: Use correct size when transferring between images [PR107635]Andre Vehreschild1-3/+6
gcc/fortran/ChangeLog: PR fortran/107635 * trans-intrinsic.cc (conv_caf_sendget): Use the size of data transferred between the two images and not the descritor's size.
2025-02-22Daily bump.GCC Administrator1-0/+20
2025-02-21Fortran: initialize non-saved pointers with -fcheck=pointer [PR48958]Harald Anlauf1-2/+5
PR fortran/48958 gcc/fortran/ChangeLog: * trans-array.cc (gfc_trans_deferred_array): Initialize the data component of non-saved pointers when -fcheck=pointer is set. gcc/testsuite/ChangeLog: * gfortran.dg/pointer_init_13.f90: New test.
2025-02-21Fortran: Improve gfc_array_kind for assumed rank; gfc_tree_array_size on 'tree'Tobias Burnus4-44/+90
Improve the internal and debug representation of assumed-rank arrays by honoring the pointer and allocatable property. Permit obtaining the array size from only a tree (via the array descriptor) besides obtaining it from the gfc_expr's array spec. This will be used by a follow up OpenMP patch for mapping derived types with allocatable components. gcc/fortran/ChangeLog: * trans-array.cc (gfc_full_array_size): Obtain the rank from the array descriptor for assumed rank. (gfc_tree_array_size): Likewise; permit expr = NULL to operate only the tree. (gfc_conv_descriptor_stride_get): Update for added assumed-rank array types. * trans-openmp.cc (gfc_omp_finish_clause): Likewise. * trans-types.cc (gfc_build_array_type, gfc_get_derived_type, gfc_get_array_descr_info): Likewise. * trans.h (enum gfc_array_kind): Add GFC_ARRAY_ASSUMED_RANK_{ALLOCATABLE,POINTER{,_CONT}}.
2025-02-21Daily bump.GCC Administrator1-0/+152
2025-02-20Fortran: Remove deprecated coarray routines [PR107635]Andre Vehreschild4-1494/+0
gcc/fortran/ChangeLog: PR fortran/107635 * gfortran.texi: Remove deprecated functions from documentation. * trans-decl.cc (gfc_build_builtin_function_decls): Remove decprecated function decls. * trans-intrinsic.cc (gfc_conv_intrinsic_exponent): Remove deprecated/no longer needed routines. * trans.h: Remove unused decls. libgfortran/ChangeLog: * caf/libcaf.h (_gfortran_caf_get): Removed because deprecated. (_gfortran_caf_send): Same. (_gfortran_caf_sendget): Same. (_gfortran_caf_send_by_ref): Same. * caf/single.c (assign_char4_from_char1): Same. (assign_char1_from_char4): Same. (convert_type): Same. (defined): Same. (_gfortran_caf_get): Same. (_gfortran_caf_send): Same. (_gfortran_caf_sendget): Same. (copy_data): Same. (get_for_ref): Same. (_gfortran_caf_get_by_ref): Same. (send_by_ref): Same. (_gfortran_caf_send_by_ref): Same. (_gfortran_caf_sendget_by_ref): Same.
2025-02-20Fortran: Add transfer_between_remotes [PR107635]Andre Vehreschild6-1071/+1433
Add the last missing coarray data manipulation routine using remote accessors. gcc/fortran/ChangeLog: PR fortran/107635 * coarray.cc (rewrite_caf_send): Rewrite to transfer_between_remotes when both sides of the assignment have a coarray. (coindexed_code_callback): Prevent duplicate rewrite. * gfortran.texi: Add documentation for transfer_between_remotes. * intrinsic.cc (add_subroutines): Add intrinsic symbol for caf_sendget to allow easy rewrite to transfer_between_remotes. * trans-decl.cc (gfc_build_builtin_function_decls): Add prototype for transfer_between_remotes. * trans-intrinsic.cc (conv_caf_vector_subscript_elem): Mark as deprecated. (conv_caf_vector_subscript): Same. (compute_component_offset): Same. (conv_expr_ref_to_caf_ref): Same. (conv_stat_and_team): Extract stat and team from expr. (gfc_conv_intrinsic_caf_get): Use conv_stat_and_team. (conv_caf_send_to_remote): Same. (has_ref_after_cafref): Mark as deprecated. (conv_caf_sendget): Translate to transfer_between_remotes. * trans.h: Add prototype for transfer_between_remotes. libgfortran/ChangeLog: * caf/libcaf.h: Add prototype for transfer_between_remotes. * caf/single.c: Implement transfer_between_remotes. gcc/testsuite/ChangeLog: * gfortran.dg/coarray_lib_comm_1.f90: Fix up scan_trees.
2025-02-20Fortran: Add send_to_remote [PR107635]Andre Vehreschild7-62/+641
Refactor to use send_to_remote instead of the slow send_by_ref. gcc/fortran/ChangeLog: PR fortran/107635 * coarray.cc (move_coarray_ref): Move the coarray reference out of the given one. Especially when there is a regular array ref. (fixup_comp_refs): Move components refs to a derived type where the codim has been removed, aka a new type. (split_expr_at_caf_ref): Correctly split the reference chain. (remove_caf_ref): Simplify. (create_get_callback): Fix some deficiencies. (create_allocated_callback): Adapt to new signature of split. (create_send_callback): New function. (rewrite_caf_send): Rewrite a call to caf_send to caf_send_to_remote. (coindexed_code_callback): Treat caf_send and caf_sendget correctly. * gfortran.h (enum gfc_isym_id): Add SENDGET-isym. * gfortran.texi: Add documentation for send_to_remote. * resolve.cc (gfc_resolve_code): No longer generate send_by_ref when allocatable coarray (component) is on the lhs. * trans-decl.cc (gfc_build_builtin_function_decls): Add caf_send_to_remote decl. * trans-intrinsic.cc (conv_caf_func_index): Ensure the static variables created are not in a block-scope. (conv_caf_send_to_remote): Translate caf_send_to_remote calls. (conv_caf_send): Renamed to conv_caf_sendget. (conv_caf_sendget): Renamed from conv_caf_send. (gfc_conv_intrinsic_subroutine): Branch correctly for conv_caf_send and sendget. * trans.h: Correct decl. libgfortran/ChangeLog: * caf/libcaf.h: Add/Correct prototypes for caf_get_from_remote, caf_send_to_remote. * caf/single.c (struct accessor_hash_t): Rename accessor_t to getter_t. (_gfortran_caf_register_accessor): Use new name of getter_t. (_gfortran_caf_send_to_remote): New function for sending data to coarray on a remote image. gcc/testsuite/ChangeLog: * gfortran.dg/coarray/send_char_array_1.f90: Extend test to catch more cases. * gfortran.dg/coarray_42.f90: Invert tests use, because no longer a send is needed when local memory in a coarray is allocated.
2025-02-20Fortran: Add caf_is_present_on_remote. [PR107635]Andre Vehreschild7-84/+264
Replace caf_is_present by caf_is_present_on_remote which is using a dedicated callback for each object to test on the remote image. gcc/fortran/ChangeLog: PR fortran/107635 * coarray.cc (create_allocated_callback): Add creating remote side procedure for checking allocation status of coarray. (rewrite_caf_allocated): Rewrite ALLOCATED on coarray to use caf routine. (coindexed_expr_callback): Exempt caf_is_present_on_remote from being rewritten again. * gfortran.h (enum gfc_isym_id): Add caf_is_present_on_remote id. * gfortran.texi: Add documentation for caf_is_present_on_remote. * intrinsic.cc (add_functions): Add caf_is_present_on_remote symbol. * trans-decl.cc (gfc_build_builtin_function_decls): Define interface of caf_is_present_on_remote. * trans-intrinsic.cc (gfc_conv_intrinsic_caf_is_present_remote): Translate caf_is_present_on_remote. (trans_caf_is_present): Remove. (caf_this_image_ref): Remove. (gfc_conv_allocated): Take out coarray treatment, because that is rewritten to caf_is_present_on_remote now. (gfc_conv_intrinsic_function): Handle caf_is_present_on_remote calls. * trans.h: Add symbol for caf_is_present_on_remote and remove old one. libgfortran/ChangeLog: * caf/libcaf.h (_gfortran_caf_is_present_on_remote): Add new function. (_gfortran_caf_is_present): Remove deprecated one. * caf/single.c (struct accessor_hash_t): Add function ptr access for remote side call. (_gfortran_caf_is_present_on_remote): Added. (_gfortran_caf_is_present): Removed. gcc/testsuite/ChangeLog: * gfortran.dg/coarray/coarray_allocated.f90: Adapt to new method of checking on remote image. * gfortran.dg/coarray_lib_alloc_4.f90: Same.
2025-02-20Fortran: Allow to use non-pure/non-elemental functions in coarray indexes ↵Andre Vehreschild2-140/+420
[PR107635] Extract calls to non-pure or non-elemental functions from index expressions on a coarray. gcc/fortran/ChangeLog: PR fortran/107635 * coarray.cc (get_arrayspec_from_expr): Treat array result of function calls correctly. (remove_coarray_from_derived_type): Prevent memory loss. (add_caf_get_from_remote): Correct locus. (find_comp): New function to find or create a new component in a derived type. (check_add_new_comp_handle_array): Handle allocatable arrays or non-pure/non-elemental functions in indexes of coarrays. (check_add_new_component): Use above function. (create_get_parameter_type): Rename to create_caf_add_data_parameter_type. (create_caf_add_data_parameter_type): Renaming of variable and make the additional data a coarray. (remove_caf_ref): Factor out to reuse in other caf-functions. (create_get_callback): Use function factored out, set locus correctly and ensure a kind is set for parameters. (add_caf_get_intrinsic): Rename to add_caf_get_from_remote and rename some variables. (coindexed_expr_callback): Skip over function created by the rewriter. (coindexed_code_callback): Filter some intrinsics not to process. (gfc_coarray_rewrite): Rewrite also contained functions. * trans-intrinsic.cc (gfc_conv_intrinsic_caf_get): Reflect changed order on caf_get_from_remote (). libgfortran/ChangeLog: * caf/libcaf.h (_gfortran_caf_register_accessor): Reflect changed parameter order. * caf/single.c (struct accessor_hash_t): Same. (_gfortran_caf_register_accessor): Call accessor using a token for accessing arrays with a descriptor on the source side. gcc/testsuite/ChangeLog: * gfortran.dg/coarray_lib_comm_1.f90: Adapt scan expression. * gfortran.dg/coarray/get_with_fn_parameter.f90: New test. * gfortran.dg/coarray/get_with_scalar_fn.f90: New test.