re PR middle-end/85879 (ICE in expand_debug_locations, at cfgexpand.c:5405)
authorChung-Lin Tang <cltang@codesourcery.com>
Thu, 31 May 2018 14:10:10 +0000 (14:10 +0000)
committerCesar Philippidis <cesar@gcc.gnu.org>
Thu, 31 May 2018 14:10:10 +0000 (07:10 -0700)
Fix PR middle-end/85879

gcc/
* gimplify.c (gimplify_adjust_omp_clauses): Add 'remove = true'
when emitting error on private/firstprivate reductions.
* omp-low.c (lower_omp_target): Avoid reference-type processing
on pointers for firstprivate clause.

gcc/testsuite/
* gfortran.dg/goacc/pr77371-1.f90: New test.
* gfortran.dg/goacc/pr77371-2.f90: New test.
* gfortran.dg/goacc/pr85879.f90: New test.

Co-Authored-By: Cesar Philippidis <cesar@codesourcery.com>
From-SVN: r261025

gcc/ChangeLog
gcc/gimplify.c
gcc/omp-low.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/goacc/pr77371-1.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/goacc/pr77371-2.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/goacc/pr85879.f90 [new file with mode: 0644]

index e696c32d3765da39d864eaa683afe050da1a6c53..c9cf570599c20c998db3db5fb729ce5171c67497 100644 (file)
@@ -1,3 +1,12 @@
+2018-05-31  Chung-Lin Tang  <cltang@codesourcery.com>
+           Cesar Philippidis  <cesar@codesourcery.com>
+
+       PR middle-end/85879
+       * gimplify.c (gimplify_adjust_omp_clauses): Add 'remove = true'
+       when emitting error on private/firstprivate reductions.
+       * omp-low.c (lower_omp_target): Avoid reference-type processing
+       on pointers for firstprivate clause.
+
 2018-05-31 Sameera Deshpande <sameera.deshpande@linaro.org>
 
        * config/aarch64/aarch64-simd-builtins.def (ld1x3): New.
index 9771804f27e53aed6c723171f4a72db59347569d..44cb784620afb4f3316ed85436498e2aea079f99 100644 (file)
@@ -9275,13 +9275,16 @@ gimplify_adjust_omp_clauses (gimple_seq *pre_p, gimple_seq body, tree *list_p,
        case OMP_CLAUSE_REDUCTION:
          decl = OMP_CLAUSE_DECL (c);
          /* OpenACC reductions need a present_or_copy data clause.
-            Add one if necessary.  Error is the reduction is private.  */
+            Add one if necessary.  Emit error when the reduction is private.  */
          if (ctx->region_type == ORT_ACC_PARALLEL)
            {
              n = splay_tree_lookup (ctx->variables, (splay_tree_key) decl);
              if (n->value & (GOVD_PRIVATE | GOVD_FIRSTPRIVATE))
-               error_at (OMP_CLAUSE_LOCATION (c), "invalid private "
-                         "reduction on %qE", DECL_NAME (decl));
+               {
+                 remove = true;
+                 error_at (OMP_CLAUSE_LOCATION (c), "invalid private "
+                           "reduction on %qE", DECL_NAME (decl));
+               }
              else if ((n->value & GOVD_MAP) == 0)
                {
                  tree next = OMP_CLAUSE_CHAIN (c);
index d8588b9faed0a937fd9ef5940e13e657d40a9d35..ba6c705cf8bd6959db4b48da1900ec1e3de37b8c 100644 (file)
@@ -7700,7 +7700,8 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
            if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FIRSTPRIVATE)
              {
                gcc_assert (is_gimple_omp_oacc (ctx->stmt));
-               if (omp_is_reference (new_var))
+               if (omp_is_reference (new_var)
+                   && TREE_CODE (TREE_TYPE (new_var)) != POINTER_TYPE)
                  {
                    /* Create a local object to hold the instance
                       value.  */
index a04fff8d188451d517bd0568a51967f3e6634b01..188ea7d7ed5d8bda4e3481b46f28cc5631ae05a9 100644 (file)
@@ -1,3 +1,11 @@
+2018-05-31  Chung-Lin Tang  <cltang@codesourcery.com>
+           Cesar Philippidis  <cesar@codesourcery.com>
+
+       PR middle-end/85879
+       * gfortran.dg/goacc/pr77371-1.f90: New test.
+       * gfortran.dg/goacc/pr77371-2.f90: New test.
+       * gfortran.dg/goacc/pr85879.f90: New test.
+
 2018-05-31  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/stack_usage1.adb: Replace -fstack-usage with -Wstack-usage.
diff --git a/gcc/testsuite/gfortran.dg/goacc/pr77371-1.f90 b/gcc/testsuite/gfortran.dg/goacc/pr77371-1.f90
new file mode 100644 (file)
index 0000000..11c29ba
--- /dev/null
@@ -0,0 +1,9 @@
+! PR fortran/77371
+! { dg-do compile }
+program p
+  character(:), allocatable :: z
+  !$acc parallel
+  z = 'abc' 
+  !$acc end parallel
+  print *, z
+end
diff --git a/gcc/testsuite/gfortran.dg/goacc/pr77371-2.f90 b/gcc/testsuite/gfortran.dg/goacc/pr77371-2.f90
new file mode 100644 (file)
index 0000000..9d42c17
--- /dev/null
@@ -0,0 +1,7 @@
+! PR fortran/77371
+! { dg-do compile }
+program p
+   integer, allocatable :: n
+!$acc parallel reduction (+:n) private(n) ! { dg-error "invalid private reduction" }
+!$acc end parallel
+end
diff --git a/gcc/testsuite/gfortran.dg/goacc/pr85879.f90 b/gcc/testsuite/gfortran.dg/goacc/pr85879.f90
new file mode 100644 (file)
index 0000000..cd50be2
--- /dev/null
@@ -0,0 +1,12 @@
+! PR middle-end/85879
+! { dg-do compile }
+
+program p
+   integer, pointer :: i
+   integer, target :: j
+   j = 2
+   i => j
+   !$acc parallel
+   j = i
+   !$acc end parallel
+end