From c7e3443332f8c97305d401e1a35cd65a15ada235 Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Fri, 1 Nov 2019 16:27:38 +0000 Subject: [PATCH] re PR fortran/90988 (Wrong error message with variables named "PUBLIC*") 2019-11-01 Steven G. Kargl 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-11-01 Steven G. Kargl PR fortran/90988 * gfortran.dg/pr90988_4.f: New test. From-SVN: r277714 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/decl.c | 27 ++++++++++++++++----------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr90988_4.f | 10 ++++++++++ 4 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pr90988_4.f diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index be8ae58f685..34d7a718c33 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-11-01 Steven G. Kargl + + 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-11-01 Tobias Burnus * f95-lang.c (LANG_HOOKS_OMP_ARRAY_DATA): Set to gfc_omp_array_data. diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 25a3967fac8..652b578b0dd 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -9059,7 +9059,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 +9082,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 +9111,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 +9128,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) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 57709cc911c..e7dec2ec882 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-11-01 Steven G. Kargl + + PR fortran/90988 + * gfortran.dg/pr90988_4.f: New test. + 2019-11-01 Martin Sebor * gcc.dg/tree-ssa/builtin-sprintf-warn-3.c: Declare test functions diff --git a/gcc/testsuite/gfortran.dg/pr90988_4.f b/gcc/testsuite/gfortran.dg/pr90988_4.f new file mode 100644 index 00000000000..3379b2e128d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr90988_4.f @@ -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 -- 2.30.2