Hi, I just committed the attached patch as obvious and simple. Since this is a regression, I will backport to gcc 9 and gcc 8 shortly.
(I'm attaching the patch as txt file in the hope it will not be munged in the web archive). Regards Thomas Fix PR 94270 by not warning about artifical dummy arguments. 2020-04-14 Thomas Koenig <tkoe...@gcc.gnu.org> PR fortran/94270 * interface.c (gfc_get_formal_from_actual_arglist): Always set artificial attribute for symbols. * trans-decl.c (generate_local_decl): Do not warn if the symbol is artifical. 2020-04-14 Thomas Koenig <tkoe...@gcc.gnu.org> PR fortran/94270 * gfortran.dg/warn_unused_dummy_argument_6.f90: New test.
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 96835dea4bf..6d01bd035de 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2020-04-14 Thomas Koenig <tkoe...@gcc.gnu.org> + + PR fortran/94270 + * interface.c (gfc_get_formal_from_actual_arglist): Always + set artificial attribute for symbols. + * trans-decl.c (generate_local_decl): Do not warn if the + symbol is artifical. + 2020-04-13 Linus Koenig <l...@sig-st.de> PR fortran/94192 diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index 75a50c999b7..8f041f0a0a8 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -5317,7 +5317,6 @@ gfc_get_formal_from_actual_arglist (gfc_symbol *sym, s->ts.is_iso_c = 0; s->ts.is_c_interop = 0; s->attr.flavor = FL_VARIABLE; - s->attr.artificial = 1; if (a->expr->rank > 0) { s->attr.dimension = 1; @@ -5332,6 +5331,7 @@ gfc_get_formal_from_actual_arglist (gfc_symbol *sym, s->maybe_array = maybe_dummy_array_arg (a->expr); } s->attr.dummy = 1; + s->attr.artificial = 1; s->declared_at = a->expr->where; s->attr.intent = INTENT_UNKNOWN; (*f)->sym = s; diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index e91a2795762..487e776f5dd 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -6072,7 +6072,7 @@ generate_local_decl (gfc_symbol * sym) /* Unused procedure passed as dummy argument. */ if (sym->attr.flavor == FL_PROCEDURE) { - if (!sym->attr.referenced) + if (!sym->attr.referenced && !sym->attr.artificial) { if (warn_unused_dummy_argument) gfc_warning (OPT_Wunused_dummy_argument, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2035cf6fd1f..86a3a1fe462 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-04-14 Thomas Koenig <tkoe...@gcc.gnu.org> + + PR fortran/94270 + * gfortran.dg/warn_unused_dummy_argument_6.f90: New test. + 2020-04-13 Marek Polacek <pola...@redhat.com> PR c++/94588 diff --git a/gcc/testsuite/gfortran.dg/warn_unused_dummy_argument_6.f90 b/gcc/testsuite/gfortran.dg/warn_unused_dummy_argument_6.f90 new file mode 100644 index 00000000000..72f6d5c0857 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/warn_unused_dummy_argument_6.f90 @@ -0,0 +1,13 @@ +! { dg-do compile } +! { dg-options "-Wall" } +! PR 94270 - this used to give a bogus warning. +! Test case by Ignacio Fernández Galván. +subroutine foo() +external bar +call meh(bar) +call foo_internal() +contains + subroutine foo_internal() + call meh(bar) + end subroutine foo_internal +end subroutine foo