From: Thomas Koenig Date: Mon, 26 Aug 2019 20:05:32 +0000 (+0000) Subject: re PR fortran/91390 (treatment of extra parameter in a subroutine call) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7a56096cc43d969a180f965a0e6bb07941978fea;p=gcc.git re PR fortran/91390 (treatment of extra parameter in a subroutine call) 2019-08-26 Thomas Koenig PR fortran/91390 PR fortran/91473 * frontend-passes.c (gfc_check_externals): Make gfc_errors_to_warnings conditional on -fallow-argument-mismatch. * invoke.texi: Document -fallow-argument-mismatch. * lang.opt: Add -fallow-argument-mismatch. 2019-08-26 Thomas Koenig PR fortran/91390 PR fortran/91473 * gfortran.dg/used_before_typed_4.f90: Change warning to error. * gfortran.dg/argument_checking_20.f90: New test. From-SVN: r274937 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index abdf9e6b24f..643a7d0829a 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,12 @@ +2019-08-26 Thomas Koenig + + PR fortran/91390 + PR fortran/91473 + * frontend-passes.c (gfc_check_externals): Make + gfc_errors_to_warnings conditional on -fallow-argument-mismatch. + * invoke.texi: Document -fallow-argument-mismatch. + * lang.opt: Add -fallow-argument-mismatch. + 2019-08-24 Thomas Koenig PR fortran/91390 diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c index fa416671fc6..86debab0599 100644 --- a/gcc/fortran/frontend-passes.c +++ b/gcc/fortran/frontend-passes.c @@ -5477,9 +5477,9 @@ gfc_check_externals (gfc_namespace *ns) gfc_clear_error (); - /* Turn errors into warnings if -std=legacy is given by the user. */ + /* Turn errors into warnings if the user indicated this. */ - if (!pedantic && !(gfc_option.warn_std & GFC_STD_LEGACY)) + if (!pedantic && flag_allow_argument_mismatch) gfc_errors_to_warnings (true); gfc_code_walker (&ns->code, check_externals_code, check_externals_expr, NULL); diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi index 1039c6084c4..0b8abc50768 100644 --- a/gcc/fortran/invoke.texi +++ b/gcc/fortran/invoke.texi @@ -116,12 +116,12 @@ by type. Explanations are in the following sections. @table @emph @item Fortran Language Options @xref{Fortran Dialect Options,,Options controlling Fortran dialect}. -@gccoptlist{-fall-intrinsics -fallow-invalid-boz -fbackslash -fcray-pointer @gol --fd-lines-as-code -fd-lines-as-comments -fdec -fdec-structure @gol --fdec-intrinsic-ints -fdec-static -fdec-math -fdec-include @gol +@gccoptlist{-fall-intrinsics -fallow-argument-mismatch -fallow-invalid-boz @gol +-fbackslash -fcray-pointer -fd-lines-as-code -fd-lines-as-comments -fdec @gol +-fdec-structure-fdec-intrinsic-ints -fdec-static -fdec-math -fdec-include @gol -fdec-format-defaults -fdec-blank-format-item -fdefault-double-8 @gol -fdefault-integer-8 -fdefault-real-8 -fdefault-real-10 -fdefault-real-16 @gol --fdollar-ok @gol -ffixed-line-length-@var{n} -ffixed-line-length-none @gol +-fdollar-ok -ffixed-line-length-@var{n} -ffixed-line-length-none @gol -fpad-source -ffree-form -ffree-line-length-@var{n} -ffree-line-length-none @gol -fimplicit-none -finteger-4-integer-8 -fmax-identifier-length @gol -fmodule-private -ffixed-form -fno-range-check -fopenacc -fopenmp @gol @@ -232,6 +232,14 @@ available with @command{gfortran}. As a consequence, @option{-Wintrinsics-std} will be ignored and no user-defined procedure with the same name as any intrinsic will be called except when it is explicitly declared @code{EXTERNAL}. +@item -fallow-argument-mismatch +@opindex @code{fallow-argument-mismatch} +Some code contains calls to external procedures whith mismatches +between the calls and the procedure definition, or with mismatches +between different calls. Such code is non-conforming, and will usually +be flagged with an error. This options degrades the error to a +warning. This option is implied by @option{-std=legacy}. + @item -fallow-invalid-boz @opindex @code{allow-invalid-boz} A BOZ literal constant can occur in a limited number of context in diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt index 85113a7da1e..1b3364ba9d3 100644 --- a/gcc/fortran/lang.opt +++ b/gcc/fortran/lang.opt @@ -365,6 +365,10 @@ d Fortran Joined ; Documented in common.opt +fallow-argument-mismatch +Fortran Var(flag_allow_argument_mismatch) LangEnabledBy(Fortran,std=legacy) +Accept argument mismatches in procedure calls. + faggressive-function-elimination Fortran Var(flag_aggressive_function_elimination) Eliminate multiple function invocations also for impure functions. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9bdc2f9b0fb..5f60dc0b1f7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2019-08-26 Thomas Koenig + + PR fortran/91390 + PR fortran/91473 + * gfortran.dg/used_before_typed_4.f90: Change warning to error. + * gfortran.dg/argument_checking_20.f90: New test. + 2019-08-26 Marek Polacek PR c++/91545 - ICE in constexpr store evaluation. diff --git a/gcc/testsuite/gfortran.dg/used_before_typed_4.f90 b/gcc/testsuite/gfortran.dg/used_before_typed_4.f90 index ff8a1fc2970..0604cfe5638 100644 --- a/gcc/testsuite/gfortran.dg/used_before_typed_4.f90 +++ b/gcc/testsuite/gfortran.dg/used_before_typed_4.f90 @@ -22,5 +22,5 @@ END SUBROUTINE test PROGRAM main IMPLICIT NONE INTEGER :: arr1(42), arr2(42) - CALL test (3, arr1, 2, arr2) ! { dg-warning "Type mismatch in argument" } + CALL test (3, arr1, 2, arr2) ! { dg-error "Type mismatch in argument" } END PROGRAM main