Patchwork [Fortran] PR57469 - silence unused dummy arg warning, if it is used in a namelist

login
register
mail settings
Submitter Tobias Burnus
Date July 1, 2013, 8:40 a.m.
Message ID <51D14084.6070609@net-b.de>
Download mbox | patch
Permalink /patch/256033/
State New
Headers show

Comments

Tobias Burnus - July 1, 2013, 8:40 a.m.
Built and regtested on x86-64-gnu-linux.
OK for the trunk?

Tobias
Tobias Burnus - July 8, 2013, 12:18 p.m.
Tobias Burnus wrote:
> Built and regtested on x86-64-gnu-linux.
> OK for the trunk?

Committed as obvious (Rev. 200785) with the test-case's grammar in the 
comment fixed. (Thanks Dominique for the review.)

Tobias

Patch

2013-07-01  Tobias Burnus  <burnus@net-b.de>

	PR fortran/57469
	* trans-decl.c (generate_local_decl): Don't warn that
	a dummy is unused, when it is in a namelist.

2013-07-01  Tobias Burnus  <burnus@net-b.de>

	PR fortran/57469
	* gfortran.dg/warn_unused_dummy_argument_4.f90: New.

diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index fc3a725..6a8d98c 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -4726,7 +4726,7 @@  generate_local_decl (gfc_symbol * sym)
 	gfc_get_symbol_decl (sym);
 
       /* Warnings for unused dummy arguments.  */
-      else if (sym->attr.dummy)
+      else if (sym->attr.dummy && !sym->attr.in_namelist)
 	{
 	  /* INTENT(out) dummy arguments are likely meant to be set.  */
 	  if (gfc_option.warn_unused_dummy_argument
--- /dev/null	2013-07-01 08:13:35.324165209 +0200
+++ gcc/gcc/testsuite/gfortran.dg/warn_unused_dummy_argument_4.f90	2013-07-01 10:21:47.718455463 +0200
@@ -0,0 +1,16 @@ 
+! { dg-do compile }
+! { dg-options "-Wall" }
+!
+! PR fortran/57469
+!
+! Contributed by Vladimir Fuka
+!
+! Don't warn for unused dummy arguments when it is used in namelists
+!
+   subroutine read_command_line(line,a,b)
+     character(*),intent(in) :: line
+     intent(inout) :: a,b
+     namelist /cmd/ a,b
+
+     read(line,nml = cmd)
+   end