aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCesar Philippidis <cesar@codesourcery.com>2016-08-12 16:12:33 +0000
committerThomas Schwinge <thomas@codesourcery.com>2016-08-12 16:12:33 +0000
commitb695292cb8b340478e6159013d0e6fa1dbb3cb4d (patch)
tree7aecaa64b2c1e3d8dda05f612f12b7cb7877fb21
parentbb66631ba157b37fedb9bf52c27d073b8aa5d6ad (diff)
[PR fortran/72741] Check clauses with intrinsic function specified in !$ACC ROUTINE ( NAME )
gcc/fortran/ * openmp.c (gfc_match_oacc_routine): Check clauses of intrinsic functions. gcc/testsuite/ * gfortran.dg/goacc/pr72741-intrinsic-1.f: New file. * gfortran.dg/goacc/pr72741-intrinsic-2.f: Likewise. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@239422 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/fortran/ChangeLog.gomp7
-rw-r--r--gcc/fortran/openmp.c25
-rw-r--r--gcc/testsuite/ChangeLog.gomp7
-rw-r--r--gcc/testsuite/gfortran.dg/goacc/pr72741-intrinsic-1.f20
-rw-r--r--gcc/testsuite/gfortran.dg/goacc/pr72741-intrinsic-2.f22
5 files changed, 73 insertions, 8 deletions
diff --git a/gcc/fortran/ChangeLog.gomp b/gcc/fortran/ChangeLog.gomp
index 8744607e2a2..8b4ffc94989 100644
--- a/gcc/fortran/ChangeLog.gomp
+++ b/gcc/fortran/ChangeLog.gomp
@@ -1,3 +1,10 @@
+2016-08-12 Cesar Philippidis <cesar@codesourcery.com>
+ Thomas Schwinge <thomas@codesourcery.com>
+
+ PR fortran/72741
+ * openmp.c (gfc_match_oacc_routine): Check clauses of intrinsic
+ functions.
+
2016-07-29 Chung-Lin Tang <cltang@codesourcery.com>
PR fortran/70598
diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c
index e463df778f7..80f46c0b21f 100644
--- a/gcc/fortran/openmp.c
+++ b/gcc/fortran/openmp.c
@@ -1919,11 +1919,11 @@ match
gfc_match_oacc_routine (void)
{
locus old_loc;
- gfc_symbol *sym = NULL;
match m;
+ gfc_intrinsic_sym *isym = NULL;
+ gfc_symbol *sym = NULL;
gfc_omp_clauses *c = NULL;
gfc_oacc_routine_name *n = NULL;
- gfc_intrinsic_sym *isym = NULL;
oacc_function dims = OACC_FUNCTION_NONE;
old_loc = gfc_current_locus;
@@ -1957,7 +1957,7 @@ gfc_match_oacc_routine (void)
sym = NULL;
}
- if ((st == NULL && isym == NULL)
+ if ((isym == NULL && st == NULL)
|| (sym
&& !sym->attr.external
&& !sym->attr.function
@@ -1996,14 +1996,21 @@ gfc_match_oacc_routine (void)
dims = gfc_oacc_routine_dims (c);
if (dims == OACC_FUNCTION_NONE)
{
- gfc_error ("Multiple loop axes specified for routine %C");
- gfc_current_locus = old_loc;
- return MATCH_ERROR;
+ gfc_error ("Multiple loop axes specified in !$ACC ROUTINE at %C");
+ goto cleanup;
}
if (isym != NULL)
- /* There is nothing to do for intrinsic procedures. */
- ;
+ {
+ if (c && (c->gang || c->worker || c->vector))
+ {
+ gfc_error ("Intrinsic function specified in !$ACC ROUTINE ( NAME )"
+ " at %C, with incompatible GANG, WORKER, or VECTOR clause");
+ goto cleanup;
+ }
+ /* The intrinsic symbol has been marked with a SEQ, or with no clause at
+ all, which is OK. */
+ }
else if (sym != NULL)
{
n = gfc_get_oacc_routine_name ();
@@ -2025,6 +2032,8 @@ gfc_match_oacc_routine (void)
gfc_current_ns->proc_name->attr.oacc_function_nohost
= c ? c->nohost : false;
}
+ else
+ gcc_unreachable ();
if (n)
n->clauses = c;
diff --git a/gcc/testsuite/ChangeLog.gomp b/gcc/testsuite/ChangeLog.gomp
index 0b96504af52..8de44b64900 100644
--- a/gcc/testsuite/ChangeLog.gomp
+++ b/gcc/testsuite/ChangeLog.gomp
@@ -1,3 +1,10 @@
+2016-08-12 Cesar Philippidis <cesar@codesourcery.com>
+ Thomas Schwinge <thomas@codesourcery.com>
+
+ PR fortran/72741
+ * gfortran.dg/goacc/pr72741-intrinsic-1.f: New file.
+ * gfortran.dg/goacc/pr72741-intrinsic-2.f: Likewise.
+
2016-08-04 Thomas Schwinge <thomas@codesourcery.com>
* g++.dg/goacc/routine-2.C: Update.
diff --git a/gcc/testsuite/gfortran.dg/goacc/pr72741-intrinsic-1.f b/gcc/testsuite/gfortran.dg/goacc/pr72741-intrinsic-1.f
new file mode 100644
index 00000000000..4bff3e34cb1
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc/pr72741-intrinsic-1.f
@@ -0,0 +1,20 @@
+! Check for valid clauses with intrinsic function specified in !$ACC ROUTINE ( NAME ).
+
+ SUBROUTINE sub_1
+ IMPLICIT NONE
+!$ACC ROUTINE (ABORT)
+!$ACC ROUTINE (ABORT) SEQ
+
+ CALL ABORT
+ END SUBROUTINE sub_1
+
+ MODULE m_w_1
+ IMPLICIT NONE
+!$ACC ROUTINE (ABORT) SEQ
+!$ACC ROUTINE (ABORT)
+
+ CONTAINS
+ SUBROUTINE sub_2
+ CALL ABORT
+ END SUBROUTINE sub_2
+ END MODULE m_w_1
diff --git a/gcc/testsuite/gfortran.dg/goacc/pr72741-intrinsic-2.f b/gcc/testsuite/gfortran.dg/goacc/pr72741-intrinsic-2.f
new file mode 100644
index 00000000000..fed8e76edd0
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc/pr72741-intrinsic-2.f
@@ -0,0 +1,22 @@
+! Check for invalid clauses with intrinsic function specified in !$ACC ROUTINE ( NAME ).
+
+ SUBROUTINE sub_1
+ IMPLICIT NONE
+!$ACC ROUTINE (ABORT) WORKER ! { dg-error "Intrinsic function specified in \\!\\\$ACC ROUTINE \\( NAME \\) at \\(1\\), with incompatible GANG, WORKER, or VECTOR clause" }
+!$ACC ROUTINE (ABORT) GANG ! { dg-error "Intrinsic function specified in \\!\\\$ACC ROUTINE \\( NAME \\) at \\(1\\), with incompatible GANG, WORKER, or VECTOR clause" }
+!$ACC ROUTINE (ABORT) VECTOR ! { dg-error "Intrinsic function specified in \\!\\\$ACC ROUTINE \\( NAME \\) at \\(1\\), with incompatible GANG, WORKER, or VECTOR clause" }
+
+ CALL ABORT
+ END SUBROUTINE sub_1
+
+ MODULE m_w_1
+ IMPLICIT NONE
+!$ACC ROUTINE (ABORT) VECTOR ! { dg-error "Intrinsic function specified in \\!\\\$ACC ROUTINE \\( NAME \\) at \\(1\\), with incompatible GANG, WORKER, or VECTOR clause" }
+!$ACC ROUTINE (ABORT) WORKER ! { dg-error "Intrinsic function specified in \\!\\\$ACC ROUTINE \\( NAME \\) at \\(1\\), with incompatible GANG, WORKER, or VECTOR clause" }
+!$ACC ROUTINE (ABORT) GANG ! { dg-error "Intrinsic function specified in \\!\\\$ACC ROUTINE \\( NAME \\) at \\(1\\), with incompatible GANG, WORKER, or VECTOR clause" }
+
+ CONTAINS
+ SUBROUTINE sub_2
+ CALL ABORT
+ END SUBROUTINE sub_2
+ END MODULE m_w_1