Hi!

This patch fixes ICE on safelen(0).  Not adding a warning for this in the
FE, as it has been added already on gomp-4_5-branch, so when it is merged,
the testcase will just need to be adjusted for the added warning.

Tested on x86_64-linux, committed to trunk so far.

2016-09-08  Jakub Jelinek  <ja...@redhat.com>

        PR fortran/77516
        * omp-low.c (lower_rec_simd_input_clauses): Use max_vf for non-positive
        OMP_CLAUSE_SAFELEN_EXPR.

        * gfortran.dg/gomp/pr77516.f90: New test.

--- gcc/omp-low.c.jj    2016-09-06 20:00:33.000000000 +0200
+++ gcc/omp-low.c       2016-09-08 11:35:42.960174529 +0200
@@ -4302,7 +4302,9 @@ lower_rec_simd_input_clauses (tree new_v
        {
          tree c = find_omp_clause (gimple_omp_for_clauses (ctx->stmt),
                                    OMP_CLAUSE_SAFELEN);
-         if (c && TREE_CODE (OMP_CLAUSE_SAFELEN_EXPR (c)) != INTEGER_CST)
+         if (c
+             && (TREE_CODE (OMP_CLAUSE_SAFELEN_EXPR (c)) != INTEGER_CST
+                 || tree_int_cst_sgn (OMP_CLAUSE_SAFELEN_EXPR (c)) != 1))
            max_vf = 1;
          else if (c && compare_tree_int (OMP_CLAUSE_SAFELEN_EXPR (c),
                                          max_vf) == -1)
--- gcc/testsuite/gfortran.dg/gomp/pr77516.f90.jj       2016-09-08 
12:06:07.363581303 +0200
+++ gcc/testsuite/gfortran.dg/gomp/pr77516.f90  2016-09-08 11:59:33.000000000 
+0200
@@ -0,0 +1,12 @@
+! PR fortran/77516
+! { dg-do compile }
+
+program pr77516
+   integer :: i, x
+   x = 0
+!$omp simd safelen(0) reduction(+:x)
+   do i = 1, 8
+      x = x + 1
+   end do
+   print *, x
+end

        Jakub

Reply via email to