]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: c-decl.c (c_decl_attributes): Also add "omp declare target" attribute for...
authorJakub Jelinek <jakub@redhat.com>
Wed, 3 Jun 2015 15:29:35 +0000 (17:29 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 3 Jun 2015 15:29:35 +0000 (17:29 +0200)
Backported from mainline
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.

* 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: r224088

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 0fc999caaee2b9002e3aa9b96867fc9b6f1c08dd..399899d7c8581ca7e1fa6156e18bc9c08cddcc5e 100644 (file)
@@ -1,3 +1,11 @@
+2015-06-03  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       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-02-27  Marek Polacek  <polacek@redhat.com>
 
        Backported from mainline
index df88edb84702b332668558cf20d431035a4322ad..0751a526d3f936300545e1000768a1eac13479ed 100644 (file)
@@ -4014,7 +4014,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 8232a3371a493999f763926c50d0816139569b93..599471245e2485caaac11da39212714a3a798412 100644 (file)
@@ -1,3 +1,11 @@
+2015-06-03  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       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-04-29  Thomas Schwinge  <thomas@codesourcery.com>
 
        Backport from trunk r222564:
index 808c94f271549751a25b88d7afd132c8fad92657..f37fea3aedb282d5b7bb8784f22f9052c3f512c9 100644 (file)
@@ -1396,7 +1396,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 1cd186c4c2bb92f25943e3ee27e229b090c617d1..20f247f1d412365bd1e53ec3280cb9b9436ccdc8 100644 (file)
@@ -1,3 +1,11 @@
+2015-06-03  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       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-04-02  Sebastian Huber  <sebastian.huber@embedded-brains.de>
 
        Backported from mainline
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;
+}