aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/resolve.c
AgeCommit message (Collapse)AuthorFilesLines
2020-12-08Fortran: Add 'omp scan' support of OpenMP 5.0Tobias Burnus1-0/+1
gcc/fortran/ChangeLog: * dump-parse-tree.c (show_omp_clauses, show_omp_node, show_code_node): Handle OMP SCAN. * gfortran.h (enum gfc_statement): Add ST_OMP_SCAN. (enum): Add OMP_LIST_SCAN_IN and OMP_LIST_SCAN_EX. (enum gfc_exec_op): Add EXEC_OMP_SCAN. * match.h (gfc_match_omp_scan): New prototype. * openmp.c (gfc_match_omp_scan): New. (gfc_match_omp_taskgroup): Cleanup. (resolve_omp_clauses, gfc_resolve_omp_do_blocks, omp_code_to_statement, gfc_resolve_omp_directive): Handle 'omp scan'. * parse.c (decode_omp_directive, next_statement, gfc_ascii_statement): Likewise. * resolve.c (gfc_resolve_code): Handle EXEC_OMP_SCAN. * st.c (gfc_free_statement): Likewise. * trans-openmp.c (gfc_trans_omp_clauses, gfc_trans_omp_do, gfc_split_omp_clauses): Handle 'omp scan'. libgomp/ChangeLog: * testsuite/libgomp.fortran/scan-1.f90: New test. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/reduction4.f90: Update; move FE some tests to ... * gfortran.dg/gomp/reduction6.f90: ... this new test and ... * gfortran.dg/gomp/reduction7.f90: ... this new test. * gfortran.dg/gomp/reduction5.f90: Add dg-error. * gfortran.dg/gomp/scan-1.f90: New test. * gfortran.dg/gomp/scan-2.f90: New test. * gfortran.dg/gomp/scan-3.f90: New test. * gfortran.dg/gomp/scan-4.f90: New test. * gfortran.dg/gomp/scan-5.f90: New test. * gfortran.dg/gomp/scan-6.f90: New test. * gfortran.dg/gomp/scan-7.f90: New test.
2020-12-05Fortran: flag formal argument before resolving an array spec [PR98016].Paul Thomas1-0/+4
2020-12-05 Paul Thomas <pault@gcc.gnu.org> gcc/fortran PR fortran/98016 * resolve.c (resolve_symbol): Set formal_arg_flag before resolving an array spec and restore value afterwards. gcc/testsuite/ PR fortran/98016 * gfortran.dg/pr98016.f90: New test.
2020-11-25PR fortran/85796 - Floating point exception with implied doHarald Anlauf1-2/+9
Catch invalid step=0 in implied do loop within data statements. gcc/fortran/ChangeLog: PR fortran/85796 * resolve.c (traverse_data_list): Fix copy&paste errors; catch step=0 in implied do loop. gcc/testsuite/ChangeLog: PR fortran/85796 * gfortran.dg/pr85796.f90: New test.
2020-11-03Fortran: Add !GCC$ attributes DEPRECATEDTobias Burnus1-0/+20
gcc/fortran/ChangeLog: * decl.c (ext_attr_list): Add EXT_ATTR_DEPRECATED. * gfortran.h (ext_attr_id_t): Ditto. * gfortran.texi (GCC$ ATTRIBUTES): Document it. * resolve.c (resolve_variable, resolve_function, resolve_call, resolve_values): Show -Wdeprecated-declarations warning. * trans-decl.c (add_attributes_to_decl): Skip those with no middle_end_name. gcc/testsuite/ChangeLog: * gfortran.dg/attr_deprecated.f90: New test.
2020-10-30Fortran: Update omp atomic for OpenMP 5Tobias Burnus1-5/+2
gcc/fortran/ChangeLog: * dump-parse-tree.c (show_omp_clauses): Handle atomic clauses. (show_omp_node): Call it for atomic. * gfortran.h (enum gfc_omp_atomic_op): Add GFC_OMP_ATOMIC_UNSET, remove GFC_OMP_ATOMIC_SEQ_CST and GFC_OMP_ATOMIC_ACQ_REL. (enum gfc_omp_memorder): Replace OMP_MEMORDER_LAST by OMP_MEMORDER_UNSET, add OMP_MEMORDER_SEQ_CST/OMP_MEMORDER_RELAXED. (gfc_omp_clauses): Add capture and atomic_op. (gfc_code): remove omp_atomic. * openmp.c (enum omp_mask1): Add atomic, capture, memorder clauses. (gfc_match_omp_clauses): Match them. (OMP_ATOMIC_CLAUSES): Add. (gfc_match_omp_flush): Update for 'last' to 'unset' change. (gfc_match_omp_oacc_atomic): Removed and placed content .. (gfc_match_omp_atomic): ... here. Update for OpenMP 5 clauses. (gfc_match_oacc_atomic): Match directly here. (resolve_omp_atomic, gfc_resolve_omp_directive): Update. * parse.c (parse_omp_oacc_atomic): Update for struct gfc_code changes. * resolve.c (gfc_resolve_blocks): Update assert. * st.c (gfc_free_statement): Also call for EXEC_O{ACC,MP}_ATOMIC. * trans-openmp.c (gfc_trans_omp_atomic): Update. (gfc_trans_omp_flush): Update for 'last' to 'unset' change. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/atomic-2.f90: New test. * gfortran.dg/gomp/atomic.f90: New test.
2020-10-27PR fortran/97491 - Wrong restriction for VALUE arguments of pure proceduresHarald Anlauf1-0/+1
A dummy argument with the VALUE attribute may be redefined in a PURE or ELEMENTAL procedure. Adjust the associated purity check. gcc/fortran/ChangeLog: * resolve.c (gfc_impure_variable): A dummy argument with the VALUE attribute may be redefined without making a procedure impure. gcc/testsuite/ChangeLog: * gfortran.dg/value_8.f90: New test.
2020-10-14Fortran : ICE in build_field PR95614Mark Eggleston1-0/+7
Local identifiers can not be the same as a module name. Original patch by Steve Kargl resulted in name clashes between common block names and local identifiers. A local identifier can be the same as a global identier if that identifier is not a module or a program. The original patch was modified to reject global identifiers that represent a module or a program. 2020-10-14 Steven G. Kargl <kargl@gcc.gnu.org> Mark Eggleston <markeggleston@gcc.gnu.org> gcc/fortran/ChangeLog: PR fortran/95614 * decl.c (gfc_get_common): Use gfc_match_common_name instead of match_common_name. * decl.c (gfc_bind_idents): Use gfc_match_common_name instead of match_common_name. * match.c : Rename match_common_name to gfc_match_common_name. * match.c (gfc_match_common): Use gfc_match_common_name instead of match_common_name. * match.h : Rename match_common_name to gfc_match_common_name. * resolve.c (resolve_common_vars): Check each symbol in a common block has a global symbol. If there is a global symbol issue an error if the symbol type is a module or a program. 2020-10-14 Mark Eggleston <markeggleston@gcc.gnu.org> gcc/testsuite/ChangeLog: PR fortran/95614 * gfortran.dg/pr95614_1.f90: New test. * gfortran.dg/pr95614_2.f90: New test. * gfortran.dg/pr95614_3.f90: New test. * gfortran.dg/pr95614_4.f90: New test.
2020-09-28Revert "Fortran : ICE in build_field PR95614"Mark Eggleston1-7/+0
This reverts commit e5a76af3a2f3324efc60b4b2778ffb29d5c377bc.
2020-09-27Fortran : ICE in build_field PR95614Mark Eggleston1-0/+7
Local identifiers can not be the same as a module name. Original patch by Steve Kargl resulted in name clashes between common block names and local identifiers. A local identifier can be the same as a global identier if that identifier represents a common. The patch was modified to allow global identifiers that represent a common block. 2020-09-27 Steven G. Kargl <kargl@gcc.gnu.org> Mark Eggleston <markeggleston@gcc.gnu.org> gcc/fortran/ PR fortran/95614 * decl.c (gfc_get_common): Use gfc_match_common_name instead of match_common_name. * decl.c (gfc_bind_idents): Use gfc_match_common_name instead of match_common_name. * match.c : Rename match_common_name to gfc_match_common_name. * match.c (gfc_match_common): Use gfc_match_common_name instead of match_common_name. * match.h : Rename match_common_name to gfc_match_common_name. * resolve.c (resolve_common_vars): Check each symbol in a common block has a global symbol. If there is a global symbol issue an error if the symbol type is known as is not a common block name. 2020-09-27 Mark Eggleston <markeggleston@gcc.gnu.org> gcc/testsuite/ PR fortran/95614 * gfortran.dg/pr95614_1.f90: New test. * gfortran.dg/pr95614_2.f90: New test.
2020-09-09Fortran: Fixes for OpenMP loop-iter privatization (PRs 95109 + 94690)Tobias Burnus1-0/+2
This commit also fixes a gfortran.dg/gomp/target1.f90 regression; target1.f90 tests the resolve.c and openmp.c changes. gcc/fortran/ChangeLog: PR fortran/95109 PR fortran/94690 * resolve.c (gfc_resolve_code): Also call gfc_resolve_omp_parallel_blocks for 'distribute parallel do (simd)'. * openmp.c (gfc_resolve_omp_parallel_blocks): Handle it. (gfc_resolve_do_iterator): Remove special code for SIMD, which is not needed. * trans-openmp.c (gfc_trans_omp_target): For TARGET_PARALLEL_DO_SIMD, call simd not do processing function. gcc/testsuite/ChangeLog: PR fortran/95109 PR fortran/94690 * gfortran.dg/gomp/combined-if.f90: Update scan-tree-dump-times for 'omp simd.*if'. * gfortran.dg/gomp/openmp-simd-5.f90: New test.
2020-09-07Fortran: Fixes for pointer function call as variable (PR96896)Tobias Burnus1-1/+3
gcc/fortran/ChangeLog: PR fortran/96896 * resolve.c (get_temp_from_expr): Also reset proc_pointer + use_assoc attribute. (resolve_ptr_fcn_assign): Use information from the LHS. gcc/testsuite/ChangeLog: PR fortran/96896 * gfortran.dg/ptr_func_assign_4.f08: Update dg-error. * gfortran.dg/ptr-func-3.f90: New test.
2020-09-07fortran: Fix arg types of _gfortran_is_extension_ofFrancois-Xavier Coudert1-0/+6
gcc/fortran/ChangeLog * resolve.c (resolve_select_type): Provide a formal arg list.
2020-09-01Fortran : ICE on invalid code PR95398Mark Eggleston1-1/+3
The CLASS_DATA macro is used to shorten the code accessing the derived components of an expressions type specification. If the type is not BT_CLASS the derived pointer is NULL resulting in an ICE. To avoid dereferencing a NULL pointer the type should be BT_CLASS. 2020-09-01 Steven G. Kargl <kargl@gcc.gnu.org> gcc/fortran PR fortran/95398 * resolve.c (resolve_select_type): Add check for BT_CLASS type before using the CLASS_DATA macro which will have a NULL pointer to derive components if it isn't BT_CLASS. 2020-09-01 Mark Eggleston <markeggleston@gcc.gnu.org> gcc/testsuite PR fortran/95398 * gfortran.dg/pr95398.f90: New test.
2020-08-10This patch fixes PR96102. See the explanatory comment in the testcase.Paul Thomas1-0/+10
2020-08-10 Paul Thomas <pault@gcc.gnu.org> gcc/fortran PR fortran/96102 * resolve.c (check_host_association): Replace the gcc_assert with an error for internal procedures. gcc/testsuite/ PR fortran/96102 * gfortran.dg/pr96102.f90: New test.
2020-07-13Fortran : accepts pointer initialization of DT dummy args PR45337Mark Eggleston1-2/+1
Initialisation of a variable results in an implicit save attribute being added to the variable. The save attribute is not allowed for variables with the dummy attribute set. Initialisation should be rejected for dummy variables. 2020-07-13 Mark Eggleston <markeggleston@gcc.gnu.org> gcc/fortran/ PR fortran/45337 * resolve.c (resolve_fl_variable): Remove type and intent checks from the check for dummy. 2020-07-13 Mark Eggleston <markeggleston@gcc.gnu.org> gcc/testsuite/ PR fortran/45337 * gfortran.dg/pr45337_1.f90: New test. * gfortran.dg/pr45337_2.f90: New test.
2020-07-10PR fortran/95980 - ICE in get_unique_type_string, at fortran/class.c:485Harald Anlauf1-5/+14
In SELECT TYPE, the argument may be an incorrectly specified unlimited CLASS variable. Avoid NULL pointer dereferences for clean error recovery. gcc/fortran/ PR fortran/95980 * class.c (gfc_add_component_ref, gfc_build_class_symbol): Add checks for NULL pointer dereference. * primary.c (gfc_variable_attr): Likewise. * resolve.c (resolve_variable, resolve_assoc_var) (resolve_fl_var_and_proc, resolve_fl_variable_derived) (resolve_symbol): Likewise.
2020-07-10PR fortran/96086 - ICE in gfc_match_select_rank, at fortran/match.c:6645Harald Anlauf1-1/+3
Handle NULL pointer dereference on SELECT RANK with an invalid assumed-rank array declaration. gcc/fortran/ PR fortran/96086 * match.c (gfc_match_select_rank): Catch NULL pointer dereference. * resolve.c (resolve_assoc_var): Catch NULL pointer dereference that may occur after an illegal declaration.
2020-07-08PR fortran/96085 - ICE in gfc_finish_var_decl, at fortran/trans-decl.c:694Harald Anlauf1-0/+1
Legacy ASSIGN requires a scalar integer variable. Reject parameter arguments. gcc/fortran/ PR fortran/96085 * resolve.c (gfc_resolve_code): Check whether assign target is a parameter.
2020-07-06PR fortran/95980 - ICE on using sync images with -fcheck=boundsHarald Anlauf1-1/+2
In SELECT TYPE, the argument may be an incorrectly specified unlimited polymorphic variable. Avoid a NULL pointer dereference for clean error recovery. gcc/fortran/ PR fortran/95980 * match.c (copy_ts_from_selector_to_associate, build_class_sym): Distinguish between unlimited polymorphic and ordinary variables to avoid NULL pointer dereference. * resolve.c (resolve_select_type): Distinguish between unlimited polymorphic and ordinary variables to avoid NULL pointer dereference.
2020-07-06PR fortran/95709 - ICE in gfc_resolve_code, at fortran/resolve.c:11807Harald Anlauf1-4/+12
The legacy "assigned GOTO" accepts only scalar integer variables. Check for proper arguments. gcc/fortran/ PR fortran/95709 * resolve.c (gfc_resolve_code): Check for valid arguments to assigned GOTO.
2020-07-05Test global identifiers against what is specified interfaces.Thomas Koenig1-0/+1
Apart from calling gfc_compare_interfaces to check interfaces against global identifiers, this also sets and check a few sym->error flags to avoid duplicate error messages. I thought about issuing errors on mismatched interfaces, but when the procedure is not invoked, a warning should be enough to alert the user. gcc/fortran/ChangeLog: PR fortran/27318 * frontend-passes.c (check_against_globals): New function. (gfc_check_externals): Split; also invoke check_against_globals via gfc_traverse_ns. (gfc_check_externals0): Recursive part formerly in gfc_check_externals. * resolve.c (resolve_global_procedure): Set sym->error on interface mismatch. * symbol.c (ambiguous_symbol): Check for, and set sym->error. gcc/testsuite/ChangeLog: PR fortran/27318 * gfortran.dg/error_recovery_1.f90: Adjust test case. * gfortran.dg/use_15.f90: Likewise. * gfortran.dg/interface_47.f90: New test.
2020-07-02PR fortran/93423 - ICE on invalid with argument list for module procedureHarald Anlauf1-1/+1
When recovering from an error, a NULL pointer dereference could occur. Check for that situation and punt. gcc/fortran/ PR fortran/93423 * resolve.c (resolve_symbol): Avoid NULL pointer dereference.
2020-07-01Fortran : Fortran translation issues PR52279Mark Eggleston1-8/+8
Mark strings for translation by enclosing in G_() and _(). 2020-06-24 Mark Eggleston <markeggleston@gcc.gnu.org> gcc/fortran/ PR fortran/52279 * arith.c (reduce_binary_aa): Mark for translation the string parameter to gfc_check_conformance with G_(). * check.c (gfc_invalid_boz): Mark hint for translation using _(). (gfc_check_achar): Mark for translation the message parameter to gfc_invalid_boz using G_(). (gfc_check_char): Mark for translation the message parameter to gfc_invalid_boz using G_(). (gfc_check_complex): Mark for translation the message parameter to gfc_invalid_boz using G_(). (gfc_check_float): Mark for translation the message parameter to gfc_invalid_boz using G_(). (check_rest): Mark for translation the string parameter to gfc_check_conformance with _(). (gfc_check_minloc_maxloc): Mark for translation the string parameter to gfc_check_conformance with _(). (gfc_check_findloc): Mark for translation the string parameter to gfc_check_conformance with _(). (check_reduction): Mark for translation the string parameter to gfc_check_conformance with _(). (gfc_check_pack): Mark for translation the string parameter to gfc_check_conformance with _(). * decl.c (match_old_style_init): Mark for translation the message parameter to gfc_invalid_boz using G_(). * expr.c (gfc_check_assign): Mark for translation the string parameter to gfc_check_conformance with _(). * intrinsic.c (check_specific): Mark for translation the string parameter to gfc_check_conformance with _(). (gfc_check_intrinsic_standard): Mark symstd_msg strings for translation using G_(). No need to mark symstd_msg for translation in call to gfc_warning or when setting symstd. * io.c (check_open_constraints): Mark strings for translation using G_() in all calls to warn_or_error. (match_io_element): Mark for translation the message parameter to gfc_invalid_boz using G_(). * primary.c (match_boz_constant): Mark for translation the message parameter to gfc_invalid_boz using G_(). * resolve.c (resolve_elemental_actual): Mark for translation the string parameter to gfc_check_conformance with _(). (resolve_operator): Mark for translation the string parameter to gfc_check_conformance with _(). Mark translation strings assigned to msg using G_() for use in a call to cfg_warning.
2020-07-01Fortran : False positive for optional arguments PR95446Mark Eggleston1-6/+22
Check that there is non-optional argument of the same rank in the list of actual arguments. If there is the warning is not required. 2020-07-01 Steven G. Kargl <kargl@gcc.gnu.org> gcc/fortran/ PR fortran/95446 * resolve.c (resolve_elemental_actual): Add code to check for non-optional argument of the same rank. Revise warning message to refer to the Fortran 2018 standard. 2020-07-01 Mark Eggleston <markeggleston@gcc.gnu.org> gcc/testsuite/ PR fortran/95446 * gfortran.dg/elemental_optional_args_6.f90: Remove check for warnings that were erroneously output. * gfortran.dg/pr95446.f90: New test.
2020-06-30PR fortran/88379 - ICE with allocatable coarray, class and associateHarald Anlauf1-1/+1
Catch NULL pointer dereference for ASSOCIATE on allocatable coarray variable. gcc/fortran/ PR fortran/88379 * resolve.c (resolve_assoc_var): Avoid NULL pointer dereference.
2020-06-27PR fortran/95881 - ICE in resolve_symbol, at fortran/resolve.c:15175Harald Anlauf1-0/+1
Avoid NULL pointer dereference. gcc/fortran/ PR fortran/95881 * resolve.c (resolve_symbol): Avoid NULL pointer dereference.
2020-06-25PR fortran/95828 - Buffer overflows with SELECT RANKHarald Anlauf1-1/+1
With SELECT RANK, name mangling results in long internal symbols that overflows internal buffers. Fix that. gcc/fortran/ PR fortran/95828 * match.c (select_rank_set_tmp): Enlarge internal buffer used in generating a mangled name. * resolve.c (resolve_select_rank): Likewise.
2020-06-25Fortran: Fix character-kind=4 substring resolution (PR95837)Tobias Burnus1-3/+0
Testing showed that it is always set and its value matches always ts->kind (if available) or otherwise, if it is a variable, the sym->ts.kind. gcc/fortran/ChangeLog: PR fortran/95837 * resolve.c (gfc_resolve_substring_charlen): Remove bogus ts.kind setting for the expression. gcc/testsuite/ChangeLog: PR fortran/95837 * gfortran.dg/char4-subscript.f90: New test.
2020-06-22Fortran : ICE in resolve_fl_procedure PR95708Mark Eggleston1-0/+1
Now issues an error "Intrinsic procedure 'num_images' not allowed in PROCEDURE" instead of an ICE. 2020-06-22 Steven G. Kargl <kargl@gcc.gnu.org> gcc/fortran/ PR fortran/95708 * intrinsic.c (add_functions): Replace CLASS_INQUIRY with CLASS_TRANSFORMATIONAL for intrinsic num_images. (make_generic): Replace ACTUAL_NO with ACTUAL_YES for intrinsic team_number. * resolve.c (resolve_fl_procedure): Check pointer ts.u.derived exists before using it. 2020-06-22 Mark Eggleston <markeggleston@gcc.gnu.org> gcc/testsuite/ PR fortran/95708 * gfortran.dg/pr95708.f90: New test.
2020-05-20Fortran : ProcPtr function results: 'ppr@' in error message PR39695Mark Eggleston1-2/+4
The value 'ppr@' is set in the name of result symbol, the actual name of the symbol is in the procedure name symbol pointed to by the result symbol's namespace (ns). When reporting errors for symbols that have the proc_pointer attribute check whether the result attribute is set and set the name accordingly. 2020-05-20 Mark Eggleston <markeggleston@gcc.gnu.org> gcc/fortran/ PR fortran/39695 * resolve.c (resolve_fl_procedure): Set name depending on whether the result attribute is set. For PROCEDURE/RESULT conflict use the name in sym->ns->proc_name->name. * symbol.c (gfc_add_type): Add check for function and result attributes use sym->ns->proc_name->name if both are set. Where the symbol cannot have a type use the name in sym->ns->proc_name->name. 2020-05-20 Mark Eggleston <markeggleston@gcc.gnu.org> gcc/testsuite/ PR fortran/39695 * gfortran.dg/pr39695_1.f90: New test. * gfortran.dg/pr39695_2.f90: New test. * gfortran.dg/pr39695_3.f90: New test. * gfortran.dg/pr39695_4.f90: New test.
2020-05-13Fortran : ICE in gfc_conv_array_constructor_expr PR93497Mark Eggleston1-1/+1
Invalid expressions, such as those involving array constructors, used for the length of character types will cause an ICE. 2020-05-13 Steven G. Kargl <kargl@gcc.gnu.org> gcc/fortran/ PR fortran/93497 * decl.c (char_len_param_value): Check whether character length expression is of type EXPR_OP and if so simplify it. * resolve.c (resolve_charlen): Reject length if it has a rank. 2020-05-13 Mark Eggleston <markeggleston@gcc.gnu.org> gcc/testsuite/ PR fortran/93497 * gfortran.dg/pr88025.f90: Change in wording of error. * gfortran.dg/pr93497.f90: New test. * gfortran.dg/pr93714_1.f90: Change in wording of errors. * gfortran.dg/pr93714_2.f90: Change in wording of errors.
2020-05-11Fortran : Spurious warning message with -Wsurprising PR59107Mark Eggleston1-4/+6
This change is from a patch developed for gcc-5. The code has moved on since then requiring a change to interface.c 2020-05-11 Janus Weil <janus@gcc.gnu.org> Dominique d'Humieres <dominiq@lps.ens.fr> gcc/fortran/ PR fortran/59107 * gfortran.h: Rename field resolved as resolve_symbol_called and assign two 2 bits instead of 1. * interface.c (check_dtio_interface1): Use new field name. (gfc_find_typebound_dtio_proc): Use new field name. * resolve.c (gfc_resolve_intrinsic): Replace check of the formal field with resolve_symbol_called is at least 2, if it is not set the field to 2. (resolve_typebound_procedure): Use new field name. (resolve_symbol): Use new field name and check whether it is at least 1, if it is not set the field to 1. 2020-05-11 Mark Eggleston <markeggleston@gcc.gnu.org> gcc/testsuite/ PR fortran/59107 * gfortran.dg/pr59107.f90: New test.
2020-04-19Fix PR fortran/93500, ICE on invalid.Thomas König1-0/+3
Returning &gfc_bad_expr when simplifying bounds after a divisin by zero happened results in the division by zero error actually reaching the user. 2020-04-19 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/93500 * resolve.c (resolve_operator): If both operands are NULL, return false. * simplify.c (simplify_bound): If a division by zero was seen during bound simplification, free the corresponcing expression and return &gfc_bad_expr. 2020-04-19 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/93500 * arith_divide_3.f90: New test.
2020-04-17Fix ICE on invalid, PR94090.Thomas König1-8/+14
The attached patch fixes an ICE on invalid: When the return type of a function was misdeclared with a wrong rank, we issued a warning, but not an error (unless with -pedantic); later on, an ICE ensued. Nothing good can come from wrongly declaring a function type (considering the ABI), so I changed that into a hard error. 2020-04-17 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/94090 * gfortran.dg (gfc_compare_interfaces): Add optional argument bad_result_characteristics. * interface.c (gfc_check_result_characteristics): Fix whitespace. (gfc_compare_interfaces): Handle new argument; return true if function return values are wrong. * resolve.c (resolve_global_procedure): Hard error if the return value of a function is wrong. 2020-04-17 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/94090 * gfortran.dg/interface_46.f90: New test.
2020-04-13ICE on wrong code [PR94192].Linus Koenig1-0/+1
The idea is not have another resolution of a pointer if an error has occurred previously. 2020-04-13 Linus Koenig <link@sig-st.de> PR fortran/94192 * resolve.c (resolve_fl_var_and_proc): Set flag "error" to 1 if pointer is found to not have an assumed rank or a deferred shape. * simplify.c (simplify_bound): If an error has been issued for a given pointer, one should not attempt to find its bounds. 2020-04-13 Linus Koenig <link@sig-st.de> PR fortran/94192 * gfortran.dg/bound_resolve_after_error_1.f90: New test.
2020-04-09PR fortran/87923 -- fix ICE when resolving I/O tags and simplify io.cFritz Reese1-11/+3
2020-04-06 Fritz Reese <foreese@gcc.gnu.org> This patch reorganizes I/O checking code. Checks which were done in the matching phase which do not affect the match result are moved to the resolution phase. Checks which were duplicated in both the matching phase and resolution phase have been reduced to one check in the resolution phase. Another section of code which used a global async_io_dt flag to check for and assign the asynchronous attribute to variables used in asynchronous I/O has been simplified. Furthermore, this patch improves error reporting and expands test coverage of I/O tags: - "TAG must be an initialization expression" reported by io.c (check_io_constraints) is replaced with an error from expr.c (gfc_reduce_init_expr) indicating _why_ the expression is not a valid initialization expression. - Several distinct error messages regarding the check for scalar + character + default kind have been unified to one message reported by resolve_tag or check_*_constraints. gcc/fortran/ChangeLog: 2020-04-09 Fritz Reese <foreese@gcc.gnu.org> PR fortran/87923 * gfortran.h (gfc_resolve_open, gfc_resolve_close): Add locus parameter. (gfc_resolve_dt): Add code parameter. * io.c (async_io_dt, check_char_variable, is_char_type): Removed. (resolve_tag_format): Add locus to error message regarding zero-sized array in FORMAT tag. (check_open_constraints, check_close_constraints): New functions called at resolution time. (gfc_match_open, gfc_match_close, match_io): Move checks which don't affect the match result to new functions check_open_constraints, check_close_constraints, check_io_constraints. (gfc_resolve_open, gfc_resolve_close): Call new functions check_open_constraints, check_close_constraints after all tags have been independently resolved. Remove duplicate constraints which are already verified by resolve_tag. Explicitly pass locus to all error reports. (compare_to_allowed_values): Add locus parameter and provide explicit locus all error reports. (match_open_element, match_close_element, match_file_element, match_dt_element, match_inquire_element): Remove redundant special cases for ASYNCHRONOUS and IOMSG tags. (gfc_resolve_dt): Remove redundant special case for format expression. Call check_io_constraints, forwarding an I/O list as the io_code parameter if present. (check_io_constraints): Change return type to bool. Pass explicit locus to error reports. Move generic checks after tag-specific checks, since errors are no longer buffered. Move simplification of format string to match_io. Remove redundant checks which are verified by resolve_tag. Remove usage of async_io_dt flag and explicitly mark symbols used in asynchronous I/O with the asynchronous attribute. * resolve.c (resolve_transfer, resolve_fl_namelist): Remove checks for async_io_dt flag. This is now done in io.c (check_io_constraints). (gfc_resolve_code): Pass code locus to gfc_resolve_open, gfc_resolve_close, gfc_resolve_dt. gcc/testsuite/ChangeLog: 2020-04-09 Fritz Reese <foreese@gcc.gnu.org> PR fortran/87923 * gfortran.dg/f2003_io_8.f03: Fix expected error messages. * gfortran.dg/io_constraints_8.f90: Likewise. * gfortran.dg/iomsg_2.f90: Likewise. * gfortran.dg/pr66725.f90: Likewise. * gfortran.dg/pr88205.f90: Likewise. * gfortran.dg/write_check4.f90: Likewise. * gfortran.dg/asynchronous_5.f03: New test. * gfortran.dg/io_constraints_15.f90: Likewise. * gfortran.dg/io_constraints_16.f90: Likewise. * gfortran.dg/io_constraints_17.f90: Likewise. * gfortran.dg/io_constraints_18.f90: Likewise. * gfortran.dg/io_tags_1.f90: Likewise. * gfortran.dg/io_tags_10.f90: Likewise. * gfortran.dg/io_tags_2.f90: Likewise. * gfortran.dg/io_tags_3.f90: Likewise. * gfortran.dg/io_tags_4.f90: Likewise. * gfortran.dg/io_tags_5.f90: Likewise. * gfortran.dg/io_tags_6.f90: Likewise. * gfortran.dg/io_tags_7.f90: Likewise. * gfortran.dg/io_tags_8.f90: Likewise. * gfortran.dg/io_tags_9.f90: Likewise. * gfortran.dg/write_check5.f90: Likewise.
2020-04-02[Fortran] Resolve formal args before checking DTIOTobias Burnus1-5/+5
* gfortran.h (gfc_resolve_formal_arglist): Add prototype. * interface.c (check_dtio_interface1): Call it. * resolve.c (gfc_resolve_formal_arglist): Renamed from resolve_formal_arglist, removed static. (find_arglists, resolve_types): Update calls. * gfortran.dg/dtio_35.f90: New.
2020-04-02fortran: ICE equivalence with an element of an array PR94030Mark Eggleston1-3/+3
Deferred size arrays can not be used in equivalance statements. gcc/fortran/ChangeLog: PR fortran/94030 * resolve.c (resolve_equivalence): Correct formatting around the label "identical_types". Instead of using gfc_resolve_array_spec use is_non_constants_shape_array to determine whether the array can be used in a in an equivalence statement. gcc/testsuite/ChangeLog: PR fortran/94030 * gfortran.dg/pr94030_1.f90 * gfortran.dg/pr94030_2.f90
2020-03-27Fortran] Reject invalid association target (PR93363)Tobias Burnus1-7/+25
PR fortran/93363 * resolve.c (resolve_assoc_var): Reject association to DT and function name. PR fortran/93363 * gfortran.dg/associate_51.f90: Fix test case. * gfortran.dg/associate_53.f90: New.
2020-03-23fortran: ICE in gfc_match_assignment PR93600Mark Eggleston1-1/+1
This patch builds on the original patch by Steve Kargl that fixed the ICE and produced an "Unclassifiable statement at (1)" error. The processing of parameter variables now correctly handles zero length arrays used with %kind and %len. A side affect is that "Unclassifiable" error now says "Assignment to constant expression at (1)". It also fixes PR93365. gcc/fortran/ChangeLog: PR fortran/93600 * expr.c (simplify_parameter_variable): Check whether the ref chain contains INQUIRY_LEN or INQUIRY_KIND and set inquiry boolean. When an empty array has been identified and a new new EXPR_ARRAY expression has been created only return that expression if inquiry is not set. This allows the new expression to drop through to be simplified into a EXPR_CONSTANT representing %kind or %len. * match.c (gfc_match_assignment): If lvalue doesn't have a symtree free both lvalue and rvalue expressions and return an error. * resolv.c (gfc_resolve_ref): Ensure that code to handle INQUIRY_LEN is only performed for arrays with deferred types. gcc/testsuite/ChangeLog: PR fortran/93365 PR fortran/93600 * gfortran.dg/pr93365.f90: New test. * gfortran.dg/pr93600_1.f90: New test. * gfortran.dg/pr93600_2.f90: New test.
2020-03-17Fix up duplicated duplicated words mostly in commentsJakub Jelinek1-1/+1
In the r10-7197-gbae7b38cf8a21e068ad5c0bab089dedb78af3346 commit I've noticed duplicated word in a message, which lead me to grep for those and we have a tons of them. I've used grep -v 'long long\|optab optab\|template template\|double double' *.[chS] */*.[chS] *.def config/*/* 2>/dev/null | grep ' \([a-zA-Z]\+\) \1 ' Note, the command will not detect the doubled words at the start or end of line or when one of the words is at the end of line and the next one at the start of another one. Some of it is fairly obvious, e.g. all the "the the" cases which is something I've posted and committed patch for already e.g. in 2016, other cases are often valid, e.g. "that that" seems to look mostly ok to me. Some cases are quite hard to figure out, I've left out some of them from the patch (e.g. "and and" in some cases isn't talking about bitwise/logical and and so looks incorrect, but in other cases it is talking about those operations). In most cases the right solution seems to be to remove one of the duplicated words, but not always. I think most important are the ones with user visible messages (in the patch 3 of the first 4 hunks), the rest is just comments (and internal documentation; for that see the doc/tm.texi changes). 2020-03-17 Jakub Jelinek <jakub@redhat.com> * lra-spills.c (remove_pseudos): Fix up duplicated word issue in a dump message. * tree-sra.c (create_access_replacement): Fix up duplicated word issue in a comment. * read-rtl-function.c (find_param_by_name, function_reader::parse_enum_value, function_reader::get_insn_by_uid): Likewise. * spellcheck.c (get_edit_distance_cutoff): Likewise. * tree-data-ref.c (create_ifn_alias_checks): Likewise. * tree.def (SWITCH_EXPR): Likewise. * selftest.c (assert_str_contains): Likewise. * ipa-param-manipulation.h (class ipa_param_body_adjustments): Likewise. * tree-ssa-math-opts.c (convert_expand_mult_copysign): Likewise. * tree-ssa-loop-split.c (find_vdef_in_loop): Likewise. * langhooks.h (struct lang_hooks_for_decls): Likewise. * ipa-prop.h (struct ipa_param_descriptor): Likewise. * tree-ssa-strlen.c (handle_builtin_string_cmp, handle_store): Likewise. * tree-ssa-dom.c (simplify_stmt_for_jump_threading): Likewise. * tree-ssa-reassoc.c (reassociate_bb): Likewise. * tree.c (component_ref_size): Likewise. * hsa-common.c (hsa_init_compilation_unit_data): Likewise. * gimple-ssa-sprintf.c (get_string_length, format_string, format_directive): Likewise. * omp-grid.c (grid_process_kernel_body_copy): Likewise. * input.c (string_concat_db::get_string_concatenation, test_lexer_string_locations_ucn4): Likewise. * cfgexpand.c (pass_expand::execute): Likewise. * gimple-ssa-warn-restrict.c (builtin_memref::offset_out_of_bounds, maybe_diag_overlap): Likewise. * rtl.c (RTX_CODE_HWINT_P_1): Likewise. * shrink-wrap.c (spread_components): Likewise. * tree-ssa-dse.c (initialize_ao_ref_for_dse, valid_ao_ref_for_dse): Likewise. * tree-call-cdce.c (shrink_wrap_one_built_in_call_with_conds): Likewise. * dwarf2out.c (dwarf2out_early_finish): Likewise. * gimple-ssa-store-merging.c: Likewise. * ira-costs.c (record_operand_costs): Likewise. * tree-vect-loop.c (vectorizable_reduction): Likewise. * target.def (dispatch): Likewise. (validate_dims, gen_ccmp_first): Fix up duplicated word issue in documentation text. * doc/tm.texi: Regenerated. * config/i386/x86-tune.def (X86_TUNE_PARTIAL_FLAG_REG_STALL): Fix up duplicated word issue in a comment. * config/i386/i386.c (ix86_test_loading_unspec): Likewise. * config/i386/i386-features.c (remove_partial_avx_dependency): Likewise. * config/msp430/msp430.c (msp430_select_section): Likewise. * config/gcn/gcn-run.c (load_image): Likewise. * config/aarch64/aarch64-sve.md (sve_ld1r<mode>): Likewise. * config/aarch64/aarch64.c (aarch64_gen_adjusted_ldpstp): Likewise. * config/aarch64/falkor-tag-collision-avoidance.c (single_dest_per_chain): Likewise. * config/nvptx/nvptx.c (nvptx_record_fndecl): Likewise. * config/fr30/fr30.c (fr30_arg_partial_bytes): Likewise. * config/rs6000/rs6000-string.c (expand_cmp_vec_sequence): Likewise. * config/rs6000/rs6000-p8swap.c (replace_swapped_load_constant): Likewise. * config/rs6000/rs6000-c.c (rs6000_target_modify_macros): Likewise. * config/rs6000/rs6000.c (rs6000_option_override_internal): Likewise. * config/rs6000/rs6000-logue.c (rs6000_emit_probe_stack_range_stack_clash): Likewise. * config/nds32/nds32-md-auxiliary.c (nds32_split_ashiftdi3): Likewise. Fix various other issues in the comment. c-family/ * c-common.c (resolve_overloaded_builtin): Fix up duplicated word issue in a diagnostic message. cp/ * pt.c (tsubst): Fix up duplicated word issue in a diagnostic message. (lookup_template_class_1, tsubst_expr): Fix up duplicated word issue in a comment. * parser.c (cp_parser_statement, cp_parser_linkage_specification, cp_parser_placeholder_type_specifier, cp_parser_constraint_requires_parens): Likewise. * name-lookup.c (suggest_alternative_in_explicit_scope): Likewise. fortran/ * array.c (gfc_check_iter_variable): Fix up duplicated word issue in a comment. * arith.c (gfc_arith_concat): Likewise. * resolve.c (gfc_resolve_ref): Likewise. * frontend-passes.c (matmul_lhs_realloc): Likewise. * module.c (gfc_match_submodule, load_needed): Likewise. * trans-expr.c (gfc_init_se): Likewise.
2020-03-08Patch and ChangeLogs for PR93581Paul Thomas1-2/+31
2020-02-03[Fortran] Fix to strict associate check (PR93427)Tobias Burnus1-2/+1
PR fortran/93427 * resolve.c (resolve_assoc_var): Remove too strict check. * gfortran.dg/associate_51.f90: Update test case. PR fortran/93427 * gfortran.dg/associate_52.f90: New.
2020-01-19Check for illegal reference in function.Thomas König1-0/+7
2020-01-17PATCH] Fortran: PR93263 -fno-automatic and RECURSIVEMark Eggleston1-1/+2
The use of -fno-automatic should not affect the save attribute of a recursive procedure. The first test case checks unsaved variables and the second checks saved variables.
2020-01-03Fortran] PR 92994 – add more ASSOCIATE checksTobias Burnus1-2/+19
PR fortran/92994 * primary.c (gfc_match_rvalue): Add some flavor checks gfc_matching_procptr_assignment. * resolve.c (resolve_assoc_var): Add more checks for invalid targets. PR fortran/92994 * gfortran.dg/associate_50.f90: Update dg-error. * gfortran.dg/associate_51.f90: New. From-SVN: r279853
2020-01-01Update copyright years.Jakub Jelinek1-1/+1
From-SVN: r279813
2019-12-20Fortran] PR 92996 – fix rank resolution EXPR_ARRAYTobias Burnus1-22/+16
PR fortran/92996 gcc/fortran/ * expr.c (simplify_parameter_variable): Call gfc_resolve_ref and gfc_expression_rank; fix location info. * gfortran.h (gfc_resolve_ref, gfc_expression_rank): Declare. * match.c (gfc_match_stopcode): Remove redundant setting of gfc_init_expr_flag; early return if gfc_simplify_expr has an error. * resolve.c (gfc_expression_rank): Renamed from expression_rank; minor cleanup. (gfc_resolve_ref): Removed static and renamed from resolve_ref. (resolve_variable, resolve_typebound_function, resolve_typebound_subroutine, resolve_ppc_call, resolve_expr_ppc, gfc_resolve_expr, resolve_procedure): Update calls. PR fortran/92996 gcc/testsuite/ * gfortran.dg/array_simplify_4.f90: New. * gfortran.dg/pr91565.f90: Update dg-error. * gfortran.dg/pr91801.f90: Likewise. From-SVN: r279638
2019-12-08Error on Associate with a program.Thomas Koenig1-0/+6
2018-12-08 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/92780 * resolve.c (resolve_assoc_var): Issue error if the associating entity is a program. 2018-12-08 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/92780 * gfortran.dg/associate_50.f90: New test. From-SVN: r279088
2019-11-25DEC comparisons - allow Hollerith constants in comparisons.Mark Eggleston1-1/+53
The -fdec option enables the use of Hollerith comparisons in comparisons with INTEGER, COMPLEX, REAL and CHARACTER expressions. Mark Eggleston <mark.eggleston@codethink.com> Jim MacArthur <jim.macarthur@codethink.co.uk> * gfortran.texi: Update Hollerith constants support for character types and use in comparisons. * invoke.texi: Tidy up list of options. Update description of -fdec-char-conversions. * resolve.c (is_character_based): New. (Convert_hollerith_to_character): New. (convert_to_numeric): New. (resolve_operator): If both sides are character based and -fdec is enabled convert Hollerith to character. If an operand is Hollerith, the other is numeric and -fdec is enabled convert to numeric. (resolve_ordinary_assign): Add check for -fdec-char-conversions for assignment of character literals. Mark Eggleston <mark.eggleston@codethink.com> Jim MacArthur <jim.macarthur@codethink.co.uk> * gfortran.dg/dec-comparison-character_1.f90: New test. * gfortran.dg/dec-comparison-character_2.f90: New test. * gfortran.dg/dec-comparison-character_3.f90: New test. * gfortran.dg/dec-comparison-complex_1.f90: New test. * gfortran.dg/dec-comparison-complex_2.f90: New test. * gfortran.dg/dec-comparison-complex_3.f90: New test. * gfortran.dg/dec-comparison-int_1.f90: New test. * gfortran.dg/dec-comparison-int_2.f90: New test. * gfortran.dg/dec-comparison-int_3.f90: New test. * gfortran.dg/dec-comparison-real_1.f90: New test. * gfortran.dg/dec-comparison-real_2.f90: New test. * gfortran.dg/dec-comparison-real_3.f90: New test. * gfortran.dg/dec-comparison.f90: New test. Co-Authored-By: Jim MacArthur <jim.macarthur@codethink.co.uk> From-SVN: r278674