c-decl.c (c_decl_attributes): Also add "omp declare target" attribute for DECL_EXTERN...
authorJakub Jelinek <jakub@redhat.com>
Thu, 19 Mar 2015 19:12:43 +0000 (20:12 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 19 Mar 2015 19:12:43 +0000 (20:12 +0100)
* c-decl.c (c_decl_attributes): Also add "omp declare target"
attribute for DECL_EXTERNAL VAR_DECLs.

* decl2.c (cplus_decl_attributes): Also add "omp declare target"
attribute for DECL_EXTERNAL VAR_DECLs.

* testsuite/libgomp.c/target-10.c: New test.
* testsuite/libgomp.c++/target-4.C: New test.

From-SVN: r221520

gcc/c/ChangeLog
gcc/c/c-decl.c
gcc/cp/ChangeLog
gcc/cp/decl2.c
libgomp/ChangeLog
libgomp/testsuite/libgomp.c++/target-4.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c/target-10.c [new file with mode: 0644]

index 7f429c97a5b4a655402b742fd0cbadc5e4b44b75..ad5edcfbf48a58c9862f692922c8d6b6d881e811 100644 (file)
@@ -1,3 +1,8 @@
+2015-03-19  Jakub Jelinek  <jakub@redhat.com>
+
+       * c-decl.c (c_decl_attributes): Also add "omp declare target"
+       attribute for DECL_EXTERNAL VAR_DECLs.
+
 2015-03-11  Jakub Jelinek  <jakub@redhat.com>
 
        * c-parser.c (c_parse_init): Don't call xstrdup on get_identifier
index c140837f1392b33b5020ca0fe71111f126c390f0..e1741f130113810a88d158675db22d783177f1e3 100644 (file)
@@ -4407,7 +4407,8 @@ c_decl_attributes (tree *node, tree attributes, int flags)
 {
   /* Add implicit "omp declare target" attribute if requested.  */
   if (current_omp_declare_target_attribute
-      && ((TREE_CODE (*node) == VAR_DECL && TREE_STATIC (*node))
+      && ((TREE_CODE (*node) == VAR_DECL
+          && (TREE_STATIC (*node) || DECL_EXTERNAL (*node)))
          || TREE_CODE (*node) == FUNCTION_DECL))
     {
       if (TREE_CODE (*node) == VAR_DECL
index c8135ffa56fcb95c8fdcd41e262a693254e47499..f8ebb2dcfa9f18601a057c0f7efd0aeb1539bbc0 100644 (file)
@@ -1,3 +1,8 @@
+2015-03-19  Jakub Jelinek  <jakub@redhat.com>
+
+       * decl2.c (cplus_decl_attributes): Also add "omp declare target"
+       attribute for DECL_EXTERNAL VAR_DECLs.
+
 2015-03-18  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/65340
index a2d1eae2015662cd6683fae887e548a956d9dc01..989a0303babc785c3e9748124b797502a7701704 100644 (file)
@@ -1440,7 +1440,8 @@ cplus_decl_attributes (tree *decl, tree attributes, int flags)
 
   /* Add implicit "omp declare target" attribute if requested.  */
   if (scope_chain->omp_declare_target_attribute
-      && ((TREE_CODE (*decl) == VAR_DECL && TREE_STATIC (*decl))
+      && ((TREE_CODE (*decl) == VAR_DECL
+          && (TREE_STATIC (*decl) || DECL_EXTERNAL (*decl)))
          || TREE_CODE (*decl) == FUNCTION_DECL))
     {
       if (TREE_CODE (*decl) == VAR_DECL
index d62132105076450c87bcd903a2bd79fdb76bfa94..d1514733c43461d79f2b3a94b9542574f6c6b834 100644 (file)
@@ -1,3 +1,8 @@
+2015-03-19  Jakub Jelinek  <jakub@redhat.com>
+
+       * testsuite/libgomp.c/target-10.c: New test.
+       * testsuite/libgomp.c++/target-4.C: New test.
+
 2015-03-13  Ilya Verbin  <ilya.verbin@intel.com>
 
        * testsuite/libgomp.fortran/declare-target-1.f90: New test.
diff --git a/libgomp/testsuite/libgomp.c++/target-4.C b/libgomp/testsuite/libgomp.c++/target-4.C
new file mode 100644 (file)
index 0000000..9d1b576
--- /dev/null
@@ -0,0 +1,3 @@
+// { dg-do run }
+
+#include "../libgomp.c/target-10.c"
diff --git a/libgomp/testsuite/libgomp.c/target-10.c b/libgomp/testsuite/libgomp.c/target-10.c
new file mode 100644 (file)
index 0000000..bc66880
--- /dev/null
@@ -0,0 +1,14 @@
+/* { dg-do run } */
+
+#pragma omp declare target
+extern int v;
+#pragma omp end declare target
+
+int v;
+
+int
+main ()
+{
+  #pragma omp target update to(v)
+  return 0;
+}