From: Ralf Wildenhues Date: Sat, 5 Mar 2011 06:55:51 +0000 (+0100) Subject: New macros AC_{F77,FC}_IMPLICIT_NONE to disable Fortran implicit int. X-Git-Tag: v2.68b~93 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f11bce4563d94fd2a675f83909066d12f6243ef;p=thirdparty%2Fautoconf.git 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. Signed-off-by: Ralf Wildenhues --- diff --git a/ChangeLog b/ChangeLog index 908690b1..82d20395 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2011-03-05 Ralf Wildenhues + 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 0e36b87c..6a1771d0 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 e6ff3ecf..29c6d2c9 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -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 diff --git a/lib/autoconf/fortran.m4 b/lib/autoconf/fortran.m4 index 180fc6db..14e1c9c9 100644 --- a/lib/autoconf/fortran.m4 +++ b/lib/autoconf/fortran.m4 @@ -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