Commit dbad8e71 by Tobias Burnus Committed by Tobias Burnus

re PR fortran/31461 (warn about entities in USE, ONLY statement not later used)

2011-08-17  Tobias Burnus  <burnus@net-b.de>

        PR fortran/31461
        * trans-decl.c (generate_local_decl): Warn about
        unused explicitly imported module variables/parameters.

2011-08-17  Tobias Burnus  <burnus@net-b.de>

        PR fortran/31461
        * gfortran.dg/warn_unused_var_2.f90: New.
        * gfortran.dg/warn_unused_var_3.f90: New.

From-SVN: r177833
parent 0d82a1c8
2011-08-17 Tobias Burnus <burnus@net-b.de>
PR fortran/31461
* trans-decl.c (generate_local_decl): Warn about
unused explicitly imported module variables/parameters.
2011-08-17 Janus Weil <janus@gcc.gnu.org> 2011-08-17 Janus Weil <janus@gcc.gnu.org>
PR fortran/50070 PR fortran/50070
......
...@@ -4453,6 +4453,9 @@ generate_local_decl (gfc_symbol * sym) ...@@ -4453,6 +4453,9 @@ generate_local_decl (gfc_symbol * sym)
|| sym->attr.in_namelist)) || sym->attr.in_namelist))
gfc_warning ("Unused variable '%s' declared at %L", sym->name, gfc_warning ("Unused variable '%s' declared at %L", sym->name,
&sym->declared_at); &sym->declared_at);
else if (warn_unused_variable && sym->attr.use_only)
gfc_warning ("Unused module variable '%s' which has been explicitly "
"imported at %L", sym->name, &sym->declared_at);
/* For variable length CHARACTER parameters, the PARM_DECL already /* For variable length CHARACTER parameters, the PARM_DECL already
references the length variable, so force gfc_get_symbol_decl references the length variable, so force gfc_get_symbol_decl
...@@ -4497,10 +4500,15 @@ generate_local_decl (gfc_symbol * sym) ...@@ -4497,10 +4500,15 @@ generate_local_decl (gfc_symbol * sym)
else if (sym->attr.flavor == FL_PARAMETER) else if (sym->attr.flavor == FL_PARAMETER)
{ {
if (warn_unused_parameter if (warn_unused_parameter
&& !sym->attr.referenced && !sym->attr.referenced)
&& !sym->attr.use_assoc) {
gfc_warning ("Unused parameter '%s' declared at %L", sym->name, if (!sym->attr.use_assoc)
&sym->declared_at); gfc_warning ("Unused parameter '%s' declared at %L", sym->name,
&sym->declared_at);
else if (sym->attr.use_only)
gfc_warning ("Unused parameter '%s' which has been explicitly "
"imported at %L", sym->name, &sym->declared_at);
}
} }
else if (sym->attr.flavor == FL_PROCEDURE) else if (sym->attr.flavor == FL_PROCEDURE)
{ {
......
2011-08-17 Tobias Burnus <burnus@net-b.de>
PR fortran/31461
* gfortran.dg/warn_unused_var_2.f90: New.
* gfortran.dg/warn_unused_var_3.f90: New.
2011-08-17 Tom de Vries <tom@codesourcery.com> 2011-08-17 Tom de Vries <tom@codesourcery.com>
PR target/43597 PR target/43597
......
! { dg-do compile }
! { dg-options "-Wunused" }
!
! PR fortran/31461
!
! Contributed by Vivek Rao.
!
module util_mod
integer :: i,j
end module util_mod
program main
use util_mod, only: i,j ! { dg-warning "Unused module variable .i. which has been explicitly imported" }
j = 1
print*,"j=",j
end program main
! { dg-final { cleanup-modules "util_mod" } }
! { dg-do compile }
! { dg-options "-Wunused-parameter" }
!
! PR fortran/31461
!
module util_mod
integer, parameter :: i = 4
end module util_mod
program main
use util_mod, only: i ! { dg-warning "Unused parameter .i. which has been explicitly imported" }
integer, parameter :: j = 4 ! { dg-warning "Unused parameter .j. declared at" }
end program main
! { dg-final { cleanup-modules "util_mod" } }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment