openmp.c (gfc_match_omp_clauses): Scan for clause vector_length before vector.
authorCesar Philippidis <cesar@codesourcery.com>
Fri, 15 Jul 2016 14:03:35 +0000 (07:03 -0700)
committerCesar Philippidis <cesar@gcc.gnu.org>
Fri, 15 Jul 2016 14:03:35 +0000 (07:03 -0700)
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.

From-SVN: r238375

gcc/fortran/ChangeLog
gcc/fortran/openmp.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/goacc/vector_length.f90 [new file with mode: 0644]

index 22ca4f4e48897f4f751163e121ef629da05791f4..51e8e2e55ef02decd5f66dec495ca7fff9d0185b 100644 (file)
@@ -1,3 +1,8 @@
+2016-07-15  Cesar Philippidis  <cesar@codesourcery.com>
+
+       * openmp.c (gfc_match_omp_clauses): Scan for clause vector_length
+       before vector.
+
 2016-07-15  Andre Vehreschild  <vehre@gcc.gnu.org>
 
        PR fortran/71807
index 865e0d9d5f063a2f0e5dff9d2b19ac0e46810607..9fff9942057b671ba6fdd099e8486a6bfdf95352 100644 (file)
@@ -1338,6 +1338,13 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, uint64_t mask,
            continue;
          break;
        case 'v':
+         /* VECTOR_LENGTH must be matched before VECTOR, because the latter
+            doesn't unconditionally match '('.  */
+         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 +1360,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)
index c3a56007ac07ed5038a3ba92a31388c7bc8f5b30..2a6ca3f2bc05ba60aea2022c225e7fc47d37f092 100644 (file)
@@ -1,3 +1,7 @@
+2016-07-15  Cesar Philippidis  <cesar@codesourcery.com>
+
+       * gfortran.dg/goacc/vector_length.f90: New test.
+
 2016-07-15  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/71881
diff --git a/gcc/testsuite/gfortran.dg/goacc/vector_length.f90 b/gcc/testsuite/gfortran.dg/goacc/vector_length.f90
new file mode 100644 (file)
index 0000000..ddab9cf
--- /dev/null
@@ -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