This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[gomp] Fix 2 -ffixed-form -fopenmp parsing bugs (PR fortran/24493)
- 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: Mon, 24 Oct 2005 05:13:47 -0400
- Subject: [gomp] Fix 2 -ffixed-form -fopenmp parsing bugs (PR fortran/24493)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
I have committed the following fix for PR fortran/24493:
2005-10-24 Jakub Jelinek <jakub@redhat.com>
PR fortran/24493
* scanner.c (skip_free_comments): Set at_bol at the beginning of the
loop, not before it.
(skip_fixed_comments): Handle ! comments in the middle of line here
as well.
(gfc_skip_comments): Use skip_fixed_comments for FIXED_FORM even if
not at BOL.
(gfc_next_char_literal): Fix expected canonicalized *$omp string.
* gfortran.dg/gomp/fixed-1.f: New test.
* gfortran.dg/gomp/free-1.f: New test.
--- gcc/fortran/scanner.c.jj 2005-09-20 10:25:18.000000000 +0200
+++ gcc/fortran/scanner.c 2005-10-24 10:26:34.000000000 +0200
@@ -322,18 +322,17 @@ skip_free_comments (void)
{
locus start;
char c;
- int at_bol = gfc_at_bol ();
+ int at_bol;
for (;;)
{
+ at_bol = gfc_at_bol ();
start = gfc_current_locus;
if (gfc_at_eof ())
break;
do
- {
- c = next_char ();
- }
+ c = next_char ();
while (gfc_is_whitespace (c));
if (c == '\n')
@@ -409,6 +408,28 @@ skip_fixed_comments (void)
int col;
char c;
+ if (! gfc_at_bol ())
+ {
+ start = gfc_current_locus;
+ if (! gfc_at_eof ())
+ {
+ do
+ c = next_char ();
+ while (gfc_is_whitespace (c));
+
+ if (c == '\n')
+ gfc_advance_line ();
+ else if (c == '!')
+ skip_comment_line ();
+ }
+
+ if (! gfc_at_bol ())
+ {
+ gfc_current_locus = start;
+ return;
+ }
+ }
+
for (;;)
{
start = gfc_current_locus;
@@ -527,14 +548,12 @@ skip_fixed_comments (void)
}
-/* Skips the current line if it is a comment. Assumes that we are at
- the start of the current line. */
+/* Skips the current line if it is a comment. */
void
gfc_skip_comments (void)
{
-
- if (!gfc_at_bol () || gfc_current_form == FORM_FREE)
+ if (gfc_current_form == FORM_FREE)
skip_free_comments ();
else
skip_fixed_comments ();
@@ -700,7 +719,7 @@ restart:
for (i = 0; i < 5; i++)
{
c = next_char ();
- if (TOLOWER (c) != "!$omp"[i])
+ if (TOLOWER (c) != "*$omp"[i])
goto not_continuation;
}
--- gcc/testsuite/gfortran.dg/gomp/free-1.f90.jj 2005-10-24 10:38:27.000000000 +0200
+++ gcc/testsuite/gfortran.dg/gomp/free-1.f90 2005-10-24 10:37:38.000000000 +0200
@@ -0,0 +1,6 @@
+subroutine foo
+integer, save :: i ! Some comment
+!$omp threadpri&
+ !$omp&vate (i)
+i = 1
+end subroutine
--- gcc/testsuite/gfortran.dg/gomp/fixed-1.f.jj 2005-10-24 10:35:16.000000000 +0200
+++ gcc/testsuite/gfortran.dg/gomp/fixed-1.f 2005-10-24 10:35:54.000000000 +0200
@@ -0,0 +1,21 @@
+C PR fortran/24493
+C { dg-do compile }
+ INTEGER I, J, K, L, M
+C$OMP THREADPRIVATE(I)
+C SOME COMMENT
+ SAVE I ! ANOTHER COMMENT
+C$OMP THREADPRIVATE
+C$OMP+(J) ! OMP DIRECTIVE COMMENT
+* NORMAL COMMENT
+c$OMP THREAD! COMMENT
+C$OMP&PRIVATE! COMMENT
+*$OMP+ (K)
+C$OMP THREADPRIVATE (L ! COMMENT
+*$OMP& , M)
+ SAVE J, K, L, M
+ I = 1
+ J = 2
+ K = 3
+ L = 4
+ M = 5
+ END
Jakub