[PR72741] For all Fortran OpenACC 'routine' directive variants check for multiple...
authorThomas Schwinge <thomas@codesourcery.com>
Thu, 28 Feb 2019 20:31:23 +0000 (21:31 +0100)
committerThomas Schwinge <tschwinge@gcc.gnu.org>
Thu, 28 Feb 2019 20:31:23 +0000 (21:31 +0100)
gcc/fortran/
PR fortran/72741
* gfortran.h (enum oacc_routine_lop): Add OACC_ROUTINE_LOP_ERROR.
* openmp.c (gfc_oacc_routine_lop, gfc_match_oacc_routine): Use it.
* trans-decl.c (add_attributes_to_decl): Likewise.
gcc/testsuite/
PR fortran/72741
* gfortran.dg/goacc/routine-multiple-lop-clauses-1.f90: New file.

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

gcc/fortran/ChangeLog
gcc/fortran/gfortran.h
gcc/fortran/openmp.c
gcc/fortran/trans-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/goacc/routine-multiple-lop-clauses-1.f90 [new file with mode: 0644]

index 78c6324d1b8399163483eec37a671911ff8b5eed..1c8f7125298064554587fc0d8f05c49899f37e68 100644 (file)
@@ -1,6 +1,11 @@
 2019-02-28  Thomas Schwinge  <thomas@codesourcery.com>
            Cesar Philippidis  <cesar@codesourcery.com>
 
+       PR fortran/72741
+       * gfortran.h (enum oacc_routine_lop): Add OACC_ROUTINE_LOP_ERROR.
+       * openmp.c (gfc_oacc_routine_lop, gfc_match_oacc_routine): Use it.
+       * trans-decl.c (add_attributes_to_decl): Likewise.
+
        PR fortran/72741
        PR fortran/89433
        * openmp.c (gfc_match_oacc_routine): Accept intrinsic symbols.
index f0258b39ffd16aa538372eca0b4b3e929f133aca..3e0f634c3a8e3992f13054b0df26ba1d698e7c50 100644 (file)
@@ -323,7 +323,8 @@ enum oacc_routine_lop
   OACC_ROUTINE_LOP_GANG,
   OACC_ROUTINE_LOP_WORKER,
   OACC_ROUTINE_LOP_VECTOR,
-  OACC_ROUTINE_LOP_SEQ
+  OACC_ROUTINE_LOP_SEQ,
+  OACC_ROUTINE_LOP_ERROR
 };
 
 /* Strings for all symbol attributes.  We use these for dumping the
index 6999ac34a1a9d3d5c3901b4c467ae9831951427c..50b91f2150ab75b026be5b68e980d11848c2dcbc 100644 (file)
@@ -2265,7 +2265,7 @@ gfc_oacc_routine_lop (gfc_omp_clauses *clauses)
        }
 
       if (n_lop_clauses > 1)
-       gfc_error ("Multiple loop axes specified for routine");
+       ret = OACC_ROUTINE_LOP_ERROR;
     }
 
   return ret;
@@ -2280,6 +2280,7 @@ gfc_match_oacc_routine (void)
   gfc_symbol *sym = NULL;
   gfc_omp_clauses *c = NULL;
   gfc_oacc_routine_name *n = NULL;
+  oacc_routine_lop lop = OACC_ROUTINE_LOP_NONE;
 
   old_loc = gfc_current_locus;
 
@@ -2352,6 +2353,13 @@ gfc_match_oacc_routine (void)
          != MATCH_YES))
     return MATCH_ERROR;
 
+  lop = gfc_oacc_routine_lop (c);
+  if (lop == OACC_ROUTINE_LOP_ERROR)
+    {
+      gfc_error ("Multiple loop axes specified for routine at %C");
+      goto cleanup;
+    }
+
   if (isym != NULL)
     {
       /* Diagnose any OpenACC 'routine' directive that doesn't match the
@@ -2381,8 +2389,7 @@ gfc_match_oacc_routine (void)
                                       gfc_current_ns->proc_name->name,
                                       &old_loc))
        goto cleanup;
-      gfc_current_ns->proc_name->attr.oacc_routine_lop
-       = gfc_oacc_routine_lop (c);
+      gfc_current_ns->proc_name->attr.oacc_routine_lop = lop;
     }
   else
     /* Something has gone wrong, possibly a syntax error.  */
index 20d453051a2944c06e32e8dd9e5e6a83b6eed9b4..36b7fdd2701f2ed2c6ee8eabe818214caf104943 100644 (file)
@@ -1425,6 +1425,7 @@ add_attributes_to_decl (symbol_attribute sym_attr, tree list)
          code = OMP_CLAUSE_SEQ;
          break;
        case OACC_ROUTINE_LOP_NONE:
+       case OACC_ROUTINE_LOP_ERROR:
        default:
          gcc_unreachable ();
        }
index c45e7b7546a9b8e66403b551f83d8adeb7764d74..9f4c598951c3d482ef8ecd4973c079a0b15f85b7 100644 (file)
@@ -1,6 +1,9 @@
 2019-02-28  Thomas Schwinge  <thomas@codesourcery.com>
            Cesar Philippidis  <cesar@codesourcery.com>
 
+       PR fortran/72741
+       * gfortran.dg/goacc/routine-multiple-lop-clauses-1.f90: New file.
+
        PR fortran/72741
        PR fortran/89433
        * gfortran.dg/goacc/routine-6.f90: Update
diff --git a/gcc/testsuite/gfortran.dg/goacc/routine-multiple-lop-clauses-1.f90 b/gcc/testsuite/gfortran.dg/goacc/routine-multiple-lop-clauses-1.f90
new file mode 100644 (file)
index 0000000..8ca9be8
--- /dev/null
@@ -0,0 +1,32 @@
+! Check for multiple clauses specifying the level of parallelism.
+
+SUBROUTINE v_1
+  !$ACC ROUTINE VECTOR WORKER ! { dg-error "Multiple loop axes specified for routine" }
+END SUBROUTINE v_1
+
+SUBROUTINE sub_1
+  IMPLICIT NONE
+  EXTERNAL :: g_1
+  !$ACC ROUTINE (g_1) GANG WORKER ! { dg-error "Multiple loop axes specified for routine" }
+  !$ACC ROUTINE (ABORT) SEQ WORKER GANG VECTOR ! { dg-error "Multiple loop axes specified for routine" }
+  !$ACC ROUTINE WORKER SEQ ! { dg-error "Multiple loop axes specified for routine" }
+
+  CALL v_1
+  CALL g_1
+  CALL ABORT
+END SUBROUTINE sub_1
+
+MODULE m_w_1
+  IMPLICIT NONE
+  EXTERNAL :: w_1
+  !$ACC ROUTINE VECTOR GANG SEQ ! { dg-error "Multiple loop axes specified for routine" }
+  !$ACC ROUTINE (w_1) GANG WORKER SEQ ! { dg-error "Multiple loop axes specified for routine" }
+  !$ACC ROUTINE (ABORT) VECTOR GANG ! { dg-error "Multiple loop axes specified for routine" }
+
+CONTAINS
+  SUBROUTINE sub_2
+    CALL v_1
+    CALL w_1
+    CALL ABORT
+  END SUBROUTINE sub_2
+END MODULE m_w_1