This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gfortran] Fix PR 18869: multiple commons in a single line


The testcase from PR 18869 looks like this:
  common /foo/ a, /bar/ b
  common /baz/ c /foobar/ d
  end

We didn't succeed in free form because we didn't eat the whitespace between
the commons correctly. Patch below, new testcase attached. bubblestrapped and
regtested. OK?

- Tobi

2004-12-07  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>

	PR fortran/18869
	* match.c (gfc_match_common): Eat whitespace.

Index: match.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/match.c,v
retrieving revision 1.25
diff -u -p -r1.25 match.c
--- match.c     8 Nov 2004 14:56:39 -0000       1.25
+++ match.c     7 Dec 2004 19:50:19 -0000
@@ -2306,12 +2306,14 @@ gfc_match_common (void)
              as = NULL;
            }

+         gfc_gobble_whitespace ();
          if (gfc_match_eos () == MATCH_YES)
            goto done;
          if (gfc_peek_char () == '/')
            break;
          if (gfc_match_char (',') != MATCH_YES)
            goto syntax;
+         gfc_gobble_whitespace ();
          if (gfc_peek_char () == '/')
            break;
        }
! { dg-do compile }
! tests various allowed variants of the common statement
! inspired by PR 18869

! blank common block
      common x
      common y, z
      common // xx

! one named common block on a line
      common /a/ e
      
! appending to a common block
      common /a/ g

! several named common blocks on a line
      common /foo/ a, /bar/ b      ! note 'a' is also the name of the 
                                   ! above common block
      common /baz/ c /foobar/ d, /bazbar/ f

      end

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]