aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
AgeCommit message (Collapse)AuthorFilesLines
2023-07-07Update ChangeLog and version files for releasereleases/gcc-10.5.0releases/gcc-10Richard Biener1-0/+4
2023-06-10Daily bump.GCC Administrator1-0/+10
2023-06-09fortran: Fix ICE on pr96024.f90 on big-endian hosts [PR96024]Jakub Jelinek1-1/+2
The pr96024.f90 testcase ICEs on big-endian hosts. The problem is that length->val.integer is accessed after checking length->expr_type == EXPR_CONSTANT, but it is a CHARACTER constant which uses length->val.character union member instead and on big-endian we end up reading constant 0x100000000 rather than some small number on little-endian and if target doesn't have enough memory for 4 times that (i.e. 16GB allocation), it ICEs. 2023-06-09 Jakub Jelinek <jakub@redhat.com> PR fortran/96024 * primary.c (gfc_convert_to_structure_constructor): Only do constant string ctor length verification and truncation/padding if constant length has INTEGER type. (cherry picked from commit 4cf6e322adc19f927859e0a5edfa93cec4b8c844)
2023-05-04Daily bump.GCC Administrator1-0/+18
2023-05-03fortran: Fix up hash table usage in gfc_trans_use_stmts [PR108451]Jakub Jelinek1-1/+5
The first testcase in the PR (which I haven't included in the patch because it is unclear to me if it is supposed to be valid or not) ICEs since extra hash table checking has been added recently. The problem is that gfc_trans_use_stmts does tree *slot = entry->decls->find_slot_with_hash (rent->use_name, hash, INSERT); if (*slot == NULL) and later on doesn't store anything into *slot and continues. Another spot a few lines later correctly clears the slot if it decides not to use the slot, so the following patch does the same. 2023-02-03 Jakub Jelinek <jakub@redhat.com> PR fortran/108451 * trans-decl.c (gfc_trans_use_stmts): Call clear_slot before doing continue. (cherry picked from commit 76f7f0eddcb7c418d1ec3dea3e2341ca99097301)
2023-05-03fortran: Fix up function types for realloc and sincos{,f,l} builtins [PR108349]Jakub Jelinek1-18/+20
As reported in the PR, the FUNCTION_TYPE for __builtin_realloc in the Fortran FE is wrong since r0-100026-gb64fca63690ad which changed -  tmp = tree_cons (NULL_TREE, pvoid_type_node, void_list_node); -  tmp = tree_cons (NULL_TREE, size_type_node, tmp); -  ftype = build_function_type (pvoid_type_node, tmp); +  ftype = build_function_type_list (pvoid_type_node, +                                    size_type_node, pvoid_type_node, +                                    NULL_TREE);    gfc_define_builtin ("__builtin_realloc", ftype, BUILT_IN_REALLOC,                       "realloc", false); The return type is correct, void *, but the first argument should be void * too and only second one size_t, while the above change changed realloc to be void *__builtin_realloc (size_t, void *); I went through all other changes from that commit and found that __builtin_sincos{,f,l} got broken as well, instead of the former void __builtin_sincos{,f,l} (ftype, ftype *, ftype *); where ftype is {double,float,long double} it is now incorrectly void __builtin_sincos{,f,l} (ftype *, ftype *); The following patch fixes that, plus some formatting issues around the spots I've changed. 2023-01-11 Jakub Jelinek <jakub@redhat.com> PR fortran/108349 * f95-lang.c (gfc_init_builtin_function): Fix up function types for BUILT_IN_REALLOC and BUILT_IN_SINCOS{F,,L}. Formatting fixes. (cherry picked from commit 0986c351aa8a9f08b3cb614baec13564dd62c114)
2023-04-17Daily bump.GCC Administrator1-0/+10
2023-04-16Fortran: fix compile-time simplification of SET_EXPONENT [PR109511]Harald Anlauf1-6/+6
gcc/fortran/ChangeLog: PR fortran/109511 * simplify.c (gfc_simplify_set_exponent): Fix implementation of compile-time simplification of intrinsic SET_EXPONENT for argument X < 1 and for I < 0. gcc/testsuite/ChangeLog: PR fortran/109511 * gfortran.dg/set_exponent_1.f90: New test. (cherry picked from commit fa4cb42870df60deb8888dbd51e2ddc6d6ab9e6a)
2023-03-25Daily bump.GCC Administrator1-0/+18
2023-03-24Fortran: simplification of NEAREST for large argument [PR109186]Harald Anlauf1-1/+1
gcc/fortran/ChangeLog: PR fortran/109186 * simplify.c (gfc_simplify_nearest): Fix off-by-one error in setting up real kind-specific maximum exponent for mpfr. gcc/testsuite/ChangeLog: PR fortran/109186 * gfortran.dg/nearest_6.f90: New test. (cherry picked from commit 4410a08b80cc40342eeaa5b6af824cd4352b218c)
2023-03-24Fortran: procedures with BIND(C) attribute require explicit interface [PR85877]Harald Anlauf1-0/+10
gcc/fortran/ChangeLog: PR fortran/85877 * resolve.c (resolve_fl_procedure): Check for an explicit interface of procedures with the BIND(C) attribute (F2018:15.4.2.2). gcc/testsuite/ChangeLog: PR fortran/85877 * gfortran.dg/pr85877.f90: New test. (cherry picked from commit 5426ab34643d9e6502f3ee572891a03471fa33ed)
2023-03-18Daily bump.GCC Administrator1-0/+18
2023-03-17Fortran: fix bounds check for copying of class expressions [PR106945]Harald Anlauf1-0/+1
In the bounds check for copying of class expressions, the number of elements determined from a descriptor, returned as type gfc_array_index_type (i.e. a signed type), should be converted to the type of the passed element count, which is of type size_type_node (i.e. unsigned), for use in comparisons. gcc/fortran/ChangeLog: PR fortran/106945 * trans-expr.c (gfc_copy_class_to_class): Convert element counts in bounds check to common type for comparison. gcc/testsuite/ChangeLog: PR fortran/106945 * gfortran.dg/pr106945.f90: New test. (cherry picked from commit 2cf5f485e0351bb1faf46196a99e524688f3966e)
2023-03-17Fortran: fix ICE with bind(c) in block data [PR104332]Harald Anlauf1-2/+2
gcc/fortran/ChangeLog: PR fortran/104332 * resolve.c (resolve_symbol): Avoid NULL pointer dereference while checking a symbol with the BIND(C) attribute. gcc/testsuite/ChangeLog: PR fortran/104332 * gfortran.dg/bind_c_usage_34.f90: New test. (cherry picked from commit e20e5d9dc11b64e8eabce6803c91cb5768207083)
2023-03-06Daily bump.GCC Administrator1-0/+30
2023-03-05Fortran: fix corner case of IBITS intrinsic [PR108937]Harald Anlauf1-0/+10
gcc/fortran/ChangeLog: PR fortran/108937 * trans-intrinsic.c (gfc_conv_intrinsic_ibits): Handle corner case LEN argument of IBITS equal to BITSIZE(I). gcc/testsuite/ChangeLog: PR fortran/108937 * gfortran.dg/ibits_2.f90: New test. (cherry picked from commit 6cce953ebec274f1468d5d3a0697cf05bb43b8f6)
2023-03-05Fortran: reject invalid CHARACTER length of derived type components [PR96024]Harald Anlauf1-0/+13
gcc/fortran/ChangeLog: PR fortran/96024 * resolve.c (resolve_component): The type of a CHARACTER length expression must be INTEGER. gcc/testsuite/ChangeLog: PR fortran/96024 * gfortran.dg/pr96024.f90: New test. (cherry picked from commit 31303c9b5bab200754cdb7ef8cd91ae4918f3018)
2023-03-05Fortran: improve checking of character length specification [PR96025]Harald Anlauf2-12/+17
gcc/fortran/ChangeLog: PR fortran/96025 * parse.c (check_function_result_typed): Improve type check of specification expression for character length and return status. (parse_spec): Use status from above. * resolve.c (resolve_fntype): Prevent use of invalid specification expression for character length. gcc/testsuite/ChangeLog: PR fortran/96025 * gfortran.dg/pr96025.f90: New test. (cherry picked from commit 6c1b825b3d6499dfeacf7c79dcf4b56a393ac204)
2023-02-12Daily bump.GCC Administrator1-0/+31
2023-02-11Fortran: ASSOCIATE variables should not be TREE_STATIC [PR95107]Harald Anlauf1-0/+1
gcc/fortran/ChangeLog: PR fortran/95107 * trans-decl.c (gfc_finish_var_decl): With -fno-automatic, do not make ASSOCIATE variables TREE_STATIC. gcc/testsuite/ChangeLog: PR fortran/95107 * gfortran.dg/save_7.f90: New test. (cherry picked from commit c36f3da534e7f411c5bc48c5b6b660e238167480)
2023-02-11Fortran: error recovery on invalid array section [PR108609]Harald Anlauf1-1/+5
The testcase for PR108527 uncovered a latent issue with invalid array sections that resulted in different paths being taken on different architectures. Detect the invalid array declaration for a clean recovery. gcc/fortran/ChangeLog: PR fortran/108609 * expr.c (find_array_section): Add check to prevent interpreting an mpz non-integer constant as an integer. gcc/testsuite/ChangeLog: PR fortran/108609 * gfortran.dg/pr108527.f90: Adjust test pattern. (cherry picked from commit 88a2a09dd4529107e7ef7a6e7ce43acf96457173)
2023-02-11Fortran: fix ICE in compare_bound_int [PR108527]Harald Anlauf1-15/+14
gcc/fortran/ChangeLog: PR fortran/108527 * resolve.c (compare_bound_int): Expression to compare must be of type INTEGER. (compare_bound_mpz_t): Likewise. (check_dimension): Fix comment on checks applied to array section and clean up associated logic. gcc/testsuite/ChangeLog: PR fortran/108527 * gfortran.dg/pr108527.f90: New test. Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org> (cherry picked from commit 22afa4947584c701633a79fd8750c9ceeaa96711)
2023-02-06Daily bump.GCC Administrator1-0/+65
2023-02-05Fortran: ICE in transformational_result [PR108529]Harald Anlauf1-0/+1
gcc/fortran/ChangeLog: PR fortran/108529 * simplify.c (simplify_transformation): Do not try to simplify transformational intrinsic when the ARRAY argument has a NULL shape. gcc/testsuite/ChangeLog: PR fortran/108529 * gfortran.dg/pr108529.f90: New test. (cherry picked from commit 6c96382eed96a9285611f2e3e2e59557094172b8)
2023-02-05Fortran: error recovery for bad initializers of implied-shape arrays [PR106209]Harald Anlauf1-2/+13
gcc/fortran/ChangeLog: PR fortran/106209 * decl.c (add_init_expr_to_sym): Handle bad initializers for implied-shape arrays. gcc/testsuite/ChangeLog: PR fortran/106209 * gfortran.dg/pr106209.f90: New test. Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org> (cherry picked from commit 748f8a8b145dde59c7b63aa68b5a59515b7efc49)
2023-02-05Fortran: avoid ICE on invalid array subscript triplets [PR108501]Harald Anlauf1-7/+16
gcc/fortran/ChangeLog: PR fortran/108501 * interface.c (get_expr_storage_size): Check array subscript triplets that we actually have integer values before trying to extract with mpz_get_si. gcc/testsuite/ChangeLog: PR fortran/108501 * gfortran.dg/pr108501.f90: New test. (cherry picked from commit 771d793df1622a476e1cf8d05f0a6aee350fa56b)
2023-02-05Fortran: fix NULL pointer dereference in gfc_check_dependency [PR108502]Harald Anlauf1-0/+5
gcc/fortran/ChangeLog: PR fortran/108502 * dependency.c (gfc_check_dependency): Prevent NULL pointer dereference while recursively checking expressions. gcc/testsuite/ChangeLog: PR fortran/108502 * gfortran.dg/pr108502.f90: New test. (cherry picked from commit 51767f31878a95161142254dca7119b409699670)
2023-02-05Fortran: fix ICE in get_expr_storage_size [PR108421]Harald Anlauf1-1/+2
gcc/fortran/ChangeLog: PR fortran/108421 * interface.c (get_expr_storage_size): Check that we actually have an integer value before trying to extract it with mpz_get_si. gcc/testsuite/ChangeLog: PR fortran/108421 * gfortran.dg/pr108421.f90: New test. (cherry picked from commit a75760374ee54768e5fd6a27080698bfbbd041ab)
2023-02-05Fortran: fix ICE in check_charlen_present [PR108420]Harald Anlauf1-3/+6
gcc/fortran/ChangeLog: PR fortran/108420 * iresolve.c (check_charlen_present): Preserve character length if there is no array constructor. gcc/testsuite/ChangeLog: PR fortran/108420 * gfortran.dg/pr108420.f90: New test. (cherry picked from commit e6669c0a50ed8aee9e5997d61e6271668d149218)
2023-02-05Fortran: diagnose USE associated symbols in COMMON blocks [PR108453]Harald Anlauf1-0/+10
gcc/fortran/ChangeLog: PR fortran/108453 * match.c (gfc_match_common): A USE associated name shall not appear in a COMMON block (F2018:C8121). gcc/testsuite/ChangeLog: PR fortran/108453 * gfortran.dg/common_27.f90: New test. (cherry picked from commit aba9ff8f30d4245294ea2583de1dc28f1c7ccf7b)
2023-01-09Daily bump.GCC Administrator1-0/+10
2023-01-08Fortran: incorrect array bounds when bound intrinsic used in decl [PR108131]Harald Anlauf1-4/+0
gcc/fortran/ChangeLog: PR fortran/108131 * array.c (match_array_element_spec): Avoid too early simplification of matched array element specs that can lead to a misinterpretation when used as array bounds in array declarations. gcc/testsuite/ChangeLog: PR fortran/108131 * gfortran.dg/pr103505.f90: Adjust expected patterns. * gfortran.dg/pr108131.f90: New test. (cherry picked from commit 6a95f0e0a06d78d94138d4c3dd64d41591197281)
2022-12-19Daily bump.GCC Administrator1-0/+9
2022-12-18Fortran: ICE on recursive derived types with allocatable components [PR107872]Paul Thomas1-1/+2
gcc/fortran/ChangeLog: PR fortran/107872 * resolve.c (derived_inaccessible): Skip over allocatable components to prevent an infinite loop. gcc/testsuite/ChangeLog: PR fortran/107872 * gfortran.dg/pr107872.f90: New test. (cherry picked from commit 01254aa2eb766c7584fd047568d7277d4d65d067)
2022-11-26Daily bump.GCC Administrator1-0/+9
2022-11-25Fortran: reject NULL actual argument without explicit interface [PR107576]Harald Anlauf1-0/+8
gcc/fortran/ChangeLog: PR fortran/107576 * interface.c (gfc_procedure_use): Reject NULL as actual argument when there is no explicit procedure interface. gcc/testsuite/ChangeLog: PR fortran/107576 * gfortran.dg/null_actual_3.f90: New test. (cherry picked from commit 820c25c83561085f54268bd536f9d216d03c3e18)
2022-10-29Daily bump.GCC Administrator1-0/+9
2022-10-28Fortran: BOZ literal constants are not compatible to any type [PR103413]Harald Anlauf1-0/+4
gcc/fortran/ChangeLog: PR fortran/103413 * symbol.c (gfc_type_compatible): A boz-literal-constant has no type and thus is not considered compatible to any type. gcc/testsuite/ChangeLog: PR fortran/103413 * gfortran.dg/illegal_boz_arg_4.f90: New test. (cherry picked from commit f7d28818179247685f3c101f9f2f16366f56309b)
2022-10-24Daily bump.GCC Administrator1-0/+10
2022-10-23Fortran: error recovery with references of bad array constructors [PR105633]Harald Anlauf1-3/+7
gcc/fortran/ChangeLog: PR fortran/105633 * expr.c (find_array_section): Move check for NULL pointers so that both subscript triplets and vector subscripts are covered. gcc/testsuite/ChangeLog: PR fortran/105633 * gfortran.dg/pr105633.f90: New test. Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org> (cherry picked from commit ecb20df4fa6d99daa635c7fb662dc0554610777e)
2022-10-11Daily bump.GCC Administrator1-0/+31
2022-10-10fortran: Move clobbers after evaluation of all arguments [PR106817]Mikael Morin1-2/+4
For actual arguments whose dummy is INTENT(OUT), we used to generate clobbers on them at the same time we generated the argument reference for the function call. This was wrong if for an argument coming later, the value expression was depending on the value of the just- clobbered argument, and we passed an undefined value in that case. With this change, clobbers are collected separatedly and appended to the procedure call preliminary code after all the arguments have been evaluated. PR fortran/106817 gcc/fortran/ChangeLog: * trans-expr.c (gfc_conv_procedure_call): Collect all clobbers to their own separate block. Append the block of clobbers to the procedure preliminary block after the argument evaluation codes for all the arguments. gcc/testsuite/ChangeLog: * gfortran.dg/intent_optimize_4.f90: New test. (cherry picked from commit 29919bf3b6449bafd02e795abbb1966e3990c1fc)
2022-10-10fortran: Fix invalid function decl clobber ICE [PR105012]Mikael Morin1-1/+2
The fortran frontend, as result symbol for a function without declared result symbol, uses the function symbol itself. This caused an invalid clobber of a function decl to be emitted, leading to an ICE, whereas the intended behaviour was to clobber the function result variable. This change fixes the problem by getting the decl from the just-retrieved variable reference after the call to gfc_conv_expr_reference, instead of copying it from the frontend symbol. PR fortran/105012 gcc/fortran/ChangeLog: * trans-expr.c (gfc_conv_procedure_call): Retrieve variable from the just calculated variable reference. gcc/testsuite/ChangeLog: * gfortran.dg/intent_out_15.f90: New test. (cherry picked from commit edaf1e005c90b311c39b46d85cea17befbece112)
2022-10-10fortran: Move the clobber generation codeMikael Morin2-30/+33
This change inlines the clobber generation code from gfc_conv_expr_reference to the single caller from where the add_clobber flag can be true, and removes the add_clobber argument. What motivates this is the standard making the procedure call a cause for a variable to become undefined, which translates to a clobber generation, so clobber generation should be closely related to procedure call generation, whereas it is rather orthogonal to variable reference generation. Thus the generation of the clobber feels more appropriate in gfc_conv_procedure_call than in gfc_conv_expr_reference. Behaviour remains unchanged. gcc/fortran/ChangeLog: * trans.h (gfc_conv_expr_reference): Remove add_clobber argument. * trans-expr.c (gfc_conv_expr_reference): Ditto. Inline code depending on add_clobber and conditions controlling it ... (gfc_conv_procedure_call): ... to here. (cherry picked from commit 2b393f6f83903cb836676bbd042c1b99a6e7e6f7)
2022-10-09Daily bump.GCC Administrator1-0/+14
2022-10-08Fortran: Fix ICE and wrong code for assumed-rank arrays [PR100029, PR100040]José Rui Faustino de Sousa1-21/+27
gcc/fortran/ChangeLog: PR fortran/100040 PR fortran/100029 * trans-expr.c (gfc_conv_class_to_class): Add code to have assumed-rank arrays recognized as full arrays and fix the type of the array assignment. (gfc_conv_procedure_call): Change order of code blocks such that the free of ALLOCATABLE dummy arguments with INTENT(OUT) occurs first. gcc/testsuite/ChangeLog: PR fortran/100029 * gfortran.dg/PR100029.f90: New test. PR fortran/100040 * gfortran.dg/PR100040.f90: New test. (cherry picked from commit 5299155bb80e90df822e1eebc9f9a0c8e4505a46)
2022-10-02Daily bump.GCC Administrator1-0/+9
2022-10-01Fortran: Fix function attributes [PR100132]José Rui Faustino de Sousa1-2/+13
gcc/fortran/ChangeLog: PR fortran/100132 * trans-types.c (create_fn_spec): Fix function attributes when passing polymorphic pointers. gcc/testsuite/ChangeLog: PR fortran/100132 * gfortran.dg/PR100132.f90: New test. (cherry picked from commit be60aa5b608b5f09fadfeff852a46589ac311a42)
2022-10-01Daily bump.GCC Administrator1-0/+36
2022-09-30Fortran: error recovery while simplifying intrinsic UNPACK [PR107054]Harald Anlauf1-3/+10
gcc/fortran/ChangeLog: PR fortran/107054 * simplify.c (gfc_simplify_unpack): Replace assert by condition that terminates simplification when there are not enough elements in the constructor of argument VECTOR. gcc/testsuite/ChangeLog: PR fortran/107054 * gfortran.dg/pr107054.f90: New test. (cherry picked from commit 78bc6497fc61bbdacfb416ee0246a775360d9af6)