commit e5446f2201d93fc9adc913ed320aa70437ff4235
Author: Tobias Burnus <tobias@codesourcery.com>
Date: Mon Feb 3 12:09:46 2020 +0100
[Fortran] Disable front-end optimization for OpenACC atomic (PR93462)
Backported from mainline
2020-01-31 Tobias Burnus <tobias@codesourcery.com>
PR fortran/93462
* frontend-passes.c (gfc_code_walker): For EXEC_OACC_ATOMIC, set
in_omp_atomic to true prevent front-end optimization.
PR fortran/93462
* gfortran.dg/goacc/atomic-1.f90: New.
---
gcc/fortran/ChangeLog | 9 +++++++++
gcc/fortran/frontend-passes.c | 1 +
gcc/testsuite/ChangeLog | 8 ++++++++
gcc/testsuite/gfortran.dg/goacc/atomic-1.f90 | 17 +++++++++++++++++
4 files changed, 35 insertions(+)
@@ -1,3 +1,12 @@
+2020-02-03 Tobias Burnus <tobias@codesourcery.com>
+
+ Backported from mainline
+ 2020-01-31 Tobias Burnus <tobias@codesourcery.com>
+
+ PR fortran/93462
+ * frontend-passes.c (gfc_code_walker): For EXEC_OACC_ATOMIC, set
+ in_omp_atomic to true prevent front-end optimization.
+
2020-02-03 Tobias Burnus <tobias@codesourcery.com>
Backported from mainline
@@ -5260,6 +5260,7 @@ gfc_code_walker (gfc_code **c, walk_code_fn_t codefn, walk_expr_fn_t exprfn,
WALK_SUBEXPR (co->ext.dt->extra_comma);
break;
+ case EXEC_OACC_ATOMIC:
case EXEC_OMP_ATOMIC:
in_omp_atomic = true;
break;
@@ -1,3 +1,11 @@
+2020-02-03 Tobias Burnus <tobias@codesourcery.com>
+
+ Backported from mainline
+ 2020-01-31 Tobias Burnus <tobias@codesourcery.com>
+
+ PR fortran/93462
+ * gfortran.dg/goacc/atomic-1.f90: New.
+
2020-02-03 Tobias Burnus <tobias@codesourcery.com>
Backported from mainline
new file mode 100644
@@ -0,0 +1,17 @@
+! { dg-do compile }
+!
+! PR fortran/93462
+!
+! Contributed by G. Steinmetz
+!
+program p
+ integer :: n = 1
+ integer :: a
+!$acc atomic write
+ a = f(n) - f(n)
+contains
+ integer function f(x)
+ integer, intent(in) :: x
+ f = x
+ end
+end