This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[gomp3] Handle tabs like spaces
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Date: Tue, 27 May 2008 08:21:57 -0400
- Subject: [gomp3] Handle tabs like spaces
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
Pedantically !$omp must be followed by space to be valid, but seems
there are several OpenMP Fortran sources in the wild which use tabs.
The following patch accepts them (gfc_gobble_whitespace will take
care of pedantic warnings about tabs).
2008-05-27 Jakub Jelinek <jakub@redhat.com>
* scanner.c (skip_free_comments, skip_fixed_comments): Handle tabs.
* parse.c (next_free): Allow tab after !$omp.
* gfortran.dg/gomp/omp_parse1.f90: Remove !$omp tab test.
* testsuite/libgomp.fortran/tabs1.f90: New test.
* testsuite/libgomp.fortran/tabs2.f: Likewise.
--- gcc/fortran/scanner.c.jj 2008-05-16 10:23:12.000000000 +0200
+++ gcc/fortran/scanner.c 2008-05-27 13:48:00.000000000 +0200
@@ -700,7 +700,8 @@ skip_free_comments (void)
if (((c = next_char ()) == 'm' || c == 'M')
&& ((c = next_char ()) == 'p' || c == 'P'))
{
- if ((c = next_char ()) == ' ' || continue_flag)
+ if ((c = next_char ()) == ' ' || c == '\t'
+ || continue_flag)
{
while (gfc_is_whitespace (c))
c = next_char ();
@@ -722,7 +723,7 @@ skip_free_comments (void)
next_char ();
c = next_char ();
}
- if (continue_flag || c == ' ')
+ if (continue_flag || c == ' ' || c == '\t')
{
gfc_current_locus = old_loc;
next_char ();
@@ -818,11 +819,11 @@ skip_fixed_comments (void)
c = next_char ();
if (c != '\n'
&& ((openmp_flag && continue_flag)
- || c == ' ' || c == '0'))
+ || c == ' ' || c == '\t' || c == '0'))
{
- c = next_char ();
- while (gfc_is_whitespace (c))
+ do
c = next_char ();
+ while (gfc_is_whitespace (c));
if (c != '\n' && c != '!')
{
/* Canonicalize to *$omp. */
@@ -841,6 +842,11 @@ skip_fixed_comments (void)
for (col = 3; col < 6; col++, c = next_char ())
if (c == ' ')
continue;
+ else if (c == '\t')
+ {
+ col = 6;
+ break;
+ }
else if (c < '0' || c > '9')
break;
else
@@ -848,7 +854,7 @@ skip_fixed_comments (void)
if (col == 6 && c != '\n'
&& ((continue_flag && !digit_seen)
- || c == ' ' || c == '0'))
+ || c == ' ' || c == '\t' || c == '0'))
{
gfc_current_locus = start;
start.nextc[0] = ' ';
--- gcc/fortran/parse.c.jj 2008-05-16 10:23:23.000000000 +0200
+++ gcc/fortran/parse.c 2008-05-27 13:37:07.000000000 +0200
@@ -643,7 +643,7 @@ next_free (void)
for (i = 0; i < 5; i++, c = gfc_next_ascii_char ())
gcc_assert (c == "!$omp"[i]);
- gcc_assert (c == ' ');
+ gcc_assert (c == ' ' || c == '\t');
gfc_gobble_whitespace ();
return decode_omp_directive ();
}
--- gcc/testsuite/gfortran.dg/gomp/omp_parse1.f90.jj 2007-11-14 12:36:30.000000000 +0100
+++ gcc/testsuite/gfortran.dg/gomp/omp_parse1.f90 2008-05-27 14:14:12.000000000 +0200
@@ -14,10 +14,6 @@ call bar
!$omp rallel
call bar
!$omp end parallel
-! Non-continuation !$omp must be followed by space, and my reading
-! doesn't seem to allow tab there. So such lines should be completely
-! ignored.
-!$omp strange ! { dg-warning "starts a commented line" }
end
! { dg-final { scan-tree-dump-times "pragma omp parallel" 3 "omplower" } }
--- libgomp/testsuite/libgomp.fortran/tabs1.f90.jj 2008-05-27 14:02:03.000000000 +0200
+++ libgomp/testsuite/libgomp.fortran/tabs1.f90 2008-05-27 14:02:22.000000000 +0200
@@ -0,0 +1,12 @@
+ if (b().ne.2) call abort
+contains
+subroutine a
+!$omp parallel
+ !$omp end parallel
+ end subroutine a
+function b()
+ integer :: b
+ b = 1
+ !$ b = 2
+end function b
+ end
--- libgomp/testsuite/libgomp.fortran/tabs2.f.jj 2008-05-27 14:02:06.000000000 +0200
+++ libgomp/testsuite/libgomp.fortran/tabs2.f 2008-05-27 14:02:35.000000000 +0200
@@ -0,0 +1,13 @@
+! { dg-options "-ffixed-form" }
+ if (b().ne.2) call abort
+ contains
+ subroutine a
+!$omp parallel
+!$omp end parallel
+ end subroutine a
+ function b()
+ integer :: b
+ b = 1
+!$ b = 2
+ end function b
+ end
Jakub