Hello world, the attached patch fixes the PR by unconditionally disabling warnings about unused variables in common blocks.
The reasons are outlined in the PR; there is quite a lot of unnecessary clutter caused by common blocks in module interfaces. Regression-tested. OK for trunk? Thomas 2012-01-03 Thomas Koenig <tkoe...@gcc.gnu.org> PR fortran/49693 * trans-common.c (create_common): Mark variables as used to avoid warnings about unused variables in common blocks. 2012-01-03 Thomas Koenig <tkoe...@gcc.gnu.org> PR fortran/49693 * gfortran.dg/common_17.f90: New test.
Index: trans-common.c =================================================================== --- trans-common.c (Revision 182754) +++ trans-common.c (Arbeitskopie) @@ -689,7 +689,9 @@ create_common (gfc_common_head *com, segment_info VAR_DECL, DECL_NAME (s->field), TREE_TYPE (s->field)); TREE_STATIC (var_decl) = TREE_STATIC (decl); - TREE_USED (var_decl) = TREE_USED (decl); + /* Mark the variable as used in order to avoid warnings about + unused variables. */ + TREE_USED (var_decl) = 1; if (s->sym->attr.use_assoc) DECL_IGNORED_P (var_decl) = 1; if (s->sym->attr.target)
! { dg-do compile } ! { dg-options "-Wall" } ! PR fortran/49693 - this used to cause a spurious warning for the ! variable in the common block. ! Original test case by Stephan Kramer. module foo implicit none integer:: a common a end module foo ! { dg-final { cleanup-modules "foo" } }