diff mbox

[Fortran] Fix PR 49693, unused variable warnings in common blocks

Message ID 4F0320E2.3090802@netcologne.de
State New
Headers show

Commit Message

Thomas Koenig Jan. 3, 2012, 3:38 p.m. UTC
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  <tkoenig@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  <tkoenig@gcc.gnu.org>

         PR fortran/49693
         * gfortran.dg/common_17.f90:  New test.
! { 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" } }
diff mbox

Patch

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)