Jeff Law sent me an email that showed my patch for PR fortran/90988 caused a regression for fixed-form source code. The attached patch address that regression.
Briefly, the original patch fixed free-form souce code parsing for 'PUBLICX' where the required whitespace was missing (i.e., 'PUBLIC X'). Unfortunately, the regression is that the original fix did not preserve fixed-form source code. OK to commit? 2019-10-31 Steven G. Kargl <ka...@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 <ka...@gcc.gnu.org> PR fortran/90988 * gfortran.dg/pr90988_4.f: New test. -- Steve
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