From 69352933301e0f67078fff8404b1eeb5c14d6b60 Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Fri, 21 Jun 2019 16:57:24 +0000 Subject: [PATCH] re PR fortran/51991 (Wrong error message with variables named "SAVE*") 2019-06-21 Steven G. Kargl PR fortran/51991 * decl.c (gfc_match_save): If SAVE was not seen, return MATCH_NO instead issuing an error message and returning MATCH_ERROR. 2019-06-21 Steven G. Kargl PR fortran/51991 gfortran.dg/pr51991.f90 From-SVN: r272556 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/decl.c | 9 +++++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr51991.f90 | 21 +++++++++++++++++++++ 4 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pr51991.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 56aca1f..6a3bd62 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-06-21 Steven G. Kargl + + PR fortran/51991 + * decl.c (gfc_match_save): If SAVE was not seen, return MATCH_NO + instead issuing an error message and returning MATCH_ERROR. + 2019-06-20 Steven G. Kargl PR fortran/77632 diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index f5517f0..d338a94 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -9302,8 +9302,13 @@ gfc_match_save (void) return MATCH_YES; syntax: - gfc_error ("Syntax error in SAVE statement at %C"); - return MATCH_ERROR; + if (gfc_current_ns->seen_save) + { + gfc_error ("Syntax error in SAVE statement at %C"); + return MATCH_ERROR; + } + else + return MATCH_NO; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3f99b80..9826e3d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-06-21 Steven G. Kargl + + PR fortran/51991 + gfortran.dg/pr51991.f90 + 2019-06-21 Jeff Law PR tree-optimization/90949 diff --git a/gcc/testsuite/gfortran.dg/pr51991.f90 b/gcc/testsuite/gfortran.dg/pr51991.f90 new file mode 100644 index 0000000..30a18e2 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr51991.f90 @@ -0,0 +1,21 @@ +! { dg-do compile } +! PR fortran/51991 +! Orginal code contributed by Sebastien Bardeau +module mymod + type :: mytyp + integer :: i + end type mytyp +contains + subroutine mysub + implicit none + type(mytyp) :: a + integer :: i,j + i = a%i + ! + ! Prior to patching gfortran, the following lined generated a syntax + ! error with the SAVE statement. Now, gfortran generates an error + ! that indicates 'j' is not a component of 'mytyp'. + ! + j = a%j ! { dg-error "is not a member of the" } + end subroutine mysub +end module mymod -- 2.7.4