[patch, fortran] Improve error messages for mismatched arguments

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[patch, fortran] Improve error messages for mismatched arguments

Thomas Koenig-6
Hello world,

the attached patch improves the rather hard to read error
messages for argument mismatches.  With this patch, this reads


     6 |   call foo(1.0) ! { dg-warning "Rank mismatch" }
       |           2
     7 |   call foo(b)   ! { dg-warning "Rank mismatch" }
       |           1
Fehler: Rank mismatch between actual argument at (1) and actual argument
at (2) (scalar and rank-2)

which I think is fairly clear.  It also makes sure that warnings are
always emitted by -fallow-argument-mismatch by removing
-Wargument-mismatch.  Finally, for people who do not want to have too
many warnings cluttering up their logs, a type mismatch is only
shown once if it is a warning.

While I was going on about fixing warnings, I also fixed PR 91557 with
the bit in trans-expr.c.  This part is trivial, I will backport it
to the other affected branches.

After this, I think we can close PR 91556. Regression-tested. OK for

2019-09-13  Thomas Koenig  <[hidden email]>

        PR fortran/91557
        PR fortran/91556
        * frontend-passes.c (check_externals_procedure): Reformat argument
        list. Use gfc_compare_actual_formal instead of gfc_procedure_use.
        * gfortran.h (gfc_symbol): Add flag error.
        * interface.c (gfc_compare_interfaces): Reformat.
        (argument_rank_mismatch): Add where_formal argument. If it is
        present, note that the error is between different calls.
        (compare_parameter): Change warnings that previously dependended
        on -Wargument-mismatch to unconditional.  Issue an error / warning
        on type mismatch only once.  Pass where_formal to
        argument_rank_mismatch for artificial variables.
        (compare_actual_formal): Change warnings that previously
        dependeded on -Wargument-mismatch to unconditional.
        (gfc_check_typebound_override): Likewise.
        (gfc_get_formal_from_actual_arglist): Set declared_at for
        artificial symbol.
        * invoke.texi: Extend description of -fallow-argument-mismatch.
        Delete -Wargument-mismatch.
        * lang.opt: Change -Wargument-mismatch to do-nothing option.
        * resolve.c (resolve_structure_cons): Change warnings that
        previously depended on -Wargument-mismatch to unconditional.
        * trans-decl.c (generate_local_decl): Do not warn if the symbol is

2019-09-13  Thomas Koenig  <[hidden email]>

        PR fortran/91557
        PR fortran/91556
        * gfortran.dg/argument_checking_20.f90: New test.
        * gfortran.dg/argument_checking_21.f90: New test.
        * gfortran.dg/argument_checking_22.f90: New test.
        * gfortran.dg/argument_checking_23.f90: New test.
        * gfortran.dg/warn_unused_dummy_argument_5.f90: New test.
        * gfortran.dg/bessel_3.f90: Add pattern for type mismatch.
        * gfortran.dg/g77/20010519-1.f: Adjust dg-warning messages to new
        * gfortran.dg/pr24823.f: Likewise.
        * gfortran.dg/pr39937.f: Likewise.

p3.diff (19K) Download Attachment
argument_checking_23.f90 (453 bytes) Download Attachment
argument_checking_22.f90 (429 bytes) Download Attachment
argument_checking_21.f90 (296 bytes) Download Attachment
argument_checking_20.f90 (246 bytes) Download Attachment