From 74d1a34e8600c3b8254eb198ef450e761598a18c Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Wed, 4 Jan 2012 11:51:37 +0000 Subject: [PATCH] re PR fortran/49693 (Spurious "unused-variable" warnings for COMMON block module variables.) 2012-01-04 Thomas Koenig PR fortran/49693 * trans-common.c (create_common): Update copyright years. Mark variables as used to avoid warnings about unused variables in common blocks. 2012-01-04 Thomas Koenig PR fortran/49693 * gfortran.dg/common_17.f90: New test. From-SVN: r182869 --- gcc/fortran/ChangeLog | 7 +++++++ gcc/fortran/trans-common.c | 7 +++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/common_17.f90 | 11 +++++++++++ 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/common_17.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index d752513e999..305646fef5f 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2012-01-04 Thomas Koenig + + PR fortran/49693 + * trans-common.c (create_common): Update copyright years. Mark + variables as used to avoid warnings about unused variables in + common blocks. + 2012-01-03 Hans-Peter Nilsson * gfortran.h (struct gfc_expr): Add missing "struct" diff --git a/gcc/fortran/trans-common.c b/gcc/fortran/trans-common.c index 61ce44ba37a..22aa3502dbd 100644 --- a/gcc/fortran/trans-common.c +++ b/gcc/fortran/trans-common.c @@ -1,5 +1,6 @@ /* Common block and equivalence list handling - Copyright (C) 2000, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 + Copyright (C) 2000, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, + 2011, 2012 Free Software Foundation, Inc. Contributed by Canqun Yang @@ -689,7 +690,9 @@ create_common (gfc_common_head *com, segment_info *head, bool saw_equiv) 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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 556e6763f44..e6c002f2c8d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-01-04 Thomas Koenig + + PR fortran/49693 + * gfortran.dg/common_17.f90: New test. + 2012-01-04 Richard Guenther PR tree-optimization/49651 diff --git a/gcc/testsuite/gfortran.dg/common_17.f90 b/gcc/testsuite/gfortran.dg/common_17.f90 new file mode 100644 index 00000000000..8ac21e7afda --- /dev/null +++ b/gcc/testsuite/gfortran.dg/common_17.f90 @@ -0,0 +1,11 @@ +! { dg-do compile } +! { dg-options "-Wall" } +! PR fortran/49693 - this used to cause a spurious warning for the +! variable in the common block. +! Test case by Stephan Kramer. +module foo + implicit none + integer:: a, b + common a +end module foo +! { dg-final { cleanup-modules "foo" } }