This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Committed] PR fortran/90297 -- Don't issue EQUIVALENCE syntax error
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Fri, 2 Aug 2019 14:34:09 -0700
- Subject: [Committed] PR fortran/90297 -- Don't issue EQUIVALENCE syntax error
- Reply-to: sgk at troutmask dot apl dot washington dot edu
I've committed the attached patch. After matching
EQUIVALNCE, the patch goobles any possible whitespace
and then checks that the next character is '('. If
it isn't '(', return MATCH_NO to give other matches a
chance to run.
2019-08-02 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/90297
* match.c (gfc_match_equivalence): Check that EQUIVALENCE is followed
by '('.
2019-08-02 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/90297
* gfortran.dg/equiv_10.f90: New test.
--
Steve
Index: gcc/fortran/match.c
===================================================================
--- gcc/fortran/match.c (revision 274021)
+++ gcc/fortran/match.c (working copy)
@@ -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;
Index: gcc/testsuite/gfortran.dg/equiv_10.f90
===================================================================
--- gcc/testsuite/gfortran.dg/equiv_10.f90 (nonexistent)
+++ gcc/testsuite/gfortran.dg/equiv_10.f90 (working copy)
@@ -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