aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
AgeCommit message (Collapse)AuthorFilesLines
2024-08-24Daily bump.GCC Administrator1-0/+45
2024-08-23Revert "Fortran: Fix class transformational intrinsic calls [PR102689]"Paul Thomas2-168/+35
This reverts commit 4cb07a38233aadb4b389a6e5236c95f52241b6e0.
2024-08-23fortran: Minor fix to -ffrontend-optimize descriptionGerald Pfeifer1-1/+1
gcc/fortran: * invoke.texi (Code Gen Options): Add a missing word.
2024-08-23Remove unnecessary view_convert obsoleted by [PR86468].Andre Vehreschild1-3/+1
This patch removes an unnecessary view_convert in trans_associate to prevent hard to find runtime errors in the future. The view_convert was erroneously introduced not understanding why ranks of the arrays to assign are different. The ranks are fixed by PR86468 now and the view_convert is obsolete. gcc/fortran/ChangeLog: PR fortran/86468 * trans-stmt.cc (trans_associate_var): Remove superfluous view_convert.
2024-08-22Daily bump.GCC Administrator1-0/+15
2024-08-21Fix coarray rank for non-coarrays in derived types. [PR86468]Andre Vehreschild2-8/+12
The corank was propagated to array components in derived types. Fix this by setting a zero corank when the array component is not a pointer. For pointer typed array components propagate the corank of the derived type to allow associating the component to a coarray. gcc/fortran/ChangeLog: PR fortran/86468 * trans-intrinsic.cc (conv_intrinsic_move_alloc): Correct comment. * trans-types.cc (gfc_sym_type): Pass coarray rank, not false. (gfc_get_derived_type): Only propagate codimension for coarrays and pointers to array components in derived typed coarrays. gcc/testsuite/ChangeLog: * gfortran.dg/coarray_lib_this_image_2.f90: Fix array rank in tree dump scan. * gfortran.dg/coarray_lib_token_4.f90: Same. * gfortran.dg/coarray/move_alloc_2.f90: New test.
2024-08-21Fortran: Fix ICE in sizeof(coarray) [PR77518]Andre Vehreschild1-3/+10
Use se's class_container where present in sizeof(). PR fortran/77518 gcc/fortran/ChangeLog: * trans-intrinsic.cc (gfc_conv_intrinsic_sizeof): Use class_container of se when set. gcc/testsuite/ChangeLog: * gfortran.dg/coarray/sizeof_1.f90: New test.
2024-08-21Daily bump.GCC Administrator1-0/+12
2024-08-20Fortran: Fix [Coarray] ICE in conv_caf_send, at ↵Andre Vehreschild3-30/+28
fortran/trans-intrinsic.c:1950 [PR84246] Fix ICE caused by converted expression already being pointer by checking for its type. Lift rewrite to caf_send completely into resolve and prevent more temporary arrays. PR fortran/84246 gcc/fortran/ChangeLog: * resolve.cc (caf_possible_reallocate): Detect arrays that may be reallocated by caf_send. (resolve_ordinary_assign): More reliably detect assignments where a rewrite to caf_send is needed. * trans-expr.cc (gfc_trans_assignment_1): Remove rewrite to caf_send, because this is done by resolve now. * trans-intrinsic.cc (conv_caf_send): Prevent unneeded temporary arrays. libgfortran/ChangeLog: * caf/single.c (send_by_ref): Created array's lbound is now 1 and the offset set correctly. gcc/testsuite/ChangeLog: * gfortran.dg/coarray_allocate_7.f08: Adapt to array being allocate by caf_send.
2024-08-20Daily bump.GCC Administrator1-0/+16
2024-08-19Allow coarrays in select type. [PR46371, PR56496]Andre Vehreschild2-7/+7
Fix ICE when scalar coarrays are used in a select type. Prevent coindexing in associate/select type/select rank selector expression. gcc/fortran/ChangeLog: PR fortran/46371 PR fortran/56496 * expr.cc (gfc_is_coindexed): Detect is coindexed also when rewritten to caf_get. * trans-stmt.cc (trans_associate_var): Always accept a descriptor for coarrays. gcc/testsuite/ChangeLog: * gfortran.dg/coarray/select_type_1.f90: New test. * gfortran.dg/coarray/select_type_2.f90: New test. * gfortran.dg/coarray/select_type_3.f90: New test.
2024-08-19Fix ICE in recompute_tree_invariant_for_addr_expr, at tree.c:4535 [PR84244]Andre Vehreschild1-1/+5
Declaring an unused function with a derived type having a pointer component and using that derived type as a coarray, lead the compiler to ICE because the caf_token for the pointer was not linked into the component correctly. PR fortran/84244 gcc/fortran/ChangeLog: * trans-types.cc (gfc_get_derived_type): When a caf_sub_token is generated for a component, link it to the component it is generated for (the previous one). gcc/testsuite/ChangeLog: * gfortran.dg/coarray/ptr_comp_5.f08: New test.
2024-08-17Daily bump.GCC Administrator1-0/+6
2024-08-16Fortran: fix documentation of intrinsic RANDOM_INIT [PR114146]Harald Anlauf1-6/+6
gcc/fortran/ChangeLog: PR fortran/114146 * intrinsic.texi: Fix documentation of arguments of RANDOM_INIT, which is conforming to the F2018 standard.
2024-08-16Daily bump.GCC Administrator1-0/+109
2024-08-15fortran: Fix bootstrap in resolve.cc [PR116387]Jakub Jelinek1-1/+1
The r15-2934 change broke bootstrap: ../../gcc/fortran/resolve.cc: In function ‘bool resolve_operator(gfc_expr*)’: ../../gcc/fortran/resolve.cc:4649:22: error: too many arguments for format [-Werror=format-extra-args] 4649 | gfc_error ("Inconsistent coranks for operator at %%L and %%L", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The following patch fixes that by using %L rather than %%L, the call has 2 location arguments. 2024-08-15 Jakub Jelinek <jakub@redhat.com> PR bootstrap/116387 * resolve.cc (resolve_operator): Use %L rather than %%L in format string.
2024-08-15Fix Coarray in associate not a coarray. [PR110033]Andre Vehreschild5-45/+127
A coarray used in an associate did not become a coarray in the block of the associate. This patch fixes that and the same also in select type statements. PR fortran/110033 gcc/fortran/ChangeLog: * class.cc (gfc_is_class_scalar_expr): Coarray refs that ref only self, aka this image, are regarded as scalar, too. * resolve.cc (resolve_assoc_var): Ignore this image coarray refs and do not build a new class type. * trans-expr.cc (gfc_get_caf_token_offset): Get the caf token from the descriptor for associated variables. (gfc_conv_variable): Same. (gfc_trans_pointer_assignment): Assign token to temporary associate variable, too. (gfc_trans_scalar_assign): Add flag that assign is for associate and use it to assign the token. (is_assoc_assign): Detect that expressions are for associate assign. (gfc_trans_assignment_1): Treat associate assigns like pointer assignments where possible. * trans-stmt.cc (trans_associate_var): Set same_class only for class-targets. * trans.h (gfc_trans_scalar_assign): Add flag to trans_scalar_assign for marking associate assignments. gcc/testsuite/ChangeLog: * gfortran.dg/coarray/associate_1.f90: New test.
2024-08-15Add corank to gfc_expr.Andre Vehreschild23-200/+450
Compute the corank of an expression along side to the regular rank. This safe costly calls to gfc_get_corank (), which consecutively has been removed. In some locations the code needed some adaption to model the difference between expr.corank and gfc_get_corank correctly. The latter always returned the codimension of the expression and not its current corank, i.e. the resolution of all indezes. This commit is preparatory to fixing PR fortran/110033 and may contain parts of that fix already. gcc/fortran/ChangeLog: * arith.cc (reduce_unary): Use expr.corank. (reduce_binary_ac): Same. (reduce_binary_ca): Same. (reduce_binary_aa): Same. * array.cc (gfc_match_array_ref): Same. * check.cc (dim_corank_check): Same. (gfc_check_move_alloc): Same. (gfc_check_image_index): Same. * class.cc (gfc_add_class_array_ref): Same. (finalize_component): Same. * data.cc (gfc_assign_data_value): Same. * decl.cc (match_clist_expr): Same. (add_init_expr_to_sym): Same. * expr.cc (simplify_intrinsic_op): Same. (simplify_parameter_variable): Same. (gfc_check_assign_symbol): Same. (gfc_get_variable_expr): Same. (gfc_add_full_array_ref): Same. (gfc_lval_expr_from_sym): Same. (gfc_get_corank): Removed. * frontend-passes.cc (callback_reduction): Use expr.corank. (create_var): Same. (combine_array_constructor): Same. (optimize_minmaxloc): Same. * gfortran.h (gfc_get_corank): Add corank to gfc_expr. * intrinsic.cc (gfc_get_intrinsic_function_symbol): Use expr.corank. (gfc_convert_type_warn): Same. (gfc_convert_chartype): Same. * iresolve.cc (resolve_bound): Same. (gfc_resolve_cshift): Same. (gfc_resolve_eoshift): Same. (gfc_resolve_logical): Same. (gfc_resolve_matmul): Same. * match.cc (copy_ts_from_selector_to_associate): Same. * matchexp.cc (gfc_get_parentheses): Same. * parse.cc (parse_associate): Same. * primary.cc (gfc_match_rvalue): Same. * resolve.cc (resolve_structure_cons): Same. (resolve_actual_arglist): Same. (resolve_elemental_actual): Same. (resolve_generic_f0): Same. (resolve_unknown_f): Same. (resolve_operator): Same. (gfc_expression_rank): Same and set dimen_type for coarray to default. (gfc_op_rank_conformable): Use expr.corank. (add_caf_get_intrinsic): Same. (resolve_variable): Same. (gfc_fixup_inferred_type_refs): Same. (check_host_association): Same. (resolve_compcall): Same. (resolve_expr_ppc): Same. (resolve_assoc_var): Same. (fixup_array_ref): Same. (resolve_select_type): Same. (add_comp_ref): Same. (get_temp_from_expr): Same. (resolve_fl_var_and_proc): Same. (resolve_symbol): Same. * symbol.cc (gfc_is_associate_pointer): Same. * trans-array.cc (walk_coarray): Same. (gfc_conv_expr_descriptor): Same. (gfc_walk_array_ref): Same. * trans-array.h (gfc_walk_array_ref): Same. * trans-expr.cc (gfc_get_ultimate_alloc_ptr_comps_caf_token): Same. * trans-intrinsic.cc (trans_this_image): Same. (trans_image_index): Same. (conv_intrinsic_cobound): Same. (gfc_walk_intrinsic_function): Same. (conv_intrinsic_move_alloc): Same. * trans-stmt.cc (gfc_trans_lock_unlock): Same. (trans_associate_var): Same and adapt to slightly different behaviour of expr.corank and gfc_get_corank. (gfc_trans_allocate): Same. * trans.cc (gfc_add_finalizer_call): Same.
2024-08-15Daily bump.GCC Administrator1-0/+18
2024-08-14Fortran: fix minor frontend GMP leaksHarald Anlauf2-3/+9
gcc/fortran/ChangeLog: * simplify.cc (gfc_simplify_sizeof): Clear used gmp variable. * target-memory.cc (gfc_target_expr_size): Likewise.
2024-08-14Prevent future proc_ptr parsing issues in associate [PR102973]Andre Vehreschild1-0/+1
A global variable is set when proc_ptr parsing in an associate is expected. In the case of an error, that flag was not reset, which is fixed now. gcc/fortran/ChangeLog: PR fortran/102973 * match.cc (gfc_match_associate): Reset proc_ptr parsing flag on error.
2024-08-14Fix ICE in build_function_decl [PR116292]Andre Vehreschild1-3/+17
Fix ICE by getting the vtype only when a derived or class type is prevent. Also take care about the _len component for unlimited polymorphics. gcc/fortran/ChangeLog: PR fortran/116292 * trans-intrinsic.cc (conv_intrinsic_move_alloc): Get the vtab only for derived types and classes and adjust _len for class types. gcc/testsuite/ChangeLog: * gfortran.dg/move_alloc_19.f90: New test.
2024-08-14Daily bump.GCC Administrator1-0/+7
2024-08-13Fortran: reject array constructor value of abstract type [PR114308]Harald Anlauf1-0/+13
gcc/fortran/ChangeLog: PR fortran/114308 * array.cc (resolve_array_list): Reject array constructor value if its declared type is abstract (F2018:C7114). gcc/testsuite/ChangeLog: PR fortran/114308 * gfortran.dg/abstract_type_10.f90: New test. Co-Authored-By: Steven G. Kargl <kargl@gcc.gnu.org>
2024-08-13Daily bump.GCC Administrator1-0/+8
2024-08-12Fortran: Fix coarray in associate not linking [PR85510]Andre Vehreschild2-5/+7
PR fortran/85510 gcc/fortran/ChangeLog: * resolve.cc (resolve_variable): Mark the variable as host associated only, when it is not in an associate block. * trans-decl.cc (generate_coarray_init): Remove incorrect unused flag on parameter. gcc/testsuite/ChangeLog: * gfortran.dg/coarray/pr85510.f90: New test.
2024-08-12Daily bump.GCC Administrator1-0/+6
2024-08-11Fortran: silence Wmaybe-uninitialized warnings for LTO build [PR116221]Harald Anlauf2-2/+2
PR fortran/116221 gcc/fortran/ChangeLog: * intrinsic.cc (gfc_get_intrinsic_sub_symbol): Initialize variable. * symbol.cc (gfc_get_ha_symbol): Likewise.
2024-08-08Daily bump.GCC Administrator1-0/+12
2024-08-07OpenMP: Constructors and destructors for "declare target" static aggregatesTobias Burnus5-0/+35
This commit also compile-time expands (__builtin_)omp_is_initial_device for both Fortran and C/C++ (unless, -fno-builtin-omp_is_initial_device is used). But the main change is: This commit adds support for running constructors and destructors for static (file-scope) aggregates for C++ objects which are marked with "declare target" directives on OpenMP offload targets. Before this commit, space is allocated on the target for such aggregates, but nothing ever constructs them properly, so they end up zero-initialised. (See the new test static-aggr-constructor-destructor-3.C for a reason why running constructors on the target is preferable to e.g. constructing on the host and then copying the resulting object to the target.) 2024-08-07 Julian Brown <julian@codesourcery.com> Tobias Burnus <tobias@baylibre.com> gcc/ChangeLog: * builtins.def (DEF_GOMP_BUILTIN_COMPILER): Define DEF_GOMP_BUILTIN_COMPILER to handle the non-prefix version. * gimple-fold.cc (gimple_fold_builtin_omp_is_initial_device): New. (gimple_fold_builtin): Call it. * omp-builtins.def (BUILT_IN_OMP_IS_INITIAL_DEVICE): Define. * tree.cc (get_file_function_name): Support names for on-target constructor/destructor functions. gcc/cp/ * decl2.cc (tree-inline.h): Include. (static_init_fini_fns): Bump to four entries. Update comment. (start_objects, start_partial_init_fini_fn): Add 'omp_target' parameter. Support "declare target" decls. Update forward declaration. (emit_partial_init_fini_fn): Add 'host_fn' parameter. Return tree for the created function. Support "declare target". (OMP_SSDF_IDENTIFIER): New macro. (partition_vars_for_init_fini): Support partitioning "declare target" variables also. (generate_ctor_or_dtor_function): Add 'omp_target' parameter. Support "declare target" decls. (c_parse_final_cleanups): Support constructors/destructors on OpenMP offload targets. gcc/fortran/ChangeLog: * gfortran.h (gfc_option_t): Add disable_omp_is_initial_device. * lang.opt (fbuiltin-): Add. * options.cc (gfc_handle_option): Handle -fno-builtin-omp_is_initial_device. * f95-lang.cc (gfc_init_builtin_functions): Handle DEF_GOMP_BUILTIN_COMPILER. * trans-decl.cc (gfc_get_extern_function_decl): Add code to use DEF_GOMP_BUILTIN_COMPILER for 'omp_is_initial_device'. libgomp/ChangeLog: * testsuite/libgomp.c++/static-aggr-constructor-destructor-1.C: New test. * testsuite/libgomp.c++/static-aggr-constructor-destructor-2.C: New test. * testsuite/libgomp.c++/static-aggr-constructor-destructor-3.C: New test. * testsuite/libgomp.c-c++-common/target-is-initial-host.c: New test. * testsuite/libgomp.c-c++-common/target-is-initial-host-2.c: New test. * testsuite/libgomp.fortran/target-is-initial-host.f: New test. * testsuite/libgomp.fortran/target-is-initial-host.f90: New test. * testsuite/libgomp.fortran/target-is-initial-host-2.f90: New test. Co-authored-by: Tobias Burnus <tobias@baylibre.com>
2024-08-07Daily bump.GCC Administrator1-0/+39
2024-08-06Fortran: Eliminate error prone translations.Jerry DeLisle1-88/+88
PR fortran/109105 gcc/fortran/ChangeLog: * resolve.cc (CHECK_INTERFACES): New helper macro. (resolve_operator): Replace use of snprintf with gfc_error.
2024-08-06Fortran: Fix class transformational intrinsic calls [PR102689]Paul Thomas2-35/+168
2024-08-06 Paul Thomas <pault@gcc.gnu.org> gcc/fortran PR fortran/102689 * trans-array.cc (get_array_ref_dim_for_loop_dim): Use the arg1 class container carried in ss->info as the seed for a lhs in class valued transformational intrinsic calls that are not the rhs of an assignment. Otherwise, the lhs variable expression is taken from the loop chain. For this latter case, the _vptr and _len fields are set. (gfc_trans_create_temp_array): Use either the lhs expression seeds to build a class variable that will take the returned descriptor as its _data field. In the case that the arg1 expr. is used, a class typespec must be built with the correct rank and the _vptr and _len fields set. The element size is provided for the temporary allocation and to set the descriptor span. (gfc_array_init_size): When an intrinsic type scalar expr3 is used in allocation of a class array, use its element size in the descriptor dtype. * trans-expr.cc (gfc_conv_class_to_class): Class valued transformational intrinsics return the pointer to the array descriptor as the _data field of a class temporary. Extract directly and return the address of the class temporary. (gfc_conv_procedure_call): store the expression for the first argument of a class valued transformational intrinsic function in the ss info class_container field. Later, use its type as the element type in the call to gfc_trans_create_temp_array. (fcncall_realloc_result): Add a dtype argument and use it in the descriptor, when available. (gfc_trans_arrayfunc_assign): For class lhs, build a dtype with the lhs rank and the rhs element size and use it in the call to fcncall_realloc_result. gcc/testsuite/ PR fortran/102689 * gfortran.dg/class_transformational_1.f90: New test for class- valued reshape. * gfortran.dg/class_transformational_2.f90: New test for other class_valued transformational intrinsics.
2024-08-03Daily bump.GCC Administrator1-0/+14
2024-08-02Fortran: Fix ICE on invalid in gfc_format_decoder.Steve Kargl1-6/+10
PR fortran/104626 gcc/fortran/ChangeLog: * symbol.cc (gfc_add_save): Add checks for SAVE attribute conflicts and duplicate SAVE attribute. gcc/testsuite/ChangeLog: * gfortran.dg/pr104626.f90: New test.
2024-08-02fortran: Support optional dummy as BACK argument of MINLOC/MAXLOC.Mikael Morin1-14/+69
Protect the evaluation of BACK with a check that the reference is non-null in case the expression is an optional dummy, in the inline code generated for MINLOC and MAXLOC. This change contains a revert of the non-testsuite part of commit r15-1994-ga55d24b3cf7f4d07492bb8e6fcee557175b47ea3, which factored the evaluation of BACK out of the loop using the scalarizer. It was a bad idea, because delegating the argument evaluation to the scalarizer makes it cumbersome to add a null pointer check next to the evaluation. Instead, evaluate BACK at the beginning, before scalarization, add a check that the argument is present if necessary, and evaluate the resulting expression to a variable, before using the variable in the inline code. gcc/fortran/ChangeLog: * trans-intrinsic.cc (maybe_absent_optional_variable): New function. (gfc_conv_intrinsic_minmaxloc): Remove BACK from scalarization and evaluate it before. Add a check that BACK is not null if the expression is an optional dummy. Save the resulting expression to a variable. Use the variable in the generated inline code. gcc/testsuite/ChangeLog: * gfortran.dg/maxloc_6.f90: New test. * gfortran.dg/minloc_7.f90: New test.
2024-08-02Daily bump.GCC Administrator1-0/+6
2024-08-01fortran: Fix up pasto in gfc_get_array_descr_infoJakub Jelinek1-5/+2
A static analyzer found a pasto in gfc_get_array_descr_info. The code does t = base_decl; if (!integer_zerop (dtype_off)) t = fold_build_pointer_plus (t, dtype_off); dtype = TYPE_MAIN_VARIANT (get_dtype_type_node ()); field = gfc_advance_chain (TYPE_FIELDS (dtype), GFC_DTYPE_RANK); rank_off = byte_position (field); if (!integer_zerop (dtype_off)) t = fold_build_pointer_plus (t, rank_off); i.e. uses the same !integer_zerop check between both, while it should be checking rank_off in the latter case. This actually doesn't change anything on the generated code, because both the dtype_off and rank_off aren't zero, typedef struct dtype_type { size_t elem_len; int version; signed char rank; signed char type; signed short attribute; } dtype_type; struct { type *base_addr; size_t offset; dtype_type dtype; index_type span; descriptor_dimension dim[]; }; dtype_off is 16 on 64-bit arches and 8 on 32-bit ones and rank_off is 12 on 64-bit arches and 8 on 32-bit arches, so this patch is just to pacify those static analyzers or be prepared if the ABI changes in the future. Because in the current ABI both of those are actually non-zero, doing if (!integer_zerop (something)) t = fold_build_pointer_plus (t, something); actually isn't an optimization, it will consume more compile time. If the ABI changes and we forget to readd it, nothing bad happens, fold_build_pointer_plus handles 0 addends fine, just takes some compile time to handle that. I've kept this if (!integer_zerop (data_off)) guard earlier because data_off is 0 in the current ABI, so it is an optimization there. 2024-08-01 Jakub Jelinek <jakub@redhat.com> * trans-types.cc (gfc_get_array_descr_info): Don't test if !integer_zerop (dtype_off), use fold_build_pointer_plus unconditionally.
2024-07-30Daily bump.GCC Administrator1-0/+12
2024-07-29OpenMP/Fortran: Fix handling of 'declare target' with 'link' clause [PR115559]Tobias Burnus2-26/+76
Contrary to a normal 'declare target', the 'declare target link' attribute also needs to set node->offloadable and push the offload_vars in the front end. Linked variables require that the data is mapped. For module variables, this can happen anywhere. For variables in an external subprograms or the main programm, this can only happen in the either that program itself or in an internal subprogram. - Whether a variable is just normally mapped or linked then becomes relevant if a device routine exists that can access that variable, i.e. an internal procedure has then to be marked as declare target. PR fortran/115559 gcc/fortran/ChangeLog: * trans-common.cc (build_common_decl): Add 'omp declare target' and 'omp declare target link' variables to offload_vars. * trans-decl.cc (add_attributes_to_decl): Likewise; update args and call decl_attributes. (get_proc_pointer_decl, gfc_get_extern_function_decl, build_function_decl): Update calls. (gfc_get_symbol_decl): Likewise; move after 'DECL_STATIC (t)=1' to avoid errors with symtab_node::get_create. libgomp/ChangeLog: * testsuite/libgomp.fortran/declare-target-link.f90: New test.
2024-07-23Daily bump.GCC Administrator1-0/+7
2024-07-22Fix Rejects allocatable coarray passed as a dummy argument [88624]Andre Vehreschild1-10/+25
Coarray parameters of procedures/functions need to be dereffed, because they are references to the descriptor but the routine expected the descriptor directly. PR fortran/88624 gcc/fortran/ChangeLog: * trans-expr.cc (gfc_conv_procedure_call): Treat pointers/references (e.g. from parameters) correctly by derefing them. gcc/testsuite/ChangeLog: * gfortran.dg/coarray/dummy_1.f90: Add calling function trough function. * gfortran.dg/pr88624.f90: New test.
2024-07-22Daily bump.GCC Administrator1-0/+10
2024-07-21Fortran: Fix regression caused by r14-10477 [PR59104]Paul Thomas3-1/+10
2024-07-21 Paul Thomas <pault@gcc.gnu.org> gcc/fortran PR fortran/59104 * gfortran.h : Add decl_order to gfc_symbol. * symbol.cc : Add static next_decl_order.. (gfc_set_sym_referenced): Set symbol decl_order. * trans-decl.cc : Include dependency.h. (decl_order): Replace symbol declared_at.lb->location with decl_order. gcc/testsuite/ PR fortran/59104 * gfortran.dg/dependent_decls_3.f90: New test.
2024-07-20Daily bump.GCC Administrator1-0/+9
2024-07-19Fortran: character array constructor with >= 4 constant elements [PR103115]Harald Anlauf1-1/+3
gcc/fortran/ChangeLog: PR fortran/103115 * trans-array.cc (gfc_trans_array_constructor_value): If the first element of an array constructor is deferred-length character and therefore does not have an element size known at compile time, do not try to collect subsequent constant elements into a constructor for optimization. gcc/testsuite/ChangeLog: PR fortran/103115 * gfortran.dg/string_array_constructor_4.f90: New test.
2024-07-19Daily bump.GCC Administrator1-0/+58
2024-07-18Fortran: Fix Explicit cobounds of a procedures parameter not respected [PR78466]Andre Vehreschild10-37/+172
Explicit cobounds of class array procedure parameters were not taken into account. Furthermore were different cobounds in distinct procedure parameter lists mixed up, i.e. the last definition was taken for all. The bounds are now regenerated when tree's and expr's bounds do not match. PR fortran/78466 PR fortran/80774 gcc/fortran/ChangeLog: * array.cc (gfc_compare_array_spec): Take cotype into account. * class.cc (gfc_build_class_symbol): Coarrays are also arrays. * gfortran.h (IS_CLASS_COARRAY_OR_ARRAY): New macro to detect regular and coarray class arrays. * interface.cc (compare_components): Take codimension into account. * resolve.cc (resolve_symbol): Improve error message. * simplify.cc (simplify_bound_dim): Remove duplicate. * trans-array.cc (gfc_trans_array_cobounds): Coarrays are also arrays. (gfc_trans_array_bounds): Same. (gfc_trans_dummy_array_bias): Same. (get_coarray_as): Get the as having a non-zero codim. (is_explicit_coarray): Detect explicit coarrays. (gfc_conv_expr_descriptor): Create a new descriptor for explicit coarrays. * trans-decl.cc (gfc_build_qualified_array): Coarrays are also arrays. (gfc_build_dummy_array_decl): Same. (gfc_get_symbol_decl): Same. (gfc_trans_deferred_vars): Same. * trans-expr.cc (class_scalar_coarray_to_class): Get the descriptor from the correct location. (gfc_conv_variable): Pick up the descriptor when needed. * trans-types.cc (gfc_is_nodesc_array): Coarrays are also arrays. (gfc_get_nodesc_array_type): Indentation fix only. (cobounds_match_decl): Match a tree's bounds to the expr's bounds and return true, when they match. (gfc_get_derived_type): Create a new type tree/descriptor, when the cobounds of the existing declaration and expr to not match. This happends for class arrays in parameter list, when there are different cobound declarations. gcc/testsuite/ChangeLog: * gfortran.dg/coarray/poly_run_1.f90: Activate old test code. * gfortran.dg/coarray/poly_run_2.f90: Activate test. It was stopping before and passing without an error.
2024-07-18Fortran: Suppress bogus used uninitialized warnings [PR108889].Paul Thomas2-0/+47
2024-07-18 Paul Thomas <pault@gcc.gnu.org> gcc/fortran PR fortran/108889 * gfortran.h: Add bit field 'allocated_in_scope' to gfc_symbol. * trans-array.cc (gfc_array_allocate): Set 'allocated_in_scope' after allocation if not a component reference. (gfc_alloc_allocatable_for_assignment): If 'allocated_in_scope' not set, not a component ref and not allocated, set the array bounds and offset to give zero length in all dimensions. Then set allocated_in_scope. gcc/testsuite/ PR fortran/108889 * gfortran.dg/pr108889.f90: New test.
2024-07-18Fortran: Use char* for deferred length character arrays [PR82904]Andre Vehreschild2-3/+7
Randomly during compiling the pass IPA: inline would ICE. This was caused by a saved deferred length string. The length variable was not set, but the variable was used in the array's declaration. Now using a character pointer to prevent this. PR fortran/82904 gcc/fortran/ChangeLog: * trans-types.cc (gfc_sym_type): Use type `char*` for saved deferred length char arrays. * trans.cc (get_array_span): Get `.span` also for `char*` typed arrays, i.e. for those that have INTEGER_TYPE instead of ARRAY_TYPE. gcc/testsuite/ChangeLog: * gfortran.dg/deferred_character_38.f90: New test.