+2020-03-12 Tobias Burnus <tobias@codesourcery.com>
+
+ PR middle-end/94120
+ * openmp.c (gfc_match_oacc_declare): Accept function-result
+ variables; reject variables declared in a different scoping unit.
+
2020-03-08 Paul Thomas <pault@gcc.gnu.org>
PR fortran/93581
{
gfc_symbol *s = n->sym;
- if (s->ns->proc_name && s->ns->proc_name->attr.proc == PROC_MODULE)
+ if (gfc_current_ns->proc_name
+ && gfc_current_ns->proc_name->attr.flavor == FL_MODULE)
{
if (n->u.map_op != OMP_MAP_ALLOC && n->u.map_op != OMP_MAP_TO)
{
return MATCH_ERROR;
}
+ if ((s->result == s && s->ns->contained != gfc_current_ns)
+ || ((s->attr.flavor == FL_UNKNOWN || s->attr.flavor == FL_VARIABLE)
+ && s->ns != gfc_current_ns))
+ {
+ gfc_error ("Variable %qs shall be declared in the same scoping unit "
+ "as !$ACC DECLARE at %L", s->name, &where);
+ return MATCH_ERROR;
+ }
+
if ((s->attr.dimension || s->attr.codimension)
&& s->attr.dummy && s->as->type != AS_EXPLICIT)
{
+2020-03-12 Tobias Burnus <tobias@codesourcery.com>
+
+ PR middle-end/94120
+ * gfortran.dg/goacc/pr78260-2.f90: Correct scan-tree-dump-times.
+ Extend test case to result variables.
+ * gfortran.dg/goacc/declare-2.f95: Actually check module-declaration
+ restriction of OpenACC.
+ * gfortran.dg/goacc/declare-3.f95: Remove case where this
+ restriction is violated.
+ * gfortran.dg/goacc/pr94120-1.f90: New.
+ * gfortran.dg/goacc/pr94120-2.f90: New.
+ * gfortran.dg/goacc/pr94120-3.f90: New.
+
2020-03-12 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/94130
module amod
-
-contains
-
-subroutine asubr (b)
implicit none
integer :: b(8)
!$acc declare present_or_create (b) ! { dg-error "present on multiple" }
!$acc declare deviceptr (b) ! { dg-error "Invalid clause in module" }
!$acc declare create (b) copyin (b) ! { dg-error "present on multiple" }
+end module
+module amod2
+contains
+subroutine asubr (a, b, c, d, e, f, g, h, i, j, k)
+ implicit none
+ integer, dimension(8) :: a, b, c, d, e, f, g, h, i, j, k
+
+ !$acc declare copy (a)
+ !$acc declare copyout (b)
+ !$acc declare present (c)
+ !$acc declare present_or_copy (d)
+ !$acc declare present_or_copyin (e)
+ !$acc declare present_or_copyout (f)
+ !$acc declare present_or_create (g)
+ !$acc declare deviceptr (h)
+ !$acc declare create (j) copyin (k)
end subroutine
-
end module
module bmod
!$acc declare copyin (b)
end module
-module mod_c
- implicit none
- integer :: c
- !$acc declare deviceptr (c)
-end module
-
module mod_d
implicit none
integer :: d
subroutine sub1
use mod_a
use mod_b
- use mod_c
use mod_d
use mod_e
end subroutine sub1
program test
use mod_a
use mod_b
- use mod_c
use mod_d
use mod_e
- ! { dg-final { scan-tree-dump {(?n)#pragma acc data map\(force_alloc:d\) map\(force_deviceptr:c\) map\(force_to:b\) map\(force_alloc:a\)$} original } }
+ ! { dg-final { scan-tree-dump {(?n)#pragma acc data map\(force_alloc:d\) map\(force_to:b\) map\(force_alloc:a\)$} original } }
end program test
! { dg-final { scan-tree-dump-times {#pragma acc data} 1 original } }
! PR fortran/78260
+! Loosely related to PR fortran/94120
+
module m
implicit none
integer :: n = 0
f1 = 5
!$acc end kernels
end function f1
+ integer function g1() result(g1res)
+ !$acc declare present(g1res)
+ !$acc kernels copyin(g1res)
+ g1res = 5
+ !$acc end kernels
+ end function g1
end module m
! { dg-final { scan-tree-dump-times "#pragma acc data map\\(force_present:__result_f1\\)" 1 "original" } }
-! { dg-final { scan-tree-dump-times "#pragma acc data map\\(force_present:__result_f1\\)" 1 "original" } }
-
+! { dg-final { scan-tree-dump-times "#pragma acc kernels map\\(to:__result_f1\\)" 1 "original" } }
+! { dg-final { scan-tree-dump-times "#pragma acc data map\\(force_present:g1res\\)" 1 "original" } }
+! { dg-final { scan-tree-dump-times "#pragma acc kernels map\\(to:g1res\\)" 1 "original" } }
--- /dev/null
+! { dg-do compile }
+!
+! PR fortran/94120
+!
+implicit none
+integer :: i
+contains
+ subroutine f()
+ !$acc declare copy(i) ! { dg-error "Variable 'i' shall be declared in the same scoping unit as !.ACC DECLARE" }
+ end
+end
--- /dev/null
+! { dg-do compile }
+!
+! PR fortran/94120
+!
+! BLOCK is not supported in OpenACC <= 3.0
+!
+subroutine f()
+ block
+ integer :: k
+ !$acc declare copy(j) ! { dg-error "Sorry, !.ACC DECLARE at .1. is not allowed in BLOCK construct" }
+ end block
+end
--- /dev/null
+! { dg-do compile }
+!
+! PR fortran/94120
+!
+! Note: BLOCK is not supported in OpenACC <= 3.0 – but the following check comes earlier:
+! It is also invalid because the variable is in a different scoping unit
+!
+subroutine g()
+ integer :: k
+ block
+ !$acc declare copy(k) ! { dg-error "Variable 'k' shall be declared in the same scoping unit as !.ACC DECLARE" }
+ end block
+end