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 va

Programming / Compilers / GCC - jakub [138bc75d-0d04-0410-961f-82ee72b054a4] - 8 September 2016 07:19 EDT

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.

###

diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 82513f4..a0be074 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,10 @@
+2016-09-08 Jakub Jelinek
+
+ 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.
+
2016-09-04 Steven G. Kargl

PR fortran/77391
diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c
index c0d6761..e4a2975 100644
--- a/gcc/fortran/trans-openmp.c
+++ b/gcc/fortran/trans-openmp.c
@@ -2818,7 +2818,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;

@@ -2857,6 +2861,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;
}
@@ -2914,6 +2919,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
@@ -2927,6 +2933,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
@@ -3041,6 +3048,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;

diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9075d48..7cbb87a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2016-09-08 Jakub Jelinek

+ 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
index 0000000..1572d5c
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/pr77500.f90
@@ -0,0 +1,9 @@
+! PR fortran/77500
+! { dg-do compile }
+
+program pr77500
+ real :: x
+!$omp atomic write
+ x = f()
+!$omp end atomic
+end

a34338c 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.
gcc/fortran/ChangeLog | 7 +++++++
gcc/fortran/trans-openmp.c | 10 +++++++++-
gcc/testsuite/ChangeLog | 3 +++
gcc/testsuite/gfortran.dg/gomp/pr77500.f90 | 9 +++++++++
4 files changed, 28 insertions(+), 1 deletion(-)

Upstream: gcc.gnu.org


  • Share