Message ID | 20191031221602.GA13698@troutmask.apl.washington.edu |
---|---|
State | New |
Headers | show |
Series | Fix the fix for PR fortran/90988 | expand |
On 10/31/19 11:16 PM, Steve Kargl wrote: > Jeff Law sent me an email … caused a regression for fixed-form > source code. Interesting, what kind of code is used in the real world! > OK to commit? OK. Thanks for the patch! Tobias > 2019-10-31 Steven G. Kargl <kargl@gcc.gnu.org> > > PR fortran/90988 > * decl.c (gfc_match_private, gfc_match_public): Fixed-form source code > does not require whitespace between PRIVATE (or PUBLIC) and an entity. > > 2019-10-31 Steven G. Kargl <kargl@gcc.gnu.org> > > PR fortran/90988 > * gfortran.dg/pr90988_4.f: New test.
On 11/1/19 1:49 AM, Tobias Burnus wrote: > On 10/31/19 11:16 PM, Steve Kargl wrote: > >> Jeff Law sent me an email … caused a regression for fixed-form >> source code. > > Interesting, what kind of code is used in the real world! It's from the dl_poly package in Fedora IIRC. It was the only instance of this problem across the Fedora builds. jeff
On Fri, Nov 01, 2019 at 08:49:58AM +0100, Tobias Burnus wrote: > On 10/31/19 11:16 PM, Steve Kargl wrote: > > > Jeff Law sent me an email … caused a regression for fixed-form > > source code. > > Interesting, what kind of code is used in the real world! > Jeff sent me the file from dl_poly that ran into thre regression. The dl_ploy developers use modern Fortran, but at least one file restrict themselves to fixed-form source code. This seems to be an odd choice to me, but it is legal Fortran. > > OK to commit? > > OK. Thanks for the patch! > Thanks. And, sorry about the regression.
Index: gcc/fortran/decl.c =================================================================== --- gcc/fortran/decl.c (revision 277696) +++ gcc/fortran/decl.c (working copy) @@ -9059,7 +9079,6 @@ match gfc_match_private (gfc_statement *st) { gfc_state_data *prev; - char c; if (gfc_match ("private") != MATCH_YES) return MATCH_NO; @@ -9083,10 +9102,14 @@ gfc_match_private (gfc_statement *st) return MATCH_YES; } - /* At this point, PRIVATE must be followed by whitespace or ::. */ - c = gfc_peek_ascii_char (); - if (!gfc_is_whitespace (c) && c != ':') - return MATCH_NO; + /* At this point in free-form source code, PRIVATE must be followed + by whitespace or ::. */ + if (gfc_current_form == FORM_FREE) + { + char c = gfc_peek_ascii_char (); + if (!gfc_is_whitespace (c) && c != ':') + return MATCH_NO; + } prev = gfc_state_stack->previous; if (gfc_current_state () != COMP_MODULE @@ -9108,8 +9131,6 @@ gfc_match_private (gfc_statement *st) match gfc_match_public (gfc_statement *st) { - char c; - if (gfc_match ("public") != MATCH_YES) return MATCH_NO; @@ -9127,10 +9148,14 @@ gfc_match_public (gfc_statement *st) return MATCH_YES; } - /* At this point, PUBLIC must be followed by whitespace or ::. */ - c = gfc_peek_ascii_char (); - if (!gfc_is_whitespace (c) && c != ':') - return MATCH_NO; + /* At this point in free-form source code, PUBLIC must be followed + by whitespace or ::. */ + if (gfc_current_form == FORM_FREE) + { + char c = gfc_peek_ascii_char (); + if (!gfc_is_whitespace (c) && c != ':') + return MATCH_NO; + } if (gfc_current_state () != COMP_MODULE) { Index: gcc/testsuite/gfortran.dg/pr90988_4.f =================================================================== --- gcc/testsuite/gfortran.dg/pr90988_4.f (nonexistent) +++ gcc/testsuite/gfortran.dg/pr90988_4.f (working copy) @@ -0,0 +1,10 @@ +c { dg-do compile } + module foo + implicit none + real a,b,c + integer i,j,k + public a,b + publicc + private i,j + privatek + end module foo