diff mbox

[fortran] PR43899 Wrong unused-variable warning with NAMELISTs

Message ID 4CD76788.5040104@frontier.com
State New
Headers show

Commit Message

Jerry DeLisle Nov. 8, 2010, 2:59 a.m. UTC
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.

Comments

Mikael Morin Nov. 8, 2010, 12:14 p.m. UTC | #1
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
diff mbox

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);