[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New macro AC_FC_IMPLICIT_NONE to disable Fortran implicit int.

From: Ralf Wildenhues
Subject: Re: New macro AC_FC_IMPLICIT_NONE to disable Fortran implicit int.
Date: Sat, 5 Mar 2011 09:37:55 +0100
User-agent: Mutt/1.5.20 (2010-08-04)

* Eric Blake wrote on Tue, Mar 01, 2011 at 08:54:50PM CET:
> On 02/27/2011 09:18 AM, Ralf Wildenhues wrote:
> > Another fairly simple Fortran macro, with data gathered from manuals
> > and from the overview site which Eve-Marie linked to.

> Same comments as the last patch, including:
> >  
> > address@hidden AC_FC_IMPLICIT_NONE (@ovar{action-if-success}, 
> > @ovar{action-if-failure})
> should this use @dvar{action-if-failure, AC_MSG_FAILURE}?

Yes, thanks.

This is one of the macros that is not only useful for Fortran 77, but
also easy to port (as the code is already Fortran 77).  So I went ahead
and factored it into AC_{F77,FC}_IMPLICIT_NONE.

I also fixed the autoconf.texi entry to not end up on the section about
Go.  Added switches for a few more compilers.  Added a print use of the
variable to avoid warnings about unused variables (given sufficient
warning flags; thanks Tobias for the hint!).

I then noted that Intel ifort only warns but doesn't fail upon implicit
declarations.  Gah!  This compiler is really not easy to support: with
unknown command-line arguments, it only warns but does not fail.  On the
upside, it has a somewhat elaborate set of flags to turn warnings into
errors '-warn errors' (mind you, it then still doesn't fail over unknown
command-line args) , but on the downside the machinery seems quite buggy
in that for example, adding '-warn stderrors' (which aims to _also_ warn
about standard-conformance errors) turns the exit status back into zero.
Command-line order does not matter.  :-(

Since I'm not yet ready to get into the business of heuristically
comparing warning output from compilers, the macro tries both -u and
'-u -warn errors', in the hope that the user hasn't turned on other
warning flags yet.

Thanks for reading this far.  Will push this in a minute.


    New macros AC_{F77,FC}_IMPLICIT_NONE to disable Fortran implicit int.
    * lib/autoconf/fortran.m4 (_AC_FC_IMPLICIT_NONE): New internal
    * doc/autoconf.texi (Fortran Compiler): Document them.
    * NEWS: Update.

diff --git a/NEWS b/NEWS
index 0e36b87..6a1771d 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,7 @@ GNU Autoconf NEWS - User visible changes.
 - New and updated macros for Fortran support:
     AC_FC_CHECK_BOUNDS to enable array bounds checking
+    AC_F77_IMPLICIT_NONE and AC_FC_IMPLICIT_NONE to disable implicit integer
 * Noteworthy changes in release 2.68 (2010-09-22) [stable]
   Released by Eric Blake, based on git versions 2.67.*.
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index e9bd85d..273fa60 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -8259,6 +8259,19 @@ Fortran Compiler
 @end defmac
address@hidden AC_F77_IMPLICIT_NONE (@ovar{action-if-success}, @
+  @dvar{action-if-failure, AC_MSG_FAILURE})
address@hidden AC_FC_IMPLICIT_NONE (@ovar{action-if-success}, @
+  @dvar{action-if-failure, AC_MSG_FAILURE})
+Try to disallow implicit declarations in the Fortran compiler.  If
+successful, the @var{action-if-success} is called and any needed flags
+are added to @code{FCFLAGS}.  Otherwise, @var{action-if-failure} is
+called, which defaults to failing with an error message.
address@hidden defmac
 @node Go Compiler
 @subsection Go Compiler Characteristics
diff --git a/lib/autoconf/fortran.m4 b/lib/autoconf/fortran.m4
index 180fc6d..14e1c9c 100644
--- a/lib/autoconf/fortran.m4
+++ b/lib/autoconf/fortran.m4
@@ -1446,3 +1446,75 @@ else
+# ------------------------------------------------------------------------
+# Look for a flag to disallow implicit declarations, and add it to FCFLAGS.
+# Call ACTION-IF-SUCCESS (defaults to nothing) if successful and
+# ACTION-IF-FAILURE (defaults to failing with an error message) if not.
+# Known flags:
+# GNU gfortran, g95: -fimplicit-none, g77: -Wimplicit
+# Intel: -u, -implicitnone; might also need '-warn errors' to turn into error.
+# Sun/Oracle: -u
+# HP: +implicit_none
+# IBM: -u, -qundef
+# SGI: -u
+# Compaq: -u, -warn declarations
+# NAGWare: -u
+# Lahey: -in, --in, -AT
+# Cray: -Mdclchk -d i
+# PGI: -Mcdlchk
+# f2c: -u
+AC_CACHE_CHECK([for flag to disallow _AC_LANG implicit declarations],
+               [ac_cv_[]_AC_LANG_ABBREV[]_implicit_none],
+for ac_flag in none -fimplicit-none -u -Wimplicit -implicitnone +implicit_none 
+               -qundef "-warn declarations" -in --in -AT "-d i" -Mdclchk \
+               "-u -warn errors"
+  if test "x$ac_flag" != xnone; then
+    _AC_LANG_PREFIX[]FLAGS="$ac_fc_implicit_none_[]_AC_LANG_PREFIX[]FLAGS_save 
+  fi
+      i = 0
+      print *, i]])],
+       [],
+       [ac_cv_[]_AC_LANG_ABBREV[]_implicit_none=$ac_flag; break])])
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+if test "x$ac_cv_[]_AC_LANG_ABBREV[]_implicit_none" = xunknown; then
+  m4_default([$3],
+    [AC_MSG_ERROR([no Fortran flag to disallow implicit declarations found], 
+  if test "x$ac_cv_[]_AC_LANG_ABBREV[]_implicit_none" != xnone; then
+  fi
+  $2
+# ------------------------------------------------------------------------
+[AC_LANG_PUSH([Fortran 77])dnl
+AC_LANG_POP([Fortran 77])dnl
+# -----------------------------------------------------------------------

reply via email to

[Prev in Thread] Current Thread [Next in Thread]