Bug 22552 - Would like warning when an undeclared function is called
Summary: Would like warning when an undeclared function is called
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.1.0
: P2 enhancement
Target Milestone: ---
Assignee: Daniel Kraft
URL:
Keywords: diagnostic, patch
Depends on:
Blocks:
 
Reported: 2005-07-18 18:51 UTC by Erik Schnetter
Modified: 2009-12-27 09:33 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-04-11 13:58:04


Attachments
Latest patch (1.69 KB, patch)
2009-05-14 13:48 UTC, Daniel Kraft
Details | Diff
ChangeLog for patch posted (313 bytes, text/plain)
2009-05-14 13:49 UTC, Daniel Kraft
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Erik Schnetter 2005-07-18 18:51:01 UTC
It would be nice to have an option for gfortran that emits a warning when an 
undeclared function or subroutine is called.  This would be similar to 
-Wimplicit-interface, except that this new warning would also accept 
non-explicit interfaces.  For example, the fragment 
 
external a 
call a 
 
leads to a warning with -Wimplicit-interface, but I would like to get no 
warning for this construct.
Comment 1 Andrew Pinski 2005-07-19 13:43:48 UTC
Confirmed.
Comment 2 Francois-Xavier Coudert 2007-11-08 17:59:32 UTC
I'm not sure about the wording, but the following patch does what you want:

Index: interface.c
===================================================================
--- interface.c (revision 129869)
+++ interface.c (working copy)
@@ -2216,12 +2216,16 @@ check_intents (gfc_formal_arglist *f, gf
 void
 gfc_procedure_use (gfc_symbol *sym, gfc_actual_arglist **ap, locus *where)
 {
-
-  /* Warn about calls with an implicit interface.  */
+  /* Warn about calls with an implicit interface, or to procedures not
+     explicitly declared.  */
   if (gfc_option.warn_implicit_interface
       && sym->attr.if_source == IFSRC_UNKNOWN)
     gfc_warning ("Procedure '%s' called with an implicit interface at %L",
                 sym->name, where);
+  else if (gfc_option.warn_implicit_procedure && sym->attr.proc == PROC_UNKNOWN
+          && sym->attr.if_source == IFSRC_UNKNOWN)
+    gfc_warning ("Procedure '%s' called at %L is not explicitly declared",
+                sym->name, where);

   if (sym->attr.if_source == IFSRC_UNKNOWN
       || !compare_actual_formal (ap, sym->formal, 0,


You also need to add the option in lang.opt and gfortran.h, and handle it in options.c, of course ;-)
Comment 3 Daniel Kraft 2009-04-11 13:58:04 UTC
Working on updating and working out FX's patch.
Comment 4 Daniel Kraft 2009-04-11 16:14:41 UTC
Extended patch based on the one from comment #2 posted: http://gcc.gnu.org/ml/fortran/2009-04/msg00148.html
Comment 5 Daniel Kraft 2009-05-14 13:48:58 UTC
Created attachment 17865 [details]
Latest patch
Comment 6 Daniel Kraft 2009-05-14 13:49:19 UTC
Created attachment 17866 [details]
ChangeLog for patch posted
Comment 7 Daniel Franke 2009-12-11 14:42:27 UTC
Daniel, is there anything going to happen with those patches you attached? :)
Comment 8 Daniel Kraft 2009-12-11 14:58:34 UTC
Well, on 10th of August I posted this to the mailing list to get comments about what to do with this PR and some other.  I did so far never get any replies :)  So actually I'd like to work things out here and either fix or close the PR.  But I've no real plan at the moment because I'd like to get other's opinions.

The patch itself seems fine to me, the point is whether we want that warning or not.
Comment 9 Daniel Kraft 2009-12-27 09:31:24 UTC
Subject: Bug 22552

Author: domob
Date: Sun Dec 27 09:30:57 2009
New Revision: 155479

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155479
Log:
2009-12-27  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
	    Daniel Kraft  <d@domob.eu>

	PR fortran/22552
	* lang.opt (Wimplicit-procedure): New option.
	* gfortran.h (struct gfc_option_t): New member `warn_implicit_procedure'
	* options.c (gfc_handle_option): Handle -Wimplicit-procedure.
	* interface.c (gfc_procedure_use): Warn about procedure never
	explicitly declared if requested by the new flag.
	* invoke.texi: Document new flag -Wimplicit-procedure.

2009-12-27  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
	    Daniel Kraft  <d@domob.eu>

	PR fortran/22552
	* gfortran.dg/warn_implicit_procedure_1.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/warn_implicit_procedure_1.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/interface.c
    trunk/gcc/fortran/invoke.texi
    trunk/gcc/fortran/lang.opt
    trunk/gcc/fortran/options.c
    trunk/gcc/testsuite/ChangeLog

Comment 10 Daniel Kraft 2009-12-27 09:33:00 UTC
Implemented on trunk with (basically) the patch attached.