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]

[PATCH] Fix OpenACC vector_length parsing in fortran


The fortran FE is currently scanning for the vector clause before
vector_length. That's a problem match_oacc_clause_gwv matches 'vector'
without looking for whatever follows it. The correction I made here was
to scan for vector_length before vector.

Is this OK for trunk and gcc6?

Cesar
2016-07-14  Cesar Philippidis  <cesar@codesourcery.com>

	gcc/fortran/
	* openmp.c (gfc_match_omp_clauses): Scan for clause vector_length
	before vector.

	gcc/testsuite/
	* gfortran.dg/goacc/vector_length.f90: New test.


diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c
index 865e0d9..b70ff3e 100644
--- a/gcc/fortran/openmp.c
+++ b/gcc/fortran/openmp.c
@@ -1338,6 +1338,11 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, uint64_t mask,
 	    continue;
 	  break;
 	case 'v':
+	  if ((mask & OMP_CLAUSE_VECTOR_LENGTH)
+	      && c->vector_length_expr == NULL
+	      && (gfc_match ("vector_length ( %e )", &c->vector_length_expr)
+		  == MATCH_YES))
+	    continue;
 	  if ((mask & OMP_CLAUSE_VECTOR)
 	      && !c->vector
 	      && gfc_match ("vector") == MATCH_YES)
@@ -1353,11 +1358,6 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, uint64_t mask,
 		needs_space = true;
 	      continue;
 	    }
-	  if ((mask & OMP_CLAUSE_VECTOR_LENGTH)
-	      && c->vector_length_expr == NULL
-	      && (gfc_match ("vector_length ( %e )", &c->vector_length_expr)
-		  == MATCH_YES))
-	    continue;
 	  break;
 	case 'w':
 	  if ((mask & OMP_CLAUSE_WAIT)
diff --git a/gcc/testsuite/gfortran.dg/goacc/vector_length.f90 b/gcc/testsuite/gfortran.dg/goacc/vector_length.f90
new file mode 100644
index 0000000..ddab9cf
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc/vector_length.f90
@@ -0,0 +1,11 @@
+program t
+  implicit none
+  integer, parameter :: n = 100
+  integer a(n), i
+
+  !$acc parallel loop num_gangs(100) num_workers(1) vector_length(32)
+  do i = 1, n
+     a(i) = i
+  enddo
+  !$acc end parallel loop
+end program t

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