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]

Re: [GOMP4, OpenACC] Fixed-form Fortran code failing to parse


On 07/04/2014 01:40 AM, Thomas Schwinge wrote:

> On Wed, 02 Jul 2014 14:53:19 +0200, I wrote:
>> I understand the attached fixed.f to be well-formed fixed-form Fortran
>> code, but it fails to parse in OpenACC mode:
> 
> The legacy of Fortran ;-) strikes again:
> 
>     $ gcc/xgcc -Bgcc/ -Bx86_64-unknown-linux-gnu/lib{gomp,gfortran}/ -Bx86_64-unknown-linux-gnu/lib{gomp,gfortran}/.libs -Ix86_64-unknown-linux-gnu/lib{gomp,gfortran} -I../source/lib{gomp,gfortran} -Lx86_64-unknown-linux-gnu/lib{gomp,gfortran}/.libs -Wl,-rpath,"$PWD"/x86_64-unknown-linux-gnu/lib{gomp,gfortran}/.libs ../../fixed-3.f -fopenacc -c
>     ../../fixed-3.f:7.6:
>     
>     *$ACC END PARALLEL                                                      
>           1
>     Error: Unclassifiable OpenACC directive at (1)
> 
> ..., and again:
> 
>     $ gcc/xgcc -Bgcc/ -Bx86_64-unknown-linux-gnu/lib{gomp,gfortran}/ -Bx86_64-unknown-linux-gnu/lib{gomp,gfortran}/.libs -Ix86_64-unknown-linux-gnu/lib{gomp,gfortran} -I../source/lib{gomp,gfortran} -Lx86_64-unknown-linux-gnu/lib{gomp,gfortran}/.libs -Wl,-rpath,"$PWD"/x86_64-unknown-linux-gnu/lib{gomp,gfortran}/.libs ../../fixed-4.f -fopenacc -c
>     ../../fixed-4.f:3.6:
>     
>     *$ACC PARALLEL                                                          
>           1
>     Error: Unclassifiable OpenACC directive at (1)
> 
> The corresponding OpenMP examples parse fine.
> 
> 
>> We should then also be adding some test coverage for fixed-form mode in
>> gcc/testsuite/gfortran.dg/goacc/.

Yeah. It doesn't look like there was any openacc testing in fixed-form
mode. This time, there were a couple of typos in scanner which caused
gfc_next_char and friends to fail when handling fixed-form comments.
There was also something being handled strangely in the parser, when I
went ahead and fixed. I think there may be a few more bugs lurking in
the fixed-form comment handling.

Thomas, is this OK for gomp-4_0-branch?

Cesar
2014-07-07  Cesar Philippidis  <cesar@codesourcery.com>

	gcc/fortran/
	* parse.c (next_fixed): Don't handle openmp pragmas when scanning 
	for openacc pragmas.
	* gcc/fortran/scanner.c (gfc_next_char_literal): Fix the scan for
	*$acc.
	
	gcc/testsuite/
	* gfortran.dg/goacc/fixed-3.f:
	* gfortran.dg/goacc/fixed-4.f:


diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c
index 9dd8099..c5e0d0a 100644
--- a/gcc/fortran/parse.c
+++ b/gcc/fortran/parse.c
@@ -1071,9 +1071,15 @@ next_fixed (void)
 		    return ST_NONE;
 		  return decode_omp_directive ();
 		}
-	      else if ((gfc_option.gfc_flag_openmp
-			|| gfc_option.gfc_flag_openmp_simd)
-		       && gfc_option.gfc_flag_openacc)
+	      else if (gfc_option.gfc_flag_openacc
+		       && !(gfc_option.gfc_flag_openmp
+			    || gfc_option.gfc_flag_openmp_simd))
+		{
+		  if (!verify_token_fixed ("acc", 3, last_was_use_stmt))
+		    return ST_NONE;
+		  return decode_oacc_directive ();
+		}
+	      else
 		{
 		  c = gfc_next_char_literal(NONSTRING);
 		  if (c == 'o' || c == 'O')
@@ -1089,12 +1095,6 @@ next_fixed (void)
 		      return decode_oacc_directive ();
 		    }
 		}
-	      else if (gfc_option.gfc_flag_openacc)
-		{
-		  if (!verify_token_fixed ("acc", 3, last_was_use_stmt))
-		    return ST_NONE;
-		  return decode_oacc_directive ();
-		}
 	    }
 	  /* FALLTHROUGH */
 
diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c
index 5869d7d..1078f7b 100644
--- a/gcc/fortran/scanner.c
+++ b/gcc/fortran/scanner.c
@@ -1462,10 +1462,10 @@ restart:
 	      goto not_continuation;
 	  }
       else if (openacc_flag)
-	for (i = 0; i > 5; i++)
+	for (i = 0; i < 5; i++)
 	  {
 	    c = next_char ();
-	    if (gfc_wide_tolower (c) != (unsigned char) "*$omp"[i])
+	    if (gfc_wide_tolower (c) != (unsigned char) "*$acc"[i])
 	      goto not_continuation;
 	  }
 
diff --git a/gcc/testsuite/gfortran.dg/goacc/fixed-3.f b/gcc/testsuite/gfortran.dg/goacc/fixed-3.f
new file mode 100644
index 0000000..ede361e
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc/fixed-3.f
@@ -0,0 +1,13 @@
+      IMPLICIT NONE
+
+      INTEGER DEV
+
+!$ACC PARALLEL
+      DEV = 0
+!$ACC END PARALLEL
+
+!$ACC PARALLEL
+      DEV = 0
+!$ACC END PARALLEL
+
+      END
diff --git a/gcc/testsuite/gfortran.dg/goacc/fixed-4.f b/gcc/testsuite/gfortran.dg/goacc/fixed-4.f
new file mode 100644
index 0000000..120d5a9
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc/fixed-4.f
@@ -0,0 +1,6 @@
+      IMPLICIT NONE
+
+!$ACC PARALLEL
+!$ACC END PARALLEL
+
+      END

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