From edbde9bd479c784c34aa62e41d64d67f21bd95d3 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 3 Jun 2015 17:29:35 +0200 Subject: [PATCH] backport: c-decl.c (c_decl_attributes): Also add "omp declare target" attribute for DECL_EXTERNAL VAR_DECLs. Backported from mainline 2015-03-19 Jakub Jelinek * 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 | 8 ++++++++ gcc/c/c-decl.c | 3 ++- gcc/cp/ChangeLog | 8 ++++++++ gcc/cp/decl2.c | 3 ++- libgomp/ChangeLog | 8 ++++++++ libgomp/testsuite/libgomp.c++/target-4.C | 3 +++ libgomp/testsuite/libgomp.c/target-10.c | 14 ++++++++++++++ 7 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 libgomp/testsuite/libgomp.c++/target-4.C create mode 100644 libgomp/testsuite/libgomp.c/target-10.c diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 0fc999caaee2..399899d7c858 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,11 @@ +2015-06-03 Jakub Jelinek + + Backported from mainline + 2015-03-19 Jakub Jelinek + + * c-decl.c (c_decl_attributes): Also add "omp declare target" + attribute for DECL_EXTERNAL VAR_DECLs. + 2015-02-27 Marek Polacek Backported from mainline diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index df88edb84702..0751a526d3f9 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -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 diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8232a3371a49..599471245e24 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2015-06-03 Jakub Jelinek + + Backported from mainline + 2015-03-19 Jakub Jelinek + + * decl2.c (cplus_decl_attributes): Also add "omp declare target" + attribute for DECL_EXTERNAL VAR_DECLs. + 2015-04-29 Thomas Schwinge Backport from trunk r222564: diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 808c94f27154..f37fea3aedb2 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -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 diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 1cd186c4c2bb..20f247f1d412 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,11 @@ +2015-06-03 Jakub Jelinek + + Backported from mainline + 2015-03-19 Jakub Jelinek + + * testsuite/libgomp.c/target-10.c: New test. + * testsuite/libgomp.c++/target-4.C: New test. + 2015-04-02 Sebastian Huber 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 index 000000000000..9d1b576f9779 --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/target-4.C @@ -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 index 000000000000..bc66880b6afc --- /dev/null +++ b/libgomp/testsuite/libgomp.c/target-10.c @@ -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; +} -- 2.47.2