]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR fortran/77500 (ICE in gfc_trans_omp_atomic, at fortran/trans-openmp...
authorJakub Jelinek <jakub@redhat.com>
Tue, 30 May 2017 07:21:41 +0000 (09:21 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 30 May 2017 07:21:41 +0000 (09:21 +0200)
Backported from mainline
2016-09-08  Jakub Jelinek  <jakub@redhat.com>

PR fortran/77500
* trans-openmp.c (gfc_trans_omp_atomic): For atomic write or
swap, don't try to look through GFC_ISYM_CONVERSION.  In other cases,
check that value.function.isym is non-NULL before dereferencing it.

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

From-SVN: r248605

gcc/fortran/ChangeLog
gcc/fortran/trans-openmp.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/gomp/pr77500.f90 [new file with mode: 0644]

index f4424d49aec62611dcbe710c7c29ef2072a617f9..c21acd8a345fd7d1e371c72fd3745cf3a9ac700c 100644 (file)
@@ -1,3 +1,13 @@
+2017-05-30  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       2016-09-08  Jakub Jelinek  <jakub@redhat.com>
+
+       PR fortran/77500
+       * trans-openmp.c (gfc_trans_omp_atomic): For atomic write or
+       swap, don't try to look through GFC_ISYM_CONVERSION.  In other cases,
+       check that value.function.isym is non-NULL before dereferencing it.
+
 2017-05-10  Richard Biener  <rguenther@suse.de>
 
        Backport from mainline
index 970cd406352e16b6701c7a4b5b72c2169806b6f7..e2182f62d2623b4cdfb8279a030aa63fc6d04998 100644 (file)
@@ -2792,7 +2792,11 @@ gfc_trans_omp_atomic (gfc_code *code)
   gfc_start_block (&block);
 
   expr2 = code->expr2;
-  if (expr2->expr_type == EXPR_FUNCTION
+  if (((atomic_code->ext.omp_atomic & GFC_OMP_ATOMIC_MASK)
+       != GFC_OMP_ATOMIC_WRITE)
+      && (atomic_code->ext.omp_atomic & GFC_OMP_ATOMIC_SWAP) == 0
+      && expr2->expr_type == EXPR_FUNCTION
+      && expr2->value.function.isym
       && expr2->value.function.isym->id == GFC_ISYM_CONVERSION)
     expr2 = expr2->value.function.actual->expr;
 
@@ -2831,6 +2835,7 @@ gfc_trans_omp_atomic (gfc_code *code)
          var = code->expr1->symtree->n.sym;
          expr2 = code->expr2;
          if (expr2->expr_type == EXPR_FUNCTION
+             && expr2->value.function.isym
              && expr2->value.function.isym->id == GFC_ISYM_CONVERSION)
            expr2 = expr2->value.function.actual->expr;
        }
@@ -2888,6 +2893,7 @@ gfc_trans_omp_atomic (gfc_code *code)
        }
       e = expr2->value.op.op1;
       if (e->expr_type == EXPR_FUNCTION
+         && e->value.function.isym
          && e->value.function.isym->id == GFC_ISYM_CONVERSION)
        e = e->value.function.actual->expr;
       if (e->expr_type == EXPR_VARIABLE
@@ -2901,6 +2907,7 @@ gfc_trans_omp_atomic (gfc_code *code)
        {
          e = expr2->value.op.op2;
          if (e->expr_type == EXPR_FUNCTION
+             && e->value.function.isym
              && e->value.function.isym->id == GFC_ISYM_CONVERSION)
            e = e->value.function.actual->expr;
          gcc_assert (e->expr_type == EXPR_VARIABLE
@@ -3015,6 +3022,7 @@ gfc_trans_omp_atomic (gfc_code *code)
          code = code->next;
          expr2 = code->expr2;
          if (expr2->expr_type == EXPR_FUNCTION
+             && expr2->value.function.isym
              && expr2->value.function.isym->id == GFC_ISYM_CONVERSION)
            expr2 = expr2->value.function.actual->expr;
 
index 828e2a9b082abc7499d675f4c4fcc97f74727c78..4ccb6310c06b24d3318898ba7f2356a84b770895 100644 (file)
@@ -3,6 +3,9 @@
        Backported from mainline
        2016-09-08  Jakub Jelinek  <jakub@redhat.com>
 
+       PR fortran/77500
+       * gfortran.dg/gomp/pr77500.f90: New test.
+
        PR fortran/77516
        * gfortran.dg/gomp/pr77516.f90: New test.
 
diff --git a/gcc/testsuite/gfortran.dg/gomp/pr77500.f90 b/gcc/testsuite/gfortran.dg/gomp/pr77500.f90
new file mode 100644 (file)
index 0000000..1572d5c
--- /dev/null
@@ -0,0 +1,9 @@
+! PR fortran/77500
+! { dg-do compile }
+
+program pr77500
+   real :: x
+!$omp atomic write
+   x = f()
+!$omp end atomic
+end