[patch, fortran] Fix PR 91390 - treatment of extra parameter in a subroutine call

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[patch, fortran] Fix PR 91390 - treatment of extra parameter in a subroutine call

Thomas König
Hello world,

here is the next installment of checking for mismatched calls,
this time for mismatching CALLs.

The solution is to build a separate namespace with procedure
arguments determined from the actual arguments the first time a
procedure is seen, and then compare it against that on subsequent
calls.

This has uncovered quite a few examples of non-conforming code
in our testsuite, so no separate test case needed, IMHO.

So, OK for trunk?  (The -std=legacy question can be settled
later).

2019-08-20  Thomas Koenig  <[hidden email]>

        PR fortran/91390
        * frontend-passes.c (check_externals_procedure): New
        function. If a procedure is not in the translation unit, create
        an "interface" for it, including its formal arguments.
        (check_externals_code): Use check_externals_procedure for common
        code with check_externals_expr.
        (check_externals_expr): Vice versa.
        * gfortran.h (gfc_get_formal_from_actual-arglist): New prototype.
        (gfc_compare_actual_formal): New prototype.
        * interface.c (compare_actual_formal): Rename to
        (gfc_compare_actual_forma): New function, make global.
        (gfc_get_formal_from_actual_arglist): Make global, and move here from
        * trans-types.c (get_formal_from_actual_arglist): Remove here.
        (gfc_get_function_type): Use gfc_get_formal_from_actual_arglist.

2019-08-20  Thomas Koenig  <[hidden email]>

        PR fortran/91390
        * gfortran.dg/bessel_3.f90: Add type mismatch errors.
        * gfortran.dg/coarray_7.f90: Rename subroutines to avoid
        additional errors.
        * gfortran.dg/g77/20010519-1.f: Add -std=legacy. Remove
        warnings for ASSIGN. Add warnings for type mismatch.
        * gfortran.dg/goacc/acc_on_device-1.f95: Add -std=legacy.
        Add cath-all warning.
        * gfortran.dg/internal_pack_9.f90: Rename subroutine to
        avoid type error.
        * gfortran.dg/internal_pack_9.f90: Add -std=legacy. Add
        warnings for type mismatch.
        * gfortran.dg/pr39937.f: Add -std=legacy and type warnings. Move
        here from
        * gfortran.fortran-torture/compile/pr39937.f: Move to gfortran.dg.

p2.diff (27K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [patch, fortran] Fix PR 91390 - treatment of extra parameter in a subroutine call

Thomas Koenig-6
Am 20.08.19 um 22:32 schrieb Thomas König:

> here is the next installment of checking for mismatched calls,
> this time for mismatching CALLs.

The reorganization of the code also means that
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91519 (a rejects-valid
regression) is fixed by this patch.

So, OK for trunk?

Regards

        Thomas
Reply | Threaded
Open this post in threaded view
|

Re: [patch, fortran] Fix PR 91390 - treatment of extra parameter in a subroutine call

Steve Kargl
On Thu, Aug 22, 2019 at 08:50:20PM +0200, Thomas Koenig wrote:

> Am 20.08.19 um 22:32 schrieb Thomas König:
>
> > here is the next installment of checking for mismatched calls,
> > this time for mismatching CALLs.
>
> The reorganization of the code also means that
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91519 (a rejects-valid
> regression) is fixed by this patch.
>
> So, OK for trunk?
>

I'll have time to look over the patch on Saturday.
If someone can give the patch a review, then go
for it.

--
Steve
Reply | Threaded
Open this post in threaded view
|

Re: [patch, fortran] Fix PR 91390 - treatment of extra parameter in a subroutine call

Thomas König
In reply to this post by Thomas König
Hi Steve,

> OK.  Thanks for taking on this task.

Committed (r274902). Thanks for the review!

> As to the open question about how to handle this check,
> I would create -fallow-argument-mismatch (or whatever
> option name you like).  gfortran issues an error if
> a mismatch is detected.  -fallow-... would reduce the
> error to warning, which can only be silenced with -w.
> Hopefully, this will encourage users to fix the code.

Yes, that is what I will submit next.  -fallow-argument-mismatch
sounds like a good name, unless somebody else comes up with a
better name.

Regards

        Thomas