diff options
author | Fritz O. Reese <fritzoreese@gmail.com> | 2016-11-03 16:00:58 +0000 |
---|---|---|
committer | Fritz Reese <foreese@gcc.gnu.org> | 2016-11-03 16:00:58 +0000 |
commit | 35ea947ffabd427908f9fa0b5df56c6fe58176ff (patch) | |
tree | 4b94c9ccf0d58309cda7b6af4ee09b7212fc57fa /gcc/fortran | |
parent | c0ae959bedcbeae109608c9a13903407bd9b636e (diff) | |
download | gcc-35ea947ffabd427908f9fa0b5df56c6fe58176ff.zip gcc-35ea947ffabd427908f9fa0b5df56c6fe58176ff.tar.gz gcc-35ea947ffabd427908f9fa0b5df56c6fe58176ff.tar.bz2 |
Support legacy PARAMETER statements with -std=legacy.
gcc/fortran/
* decl.c (gfc_match_parameter): Allow omitted '()' with -std=legacy.
* parse.c (decode_statement): Match "parameter" before assignments.
* gfortran.texi: Document.
gcc/testsuite/gfortran.dg/
* dec_parameter_1.f: New test.
* dec_parameter_2.f90: Likewise.
* dec_parameter_3.f90: Likewise.
* dec_parameter_4.f90: Likewise.
From-SVN: r241823
Diffstat (limited to 'gcc/fortran')
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/decl.c | 10 | ||||
-rw-r--r-- | gcc/fortran/gfortran.texi | 18 | ||||
-rw-r--r-- | gcc/fortran/parse.c | 4 |
4 files changed, 35 insertions, 3 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index d47eeb0..baec7bf 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2016-11-03 Fritz O. Reese <fritzoreese@gmail.com> + + * decl.c (gfc_match_parameter): Allow omitted '()' with -std=legacy. + * parse.c (decode_statement): Match "parameter" before assignments. + * gfortran.texi: Document. + 2016-11-02 Fritz O. Reese <fritzoreese@gmail.com> * lang.opt, invoke.texi: New argument -Wargument-mismatch. diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index f18eb41..0120ceb 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -7821,10 +7821,16 @@ cleanup: match gfc_match_parameter (void) { + const char *term = " )%t"; match m; if (gfc_match_char ('(') == MATCH_NO) - return MATCH_NO; + { + /* With legacy PARAMETER statements, don't expect a terminating ')'. */ + if (!gfc_notify_std (GFC_STD_LEGACY, "PARAMETER without '()' at %C")) + return MATCH_NO; + term = " %t"; + } for (;;) { @@ -7832,7 +7838,7 @@ gfc_match_parameter (void) if (m != MATCH_YES) break; - if (gfc_match (" )%t") == MATCH_YES) + if (gfc_match (term) == MATCH_YES) break; if (gfc_match_char (',') != MATCH_YES) diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi index e65c2de..cd2c5a5 100644 --- a/gcc/fortran/gfortran.texi +++ b/gcc/fortran/gfortran.texi @@ -1471,6 +1471,7 @@ compatibility extensions along with those enabled by @option{-std=legacy}. * .XOR. operator:: * Bitwise logical operators:: * Extended I/O specifiers:: +* Legacy PARAMETER statements:: @end menu @node Old-style kind specifications @@ -2696,6 +2697,23 @@ supported on other systems. @end table +@node Legacy PARAMETER statements +@subsection Legacy PARAMETER statements +@cindex PARAMETER + +For compatibility, GNU Fortran supports legacy PARAMETER statements without +parentheses with @option{-std=legacy}. A warning is emitted if used with +@option{-std=gnu}, and an error is acknowledged with a real Fortran standard +flag (@option{-std=f95}, etc...). These statements take the following form: + +@smallexample +implicit real (E) +parameter e = 2.718282 +real c +parameter c = 3.0e8 +@end smallexample + + @node Extensions not implemented in GNU Fortran @section Extensions not implemented in GNU Fortran @cindex extensions, not implemented diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c index 2aa2afc..0ee054a 100644 --- a/gcc/fortran/parse.c +++ b/gcc/fortran/parse.c @@ -352,6 +352,9 @@ decode_statement (void) } gfc_matching_function = false; + /* Legacy parameter statements are ambiguous with assignments so try parameter + first. */ + match ("parameter", gfc_match_parameter, ST_PARAMETER); /* Match statements whose error messages are meant to be overwritten by something better. */ @@ -528,7 +531,6 @@ decode_statement (void) case 'p': match ("print", gfc_match_print, ST_WRITE); - match ("parameter", gfc_match_parameter, ST_PARAMETER); match ("pause", gfc_match_pause, ST_PAUSE); match ("pointer", gfc_match_pointer, ST_ATTR_DECL); if (gfc_match_private (&st) == MATCH_YES) |