re PR fortran/55352 (Erroneous gfortran warning of unused module variable when variable is only used in namelist)
2012-11-21 Janus Weil <janus@gcc.gnu.org> PR fortran/55352 * trans-decl.c (generate_local_decl): Don't warn for explicitly imported but unused module variables which are in a namelist or common block. 2012-11-21 Janus Weil <janus@gcc.gnu.org> PR fortran/55352 * gfortran.dg/namelist_76.f90: New. From-SVN: r193711
This commit is contained in:
parent
b6405ca836
commit
ecdbf2cdfa
|
@ -1,3 +1,9 @@
|
|||
2012-11-21 Janus Weil <janus@gcc.gnu.org>
|
||||
|
||||
PR fortran/55352
|
||||
* trans-decl.c (generate_local_decl): Don't warn for explicitly imported
|
||||
but unused module variables which are in a namelist or common block.
|
||||
|
||||
2012-11-20 Diego Novillo <dnovillo@google.com>
|
||||
Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
|
|
|
@ -4589,22 +4589,25 @@ generate_local_decl (gfc_symbol * sym)
|
|||
}
|
||||
|
||||
/* Warn for unused variables, but not if they're inside a common
|
||||
block, a namelist, or are use-associated. */
|
||||
block or a namelist. */
|
||||
else if (warn_unused_variable
|
||||
&& !(sym->attr.in_common || sym->attr.use_assoc || sym->mark
|
||||
|| sym->attr.in_namelist))
|
||||
&& !(sym->attr.in_common || sym->mark || sym->attr.in_namelist))
|
||||
{
|
||||
gfc_warning ("Unused variable '%s' declared at %L", sym->name,
|
||||
&sym->declared_at);
|
||||
if (sym->backend_decl != NULL_TREE)
|
||||
TREE_NO_WARNING(sym->backend_decl) = 1;
|
||||
}
|
||||
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);
|
||||
if (sym->backend_decl != NULL_TREE)
|
||||
TREE_NO_WARNING(sym->backend_decl) = 1;
|
||||
if (sym->attr.use_only)
|
||||
{
|
||||
gfc_warning ("Unused module variable '%s' which has been "
|
||||
"explicitly imported at %L", sym->name,
|
||||
&sym->declared_at);
|
||||
if (sym->backend_decl != NULL_TREE)
|
||||
TREE_NO_WARNING(sym->backend_decl) = 1;
|
||||
}
|
||||
else if (!sym->attr.use_assoc)
|
||||
{
|
||||
gfc_warning ("Unused variable '%s' declared at %L",
|
||||
sym->name, &sym->declared_at);
|
||||
if (sym->backend_decl != NULL_TREE)
|
||||
TREE_NO_WARNING(sym->backend_decl) = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* For variable length CHARACTER parameters, the PARM_DECL already
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2012-11-21 Janus Weil <janus@gcc.gnu.org>
|
||||
|
||||
PR fortran/55352
|
||||
* gfortran.dg/namelist_76.f90: New.
|
||||
|
||||
2012-11-21 Martin Jambor <mjambor@suse.cz>
|
||||
|
||||
* gcc.dg/ipa/ipcp-agg-7.c: New test.
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
! { dg-do compile }
|
||||
!
|
||||
! PR 55352: [4.7/4.8 Regression] Erroneous gfortran warning of unused module variable when variable is only used in namelist
|
||||
!
|
||||
! Contributed by <AstroFloyd@gmail.com>
|
||||
|
||||
module data
|
||||
implicit none
|
||||
integer :: a
|
||||
end module data
|
||||
|
||||
program test
|
||||
use data, only: a
|
||||
implicit none
|
||||
a = 1
|
||||
call write_data()
|
||||
end program test
|
||||
|
||||
subroutine write_data()
|
||||
use data, only: a
|
||||
implicit none
|
||||
namelist /write_data_list/ a
|
||||
open(unit=10,form='formatted',status='replace',action='write',file='test.dat')
|
||||
write(10, nml=write_data_list)
|
||||
close(10)
|
||||
end subroutine write_data
|
||||
|
||||
! { dg-final { cleanup-modules "data" } }
|
Loading…
Reference in New Issue