Hi Steve, Far from objecting, the patch is OK to apply before Saturday :-)
Thanks for the patch. Paul On 16 August 2016 at 21:25, Steve Kargl <s...@troutmask.apl.washington.edu> wrote: > If no one objects before Saturday, I will commit the following patch. > > 2016-08-20 Steven G. Kargl <ka...@gcc.gnu.org> > > PR fortran/77260 > * trans-decl.c(generate_local_decl): Suppress warning > for unused variable if symbol is entry point. > > 2016-08-20 Steven G. Kargl <ka...@gcc.gnu.org> > > PR fortran/77260 > * gfortran.dg/pr77260_1.f90: New test. > * gfortran.dg/pr77260_2.f90: Ditto. > > Index: gcc/fortran/trans-decl.c > =================================================================== > --- gcc/fortran/trans-decl.c (revision 239293) > +++ gcc/fortran/trans-decl.c (working copy) > @@ -5319,9 +5319,19 @@ generate_local_decl (gfc_symbol * sym) > } > else if (!sym->attr.use_assoc) > { > - gfc_warning (OPT_Wunused_variable, > - "Unused variable %qs declared at %L", > - sym->name, &sym->declared_at); > + /* Corner case: the symbol may be an entry point. At this > point, > + it may appear to be an unused variable. Suppress warning. > */ > + bool enter = false; > + gfc_entry_list *el; > + > + for (el = sym->ns->entries; el; el=el->next) > + if (strcmp(sym->name, el->sym->name) == 0) > + enter = true; > + > + if (!enter) > + gfc_warning (OPT_Wunused_variable, > + "Unused variable %qs declared at %L", > + sym->name, &sym->declared_at); > if (sym->backend_decl != NULL_TREE) > TREE_NO_WARNING(sym->backend_decl) = 1; > } > Index: gcc/testsuite/gfortran.dg/pr77260_1.f90 > =================================================================== > --- gcc/testsuite/gfortran.dg/pr77260_1.f90 (nonexistent) > +++ gcc/testsuite/gfortran.dg/pr77260_1.f90 (working copy) > @@ -0,0 +1,25 @@ > +! { dg-do compile } > +! { dg-options "-Wall" } > +module foo > + > + implicit none > + > + private > + public f1,f2 > + > + contains > + > + integer function f1() > + integer f2 > + f1=5 > + entry f2 > + f2=8 > + end function > +end module > + > +program test > + use foo > + implicit none > + print *,f2() > +end program > +! { dg-final { cleanup-modules "foo" } } > Index: gcc/testsuite/gfortran.dg/pr77260_2.f90 > =================================================================== > --- gcc/testsuite/gfortran.dg/pr77260_2.f90 (nonexistent) > +++ gcc/testsuite/gfortran.dg/pr77260_2.f90 (working copy) > @@ -0,0 +1,26 @@ > +! { dg-do compile } > +! { dg-options "-Wall" } > +module foo > + > + implicit none > + > + private > + public f1,f2 > + > + contains > + > + integer function f1() > + integer f2 > + integer f3 ! { dg-warning "Unused variable" } > + f1=5 > + entry f2 > + f2=8 > + end function > +end module > + > +program test > + use foo > + implicit none > + print *,f2() > +end program > +! { dg-final { cleanup-modules "foo" } } > -- > Steve -- The difference between genius and stupidity is; genius has its limits. Albert Einstein