openmp: Fix up !$omp target parallel handling
authorJakub Jelinek <jakub@redhat.com>
Wed, 22 Jan 2020 08:54:59 +0000 (09:54 +0100)
committerJakub Jelinek <jakub@redhat.com>
Wed, 22 Jan 2020 08:54:59 +0000 (09:54 +0100)
The PR93329 fix revealed we ICE on !$omp target parallel, this change fixes
that.

2020-01-22  Jakub Jelinek  <jakub@redhat.com>

* parse.c (parse_omp_structured_block): Handle ST_OMP_TARGET_PARALLEL.
* trans-openmp.c (gfc_trans_omp_target)
<case EXEC_OMP_TARGET_PARALLEL>: Call pushlevel first.

* gfortran.dg/gomp/target-parallel1.f90: New test.
* gfortran.dg/goacc/pr93329.f90: Enable commented out target parallel
test.

gcc/ChangeLog
gcc/cp/ChangeLog
gcc/fortran/ChangeLog
gcc/fortran/parse.c
gcc/fortran/trans-openmp.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/goacc/pr93329.f90
gcc/testsuite/gfortran.dg/gomp/target-parallel1.f90 [new file with mode: 0644]

index 223f52d08b1454a8b14e53367742d6b12266f334..d338a4a9728bcf5d97cf9322f9fd7a936d50f305 100644 (file)
@@ -13,7 +13,6 @@
        <case SYMBOL_SMALL_TLSGD>: Call gen_tlsgd_small_* with a ptr_mode
        register.  Convert that register back to dest using convert_mode.
 
-
 2020-01-21  Jim Wilson  <jimw@sifive.com>
 
        * config/riscv/riscv-sr.c (riscv_sr_match_prologue): Use INTVAL
index 4c195c48b030ffa5b107381ee6ce9a39c5f789fa..1609344ac6fd029838d9df2a014846cce9336974 100644 (file)
@@ -1,10 +1,10 @@
-2020-01-22  Jun Ma <JunMa@linux.alibaba.com>
+2020-01-22  Jun Ma  <JunMa@linux.alibaba.com>
 
        * coroutines.cc (finish_co_await_expr): Add error check on return
        value of build_co_await.
        (finish_co_yield_expr,): Ditto.
 
-2020-01-22  Jun Ma <JunMa@linux.alibaba.com>
+2020-01-22  Jun Ma  <JunMa@linux.alibaba.com>
 
        * coroutines.cc (lookup_awaitable_member): Lookup an awaitable member.
        (lookup_promise_method): Emit diagnostic when get NULL_TREE back only.
index 031c75bb5e5fbf000d19b7498883b319ff651541..ceefdf8c03ddd97c76bda6e700fa49957a1143d8 100644 (file)
@@ -1,5 +1,9 @@
 2020-01-22  Jakub Jelinek  <jakub@redhat.com>
 
+       * parse.c (parse_omp_structured_block): Handle ST_OMP_TARGET_PARALLEL.
+       * trans-openmp.c (gfc_trans_omp_target)
+       <case EXEC_OMP_TARGET_PARALLEL>: Call pushlevel first.
+
        PR fortran/93329
        * openmp.c (omp_code_to_statement): Handle remaining EXEC_OMP_*
        cases.
index 68cd58ef702bfcdba47b75087b25cc2f37da9ecf..4bff0c885e2322f8b09419c65b5dac8fa36ba403 100644 (file)
@@ -5231,6 +5231,9 @@ parse_omp_structured_block (gfc_statement omp_st, bool workshare_stmts_only)
     case ST_OMP_TARGET_DATA:
       omp_end_st = ST_OMP_END_TARGET_DATA;
       break;
+    case ST_OMP_TARGET_PARALLEL:
+      omp_end_st = ST_OMP_END_TARGET_PARALLEL;
+      break;
     case ST_OMP_TARGET_TEAMS:
       omp_end_st = ST_OMP_END_TARGET_TEAMS;
       break;
index 9835d2aae3c1743c72e8421c84888c0b71e7e434..fd60bbbed5de1e1686973ef0053a97514b9d3d69 100644 (file)
@@ -5357,6 +5357,7 @@ gfc_trans_omp_target (gfc_code *code)
       {
        stmtblock_t iblock;
 
+       pushlevel ();
        gfc_start_block (&iblock);
        tree inner_clauses
          = gfc_trans_omp_clauses (&block, &clausesa[GFC_OMP_SPLIT_PARALLEL],
index 0c04921f60d9806f4c06a61b81f017aec33e176a..552270d874cf708220bbaa4d4f393c5fffb3b927 100644 (file)
@@ -1,5 +1,9 @@
 2020-01-22  Jakub Jelinek  <jakub@redhat.com>
 
+       * gfortran.dg/gomp/target-parallel1.f90: New test.
+       * gfortran.dg/goacc/pr93329.f90: Enable commented out target parallel
+       test.
+
        PR fortran/93329
        * gfortran.dg/goacc/pr93329.f90: New test.
 
index aed264a03e990d8b775dbeff4fb788bbd8474773..b2d25bda88b3abf8af4d8740b4af694f3f3be999 100644 (file)
@@ -68,8 +68,8 @@
 !$omp target exit data map(from: x)    ! { dg-error "OMP TARGET EXIT DATA directive cannot be specified within" }
 !$acc end kernels
 !$acc kernels
-!!$omp target parallel
-!!$omp end target parallel
+!$omp target parallel          ! { dg-error "OMP TARGET PARALLEL directive cannot be specified within" }
+!$omp end target parallel
 !$acc end kernels
 !$acc kernels
 !$omp target parallel do       ! { dg-error "OMP TARGET PARALLEL DO directive cannot be specified within" }
diff --git a/gcc/testsuite/gfortran.dg/gomp/target-parallel1.f90 b/gcc/testsuite/gfortran.dg/gomp/target-parallel1.f90
new file mode 100644 (file)
index 0000000..bb8561f
--- /dev/null
@@ -0,0 +1,4 @@
+!$omp target parallel
+  print *, 'Hello, world'
+!$omp end target parallel
+end