This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch, fortran] Fix PR 48847, bogus "unused parameter" warning


Hello world,

the attached, rather obvious patch fixed a bogus "unused parameter"
warning with procedure dummy arguments and warns about these if
they occur.

Regression-tested. OK for trunk? Or rather wait until 4.8?

Thomas

2012-02-05 Thomas König <tkoenig@gcc.gnu.org>

        PR fortran/48847
        * trans-decl.c:  Warn about unused dummy procedure arguments
        if -Wunused-dummy-argument is specified.  Suppress middle-end
        warnings about procedure arguments.

2012-02-05 Thomas König <tkoenig@gcc.gnu.org>

        PR fortran/48847
        * gfortran.dg/warn_unused_dummy_argument_3.f90:  New test.
Index: trans-decl.c
===================================================================
--- trans-decl.c	(Revision 183873)
+++ trans-decl.c	(Arbeitskopie)
@@ -4683,6 +4683,22 @@ generate_local_decl (gfc_symbol * sym)
 	  && sym->ts.type == BT_CHARACTER && sym->ts.is_c_interop
 	  && sym->ns->proc_name != NULL && sym->ns->proc_name->attr.is_bind_c)
 	gfc_conv_scalar_char_value (sym, NULL, NULL);
+
+      /* Unused procedure passed as dummy argument.  */
+      if (sym->attr.flavor == FL_PROCEDURE)
+	{
+	  if (!sym->attr.referenced)
+	    {
+	      if (gfc_option.warn_unused_dummy_argument)
+		gfc_warning ("Unused dummy argument '%s' at %L", sym->name,
+			     &sym->declared_at);	     
+	    }
+
+	  /* Silence bogus "unused parameter" warnings from the
+	     middle end.  */
+	  if (sym->backend_decl != NULL_TREE)
+		TREE_NO_WARNING(sym->backend_decl) = 1;
+	}
     }
 
   /* Make sure we convert the types of the derived types from iso_c_binding

Attachment: warn_unused_dummy_argument_3.f90
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]