From ca8ecd919453664b1312e6c7d236e404731d8bb0 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Wed, 19 Jun 2019 00:15:43 +0200 Subject: [PATCH] [PR85221] Set 'omp declare target', 'omp declare target link' attributes for Fortran OpenACC 'declare'd variables gcc/fortran/ PR fortran/85221 * trans-decl.c (add_attributes_to_decl): Handle OpenACC 'declare' directive. gcc/testsuite/ PR fortran/85221 * gfortran.dg/goacc/declare-3.f95: New file. From-SVN: r272453 --- gcc/fortran/ChangeLog | 6 +++ gcc/fortran/trans-decl.c | 9 +++- gcc/testsuite/ChangeLog | 3 ++ gcc/testsuite/gfortran.dg/goacc/declare-3.f95 | 47 +++++++++++++++++++ 4 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/goacc/declare-3.f95 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index d30fa2e50a8..6fd97b61ce0 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-06-18 Thomas Schwinge + + PR fortran/85221 + * trans-decl.c (add_attributes_to_decl): Handle OpenACC 'declare' + directive. + 2019-06-16 Thomas Koenig * dump_parse_tree (debug): Add verison for formal arglist. diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index b8e07274feb..f504c279c31 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -1432,10 +1432,15 @@ add_attributes_to_decl (symbol_attribute sym_attr, tree list) list = oacc_replace_fn_attrib_attr (list, dims); } - if (sym_attr.omp_declare_target_link) + if (sym_attr.omp_declare_target_link + || sym_attr.oacc_declare_link) list = tree_cons (get_identifier ("omp declare target link"), NULL_TREE, list); - else if (sym_attr.omp_declare_target) + else if (sym_attr.omp_declare_target + || sym_attr.oacc_declare_create + || sym_attr.oacc_declare_copyin + || sym_attr.oacc_declare_deviceptr + || sym_attr.oacc_declare_device_resident) list = tree_cons (get_identifier ("omp declare target"), clauses, list); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 59d39e8c179..552ccc6fbd6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2019-06-18 Thomas Schwinge + PR fortran/85221 + * gfortran.dg/goacc/declare-3.f95: New file. + PR middle-end/90859 * c-c++-common/goacc/firstprivate-mappings-1.c: Update. diff --git a/gcc/testsuite/gfortran.dg/goacc/declare-3.f95 b/gcc/testsuite/gfortran.dg/goacc/declare-3.f95 new file mode 100644 index 00000000000..ec5d4c5a062 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/declare-3.f95 @@ -0,0 +1,47 @@ +! Test valid usage of the OpenACC 'declare' directive. + +module mod_a + implicit none + integer :: a + !$acc declare create (a) +end module + +module mod_b + implicit none + integer :: b + !$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 + !$acc declare device_resident (d) +end module + +module mod_e + implicit none + integer :: e + !$acc declare link (e) +end module + +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 +end program test -- 2.30.2