From e6938b986e59813cf1c8345d0bd9851f09518261 Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Fri, 2 Aug 2019 21:28:58 +0000 Subject: [PATCH] re PR fortran/90297 (gcc/fortran/resolve.c: 2 * possibly redundant code ?) 2019-08-02 Steven G. Kargl PR fortran/90297 * match.c (gfc_match_equivalence): Check that EQUIVALENCE is followed by '('. 2019-08-02 Steven G. Kargl PR fortran/90297 * gfortran.dg/equiv_10.f90: New test. From-SVN: r274031 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/match.c | 9 +++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/equiv_10.f90 | 15 +++++++++++++++ 4 files changed, 35 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/equiv_10.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index fd55ca72bd3..c0d69ff9e34 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-08-02 Steven G. Kargl + + PR fortran/90297 + * match.c (gfc_match_equivalence): Check that EQUIVALENCE is followed + by '('. + 2019-07-30 Steven G. Kargl PR fortran/91296 diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index 0f3b2132122..5377e93871e 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -5552,6 +5552,15 @@ gfc_match_equivalence (void) gfc_common_head *common_head = NULL; bool common_flag; int cnt; + char c; + + /* EQUIVALENCE has been matched. After gobbling any possible whitespace, + the next character needs to be '('. Check that here, and return + MATCH_NO for a variable of the form equivalencej. */ + gfc_gobble_whitespace (); + c = gfc_peek_ascii_char (); + if (c != '(') + return MATCH_NO; tail = NULL; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 147d8f8536f..6a3c8708c8f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-08-02 Steven G. Kargl + + PR fortran/90297 + * gfortran.dg/equiv_10.f90: New test. + 2019-08-02 Marek Polacek PR c++/56428 diff --git a/gcc/testsuite/gfortran.dg/equiv_10.f90 b/gcc/testsuite/gfortran.dg/equiv_10.f90 new file mode 100644 index 00000000000..2d6d5c3b6df --- /dev/null +++ b/gcc/testsuite/gfortran.dg/equiv_10.f90 @@ -0,0 +1,15 @@ +! { dg-do compile } +! PR fortran/90986 +module mymod + type :: mytyp + integer :: i + end type mytyp +contains + subroutine mysub + implicit none + type(mytyp) :: a + integer :: equivalencei,equivalencej + equivalencei = a%i + equivalencej = a%j ! { dg-error "is not a member of the" } + end subroutine mysub +end module mymod -- 2.30.2