User account creation filtered due to spam.

Bug 34557 - Rejects valid: EQUIVALENCE of character substrings
Summary: Rejects valid: EQUIVALENCE of character substrings
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks: 32834
  Show dependency treegraph
 
Reported: 2007-12-22 19:10 UTC by Tobias Burnus
Modified: 2008-01-04 09:16 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.3.0
Last reconfirmed: 2008-01-02 22:38:48


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2007-12-22 19:10:13 UTC
! Rejects valid. EQUIVALENCE of substrings; fails with 4.[1-3].x with:
!
!EQUIVALENCE (A (2,1) (1:1), B (1) (2:3), C (3:5))
!                   1
!Error: Syntax error in EQUIVALENCE statement at (1)
!
! Found using the Fortran Company Fortran 90 Test Suite (Lite),
! Version 1.4
CHARACTER A(2,2)*2, B(2)*3, C*5
EQUIVALENCE (A (2,1) (1:1), B (1) (2:3), C (3:5))
end
Comment 1 Thomas Koenig 2008-01-02 22:38:48 UTC
Confirmed.  This is a regression vs. 4.2:

$ cat foo.f 
! Rejects valid. EQUIVALENCE of substrings; fails with 4.[1-3].x with:
!
!EQUIVALENCE (A (2,1) (1:1), B (1) (2:3), C (3:5))
!                   1
!Error: Syntax error in EQUIVALENCE statement at (1)
!
! Found using the Fortran Company Fortran 90 Test Suite (Lite),
! Version 1.4
      CHARACTER A(2,2)*2, B(2)*3, C*5
      EQUIVALENCE (A (2,1) (1:1), B (1) (2:3), C (3:5))
      end
$ gfortran-4.2 foo.f 
$              
Comment 2 Tobias Burnus 2008-01-03 12:53:15 UTC
> Confirmed.  This is a regression vs. 4.2:

I think it is not a regression with regards to 4.1 or 4.2. Here, it gives no ICE/error/warning for .f (fixed-form source) but it does so for .f90 (free-form source).

With free-form source, it works if one changes
      EQUIVALENCE (A (2,1) (1:1), B (1) (2:3), C (3:5))
into
      EQUIVALENCE (A (2,1)(1:1), B (1)(2:3), C(3:5))
Which explains why fixed form works and indicates what we do not eat the whitespaces when matching a substring.
Comment 3 Tobias Burnus 2008-01-03 15:38:53 UTC
Patch.

Index: gcc/fortran/primary.c
===================================================================
--- gcc/fortran/primary.c       (Revision 131302)
+++ gcc/fortran/primary.c       (Arbeitskopie)
@@ -1679,6 +1679,7 @@ match_varspec (gfc_expr *primary, int eq

   tail = NULL;

+  gfc_gobble_whitespace ();
   if ((equiv_flag && gfc_peek_char () == '(') || sym->attr.dimension)
     {
       /* In EQUIVALENCE, we don't know yet whether we are seeing
@@ -1692,6 +1693,7 @@ match_varspec (gfc_expr *primary, int eq
       if (m != MATCH_YES)
        return m;

+      gfc_gobble_whitespace ();
       if (equiv_flag && gfc_peek_char () == '(')
        {
          tail = extend_ref (primary, tail);
Comment 4 Thomas Koenig 2008-01-03 20:00:22 UTC
(In reply to comment #3)
> Patch.

Looks obvious and simple.

OK to commit if it passes regression-test.

Thomas
Comment 5 Tobias Burnus 2008-01-04 09:12:13 UTC
Subject: Bug 34557

Author: burnus
Date: Fri Jan  4 09:11:26 2008
New Revision: 131317

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131317
Log:
2008-01-04  Tobias Burnus  <burnus@net-b.de>

       PR fortran/34557
       * primary.c (match_varspec): Gobble whitespace before
       checking for '('.

2008-01-04  Tobias Burnus  <burnus@net-b.de>

       PR fortran/34557
       * gfortran.dg/equiv_substr.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/equiv_substr.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/primary.c
    trunk/gcc/testsuite/ChangeLog

Comment 6 Tobias Burnus 2008-01-04 09:16:18 UTC
FIXED on the trunk (4.3.0).