]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
New macros AC_{F77,FC}_IMPLICIT_NONE to disable Fortran implicit int.
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sat, 5 Mar 2011 06:55:51 +0000 (07:55 +0100)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sat, 5 Mar 2011 08:42:04 +0000 (09:42 +0100)
* lib/autoconf/fortran.m4 (_AC_FC_IMPLICIT_NONE): New internal
macro.
(AC_F77_IMPLICIT_NONE, AC_FC_IMPLICIT_NONE): New macros.
* doc/autoconf.texi (Fortran Compiler): Document them.
* NEWS: Update.

Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
ChangeLog
NEWS
doc/autoconf.texi
lib/autoconf/fortran.m4

index 908690b1858fcf6eeba62e9f4bf81132117ecb34..82d20395678a04a22687a5630b01c9c93556e734 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2011-03-05  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
+       New macros AC_{F77,FC}_IMPLICIT_NONE to disable Fortran implicit int.
+       * lib/autoconf/fortran.m4 (_AC_FC_IMPLICIT_NONE): New internal
+       macro.
+       (AC_F77_IMPLICIT_NONE, AC_FC_IMPLICIT_NONE): New macros.
+       * doc/autoconf.texi (Fortran Compiler): Document them.
+       * NEWS: Update.
+
        New macro AC_FC_CHECK_BOUNDS to enable Fortran array bounds checking.
        * lib/autoconf/fortran.m4 (AC_FC_CHECK_BOUNDS): New macro.
        * doc/autoconf.texi (Fortran Compiler): Document it.
diff --git a/NEWS b/NEWS
index 0e36b87cdaf27a73df25a9ef16cbac6ac7cea300..6a1771d05861378ca3d74febc5f782900b56c49d 100644 (file)
--- 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.*.
index e6ff3ecf74b97601dc267334f7228b3a5ac61f40..29c6d2c9d0442c76d53c910e2f2894ec36fea486 100644 (file)
@@ -8262,6 +8262,23 @@ The result of the macro is cached in the @code{ac_cv_fc_check_bounds}
 variable.
 @end defmac
 
+@defmac AC_F77_IMPLICIT_NONE (@ovar{action-if-success}, @
+  @dvar{action-if-failure, AC_MSG_FAILURE})
+@defmacx AC_FC_IMPLICIT_NONE (@ovar{action-if-success}, @
+  @dvar{action-if-failure, AC_MSG_FAILURE})
+@acindex{F77_IMPLICIT_NONE}
+@acindex{FC_IMPLICIT_NONE}
+
+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.
+
+The result of these macros are cached in the
+@code{ac_cv_f77_implicit_none} and @code{ac_cv_fc_implicit_none}
+variables, respectively.
+@end defmac
+
 
 @node Go Compiler
 @subsection Go Compiler Characteristics
index 180fc6dbb8e57609fa5287adb7c61e14a93655d3..14e1c9c99e69ac1eccba43c6e2da09d8946c4bf6 100644 (file)
@@ -1446,3 +1446,75 @@ else
 fi
 AC_LANG_POP([Fortran])dnl
 ])# AC_FC_CHECK_BOUNDS
+
+
+# _AC_FC_IMPLICIT_NONE([ACTION-IF-SUCCESS], [ACTION-IF-FAILURE = FAILURE])
+# ------------------------------------------------------------------------
+# 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_DEFUN([_AC_FC_IMPLICIT_NONE],
+[_AC_FORTRAN_ASSERT()dnl
+AC_CACHE_CHECK([for flag to disallow _AC_LANG implicit declarations],
+               [ac_cv_[]_AC_LANG_ABBREV[]_implicit_none],
+[ac_cv_[]_AC_LANG_ABBREV[]_implicit_none=unknown
+ac_fc_implicit_none_[]_AC_LANG_PREFIX[]FLAGS_save=$[]_AC_LANG_PREFIX[]FLAGS
+for ac_flag in none -fimplicit-none -u -Wimplicit -implicitnone +implicit_none \
+               -qundef "-warn declarations" -in --in -AT "-d i" -Mdclchk \
+               "-u -warn errors"
+do
+  if test "x$ac_flag" != xnone; then
+    _AC_LANG_PREFIX[]FLAGS="$ac_fc_implicit_none_[]_AC_LANG_PREFIX[]FLAGS_save $ac_flag"
+  fi
+  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])],
+    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
+      i = 0
+      print *, i]])],
+       [],
+       [ac_cv_[]_AC_LANG_ABBREV[]_implicit_none=$ac_flag; break])])
+done
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+_AC_LANG_PREFIX[]FLAGS=$ac_fc_implicit_none_[]_AC_LANG_PREFIX[]FLAGS_save
+])
+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], 77)])
+else
+  if test "x$ac_cv_[]_AC_LANG_ABBREV[]_implicit_none" != xnone; then
+    _AC_LANG_PREFIX[]FLAGS="$_AC_LANG_PREFIX[]FLAGS $ac_cv_[]_AC_LANG_ABBREV[]_implicit_none"
+  fi
+  $2
+fi
+])# _AC_FC_IMPLICIT_NONE
+
+
+# AC_F77_IMPLICIT_NONE([ACTION-IF-SUCCESS], [ACTION-IF-FAILURE = FAILURE])
+# ------------------------------------------------------------------------
+AC_DEFUN([AC_F77_IMPLICIT_NONE],
+[AC_LANG_PUSH([Fortran 77])dnl
+_AC_FC_IMPLICIT_NONE($@)
+AC_LANG_POP([Fortran 77])dnl
+])# AC_F77_IMPLICIT_NONE
+
+
+# AC_FC_IMPLICIT_NONE([ACTION-IF-SUCCESS], [ACTION-IF-FAILURE = FAILURE])
+# -----------------------------------------------------------------------
+AC_DEFUN([AC_FC_IMPLICIT_NONE],
+[AC_LANG_PUSH([Fortran])dnl
+_AC_FC_IMPLICIT_NONE($@)
+AC_LANG_POP([Fortran])dnl
+])# AC_FC_IMPLICIT_NONE