Patchwork [fortran] PR43899 Wrong unused-variable warning with NAMELISTs

login
register
mail settings
Submitter Jerry DeLisle
Date Nov. 8, 2010, 2:59 a.m.
Message ID <4CD76788.5040104@frontier.com>
Download mbox | patch
Permalink /patch/70389/
State New
Headers show

Comments

Jerry DeLisle - Nov. 8, 2010, 2:59 a.m.
Hi,

This patch avoids the bogus warning.  Still remaining is to check if a namelist 
is not used somewhere.  I assume we need to scan a namespace.  I would like to 
get this part committed before the last piece.

Regression tested on x86-64.  OK for trunk?

Regards,

Jerry

2010-11-07  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/43899
	* trans-decl.c (generate_local_decl): Do not generate unused warning
	for variables in namelists.
Mikael Morin - Nov. 8, 2010, 12:14 p.m.
On Monday 08 November 2010 03:59:20 Jerry DeLisle wrote:
> Hi,
> 
> This patch avoids the bogus warning.  Still remaining is to check if a
> namelist is not used somewhere.  I assume we need to scan a namespace.  I
> would like to get this part committed before the last piece.
> 
> Regression tested on x86-64.  OK for trunk?
> 
> Regards,
> 
> Jerry
> 
> 2010-11-07  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
> 
> 	PR fortran/43899
> 	* trans-decl.c (generate_local_decl): Do not generate unused warning
> 	for variables in namelists.

OK, thanks

Patch

Index: trans-decl.c
===================================================================
--- trans-decl.c	(revision 166426)
+++ trans-decl.c	(working copy)
@@ -4017,9 +4017,10 @@  generate_local_decl (gfc_symbol * sym)
 	}
 
       /* Warn for unused variables, but not if they're inside a common
-	 block or are use-associated.  */
+	 block, a namelist, or are use-associated.  */
       else if (warn_unused_variable
-	       && !(sym->attr.in_common || sym->attr.use_assoc || sym->mark))
+	       && !(sym->attr.in_common || sym->attr.use_assoc || sym->mark
+		    || sym->attr.in_namelist))
 	gfc_warning ("Unused variable '%s' declared at %L", sym->name,
 		     &sym->declared_at);