gfortran.h (GFC_STD_LEGACY): New "standard" macro.

* gfortran.h (GFC_STD_LEGACY): New "standard" macro.  Reindent.
	* options.c (gfc_init_options): By default, allow legacy extensions
	but warn about them.
	(gfc_post_options): Make -pedantic warn about legacy extensions
	even with -std=legacy.
	(gfc_handle_option): Make -std=gnu follow the default behaviour
	of warning about legacy extensions, but allowing them. Make the
	new -std=legacy accept everything and warn about nothing.
	* lang.opt (std=legacy): New F95 command line option.
	* invoke.texi: Document both -std=f2003 and -std=legacy.
	* gfortran.texi: Explain the two types of extensions and document
	how they are affected by the various -std= command line options.

From-SVN: r100377
This commit is contained in:
Roger Sayle 2005-05-30 22:16:08 +00:00 committed by Roger Sayle
parent d5c405cc71
commit c0309c74ca
6 changed files with 51 additions and 12 deletions

View File

@ -1,3 +1,18 @@
2005-05-30 Roger Sayle <roger@eyesopen.com>
* gfortran.h (GFC_STD_LEGACY): New "standard" macro. Reindent.
* options.c (gfc_init_options): By default, allow legacy extensions
but warn about them.
(gfc_post_options): Make -pedantic warn about legacy extensions
even with -std=legacy.
(gfc_handle_option): Make -std=gnu follow the default behaviour
of warning about legacy extensions, but allowing them. Make the
new -std=legacy accept everything and warn about nothing.
* lang.opt (std=legacy): New F95 command line option.
* invoke.texi: Document both -std=f2003 and -std=legacy.
* gfortran.texi: Explain the two types of extensions and document
how they are affected by the various -std= command line options.
2005-05-30 Kazu Hirata <kazu@cs.umass.edu> 2005-05-30 Kazu Hirata <kazu@cs.umass.edu>
* trans-expr.c: Remove trailing ^M. * trans-expr.c: Remove trailing ^M.

View File

@ -92,13 +92,14 @@ mstring;
/* Flags to specify which standard/extension contains a feature. */ /* Flags to specify which standard/extension contains a feature. */
#define GFC_STD_GNU (1<<5) /* GNU Fortran extension. */ #define GFC_STD_LEGACY (1<<6) /* Backward compatibility. */
#define GFC_STD_F2003 (1<<4) /* New in F2003. */ #define GFC_STD_GNU (1<<5) /* GNU Fortran extension. */
#define GFC_STD_F2003 (1<<4) /* New in F2003. */
/* Note that no features were obsoleted nor deleted in F2003. */ /* Note that no features were obsoleted nor deleted in F2003. */
#define GFC_STD_F95 (1<<3) /* New in F95. */ #define GFC_STD_F95 (1<<3) /* New in F95. */
#define GFC_STD_F95_DEL (1<<2) /* Deleted in F95. */ #define GFC_STD_F95_DEL (1<<2) /* Deleted in F95. */
#define GFC_STD_F95_OBS (1<<1) /* Obsoleted in F95. */ #define GFC_STD_F95_OBS (1<<1) /* Obsoleted in F95. */
#define GFC_STD_F77 (1<<0) /* Up to and including F77. */ #define GFC_STD_F77 (1<<0) /* Up to and including F77. */
/*************************** Enums *****************************/ /*************************** Enums *****************************/

View File

@ -618,7 +618,14 @@ Variable for swapping Endianness during unformatted write.
@command{gfortran} implements a number of extensions over standard @command{gfortran} implements a number of extensions over standard
Fortran. This chapter contains information on their syntax and Fortran. This chapter contains information on their syntax and
meaning. meaning. There are currently two categories of @command{gfortran}
extensions, those that provide functionality beyond that provided
by any standard, and those that are supported by @command{gfortran}
purely for backward compatibility with legacy compilers. By default,
@option{-std=gnu} allows the compiler to accept both types of
extensions, but to warn about the use of the latter. Specifying
either @option{-std=f95} or @option{-std=f2003} disables both types
of extensions, and @option{-std=legacy} allows both without warning.
@menu @menu
* Old-style kind specifications:: * Old-style kind specifications::

View File

@ -248,7 +248,7 @@ Specify that no implicit typing is allowed, unless overridden by explicit
@cindex option, -std=@var{std} @cindex option, -std=@var{std}
@item -std=@var{std} @item -std=@var{std}
Conform to the specified standard. Allowed values for @var{std} are Conform to the specified standard. Allowed values for @var{std} are
@samp{gnu} and @samp{f95}. @samp{gnu}, @samp{f95}, @samp{f2003} and @samp{legacy}.
@end table @end table

View File

@ -161,4 +161,8 @@ std=gnu
F95 F95
Conform nothing in particular. Conform nothing in particular.
std=legacy
F95
Accept extensions to support legacy code.
; This comment is to ensure we retain the blank line above. ; This comment is to ensure we retain the blank line above.

View File

@ -77,9 +77,10 @@ gfc_init_options (unsigned int argc ATTRIBUTE_UNUSED,
flag_errno_math = 0; flag_errno_math = 0;
gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
| GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F77 | GFC_STD_GNU; | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F77 | GFC_STD_GNU
| GFC_STD_LEGACY;
gfc_option.warn_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL gfc_option.warn_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
| GFC_STD_F2003; | GFC_STD_F2003 | GFC_STD_LEGACY;
gfc_option.warn_nonstd_intrinsics = 0; gfc_option.warn_nonstd_intrinsics = 0;
@ -113,6 +114,9 @@ gfc_post_options (const char **pfilename)
/* If -pedantic, warn about the use of GNU extensions. */ /* If -pedantic, warn about the use of GNU extensions. */
if (pedantic && (gfc_option.allow_std & GFC_STD_GNU) != 0) if (pedantic && (gfc_option.allow_std & GFC_STD_GNU) != 0)
gfc_option.warn_std |= GFC_STD_GNU; gfc_option.warn_std |= GFC_STD_GNU;
/* -std=legacy -pedantic is effectively -std=gnu. */
if (pedantic && (gfc_option.allow_std & GFC_STD_LEGACY) != 0)
gfc_option.warn_std |= GFC_STD_F95_OBS | GFC_STD_F95_DEL | GFC_STD_LEGACY;
/* If the user didn't explicitly specify -f(no)-second-underscore we /* If the user didn't explicitly specify -f(no)-second-underscore we
use it if we're trying to be compatible with f2c, and not use it if we're trying to be compatible with f2c, and not
@ -333,8 +337,16 @@ gfc_handle_option (size_t scode, const char *arg, int value)
case OPT_std_gnu: case OPT_std_gnu:
gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
| GFC_STD_F77 | GFC_STD_F95 | GFC_STD_F2003 | GFC_STD_F77 | GFC_STD_F95 | GFC_STD_F2003
| GFC_STD_GNU; | GFC_STD_GNU | GFC_STD_LEGACY;
gfc_option.warn_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL; gfc_option.warn_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
| GFC_STD_LEGACY;
break;
case OPT_std_legacy:
gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
| GFC_STD_F77 | GFC_STD_F95 | GFC_STD_F2003
| GFC_STD_GNU | GFC_STD_LEGACY;
gfc_option.warn_std = 0;
break; break;
case OPT_Wnonstd_intrinsics: case OPT_Wnonstd_intrinsics: