Hi, The attached patch fixes an issue where a declare'd variable, with the link clause, wasn't marked as offloadable.
Committed after regtesting on x86_64. Thanks! Jim
Index: libgomp/testsuite/libgomp.oacc-c-c++-common/declare-4.c =================================================================== --- libgomp/testsuite/libgomp.oacc-c-c++-common/declare-4.c (revision 227748) +++ libgomp/testsuite/libgomp.oacc-c-c++-common/declare-4.c (working copy) @@ -6,7 +6,16 @@ float b; #pragma acc declare link (b) +#pragma acc routine int +func (int a) +{ + b = a + 1; + + return b; +} + +int main (int argc, char **argv) { float a; @@ -23,5 +32,10 @@ main (int argc, char **argv) if (a != 3.0) abort (); + a = func (a); + + if (a != 4.0) + abort (); + return 0; } Index: gcc/varpool.c =================================================================== --- gcc/varpool.c (revision 227748) +++ gcc/varpool.c (working copy) @@ -173,24 +173,8 @@ make_offloadable (varpool_node *node, tree decl) attrs = lookup_attribute ("oacc declare", DECL_ATTRIBUTES (decl)); if (attrs) { - tree *t; - int total = 0, skip = 0; + make_offloadable_1 (node, decl); - gcc_assert (&TREE_VALUE (attrs)); - - for (t = &TREE_VALUE (attrs); *t; t = &TREE_CHAIN (*t)) - { - HOST_WIDE_INT kind = OMP_CLAUSE_MAP_KIND (TREE_VALUE (*t)); - - total++; - - if (kind == GOMP_MAP_LINK) - skip++; - } - - if (total - skip > 0) - make_offloadable_1 (node, decl); - DECL_ATTRIBUTES (decl) = remove_attribute ("oacc declare", DECL_ATTRIBUTES (decl)); }