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 22ca4f4..51e8e2e 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 865e0d9..9fff994 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 c3a5600..2a6ca3f 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