]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[PR85221] Set 'omp declare target', 'omp declare target link' attributes for Fortran...
authortschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 18 Jun 2019 22:15:43 +0000 (22:15 +0000)
committertschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 18 Jun 2019 22:15:43 +0000 (22:15 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@272453 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/trans-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/goacc/declare-3.f95 [new file with mode: 0644]

index d30fa2e50a885e9857f993a9d1fa74b59bdcd76d..6fd97b61ce0568e709d70bdd73f0b7179230f0db 100644 (file)
@@ -1,3 +1,9 @@
+2019-06-18  Thomas Schwinge  <thomas@codesourcery.com>
+
+       PR fortran/85221
+       * trans-decl.c (add_attributes_to_decl): Handle OpenACC 'declare'
+       directive.
+
 2019-06-16  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        * dump_parse_tree (debug): Add verison for formal arglist.
index b8e07274febda7828c0d4376566298fa8d025176..f504c279c31bd05822289770d2a5fa2d529c891b 100644 (file)
@@ -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);
 
index 59d39e8c179a2b37e20d67b5ef7d2071467a3c24..552ccc6fbd68cfd11f6b93a564d188fe80504fa4 100644 (file)
@@ -1,5 +1,8 @@
 2019-06-18  Thomas Schwinge  <thomas@codesourcery.com>
 
+       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 (file)
index 0000000..ec5d4c5
--- /dev/null
@@ -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