===================================================================
@@ -1,3 +1,8 @@
+2016-01-07 James Norris <jnorris@codesourcery.com>
+
+ * c-parser.c (c_finish_oacc_routine): Add new attribute.
+ * c-typeck.c (build_external_ref): Add usage check.
+
2015-12-08 Thomas Schwinge <thomas@codesourcery.com>
* c-parser.c (c_parser_oacc_clause_bind, c_parser_oacc_routine)
===================================================================
@@ -14115,6 +14115,10 @@
/* Also add an "omp declare target" attribute, with clauses. */
DECL_ATTRIBUTES (fndecl) = tree_cons (get_identifier ("omp declare target"),
clauses, DECL_ATTRIBUTES (fndecl));
+
+ DECL_ATTRIBUTES (fndecl)
+ = tree_cons (get_identifier ("oacc routine"),
+ clauses, DECL_ATTRIBUTES (fndecl));
}
/* OpenACC 2.0:
===================================================================
@@ -2664,6 +2664,26 @@
tree ref;
tree decl = lookup_name (id);
+ if (decl
+ && decl != error_mark_node
+ && current_function_decl
+ && TREE_CODE (decl) == VAR_DECL
+ && is_global_var (decl)
+ && lookup_attribute ("oacc routine",
+ DECL_ATTRIBUTES (current_function_decl)))
+ {
+ if (lookup_attribute ("omp declare target link",
+ DECL_ATTRIBUTES (decl))
+ || ((!lookup_attribute ("omp declare target",
+ DECL_ATTRIBUTES (decl))
+ && ((TREE_STATIC (decl) && !DECL_EXTERNAL (decl))
+ || (!TREE_STATIC (decl) && DECL_EXTERNAL (decl))))))
+ {
+ error_at (loc, "invalid use in %<routine%> function");
+ return error_mark_node;
+ }
+ }
+
/* In Objective-C, an instance variable (ivar) may be preferred to
whatever lookup_name() found. */
decl = objc_lookup_ivar (decl, id);
===================================================================
@@ -1,3 +1,8 @@
+2016-01-07 James Norris <jnorris@codesourcery.com>
+
+ * parser.c (cp_finalize_oacc_routine): Add new attribute.
+ * semantics.c (finish_id_expression): Add usage check.
+
2016-01-07 Cesar Philippidis <cesar@codesourcery.com>
* cp-tree.h (bind_decls_match): Declare.
===================================================================
@@ -36732,6 +36732,10 @@
DECL_ATTRIBUTES (fndecl)
= tree_cons (get_identifier ("omp declare target"),
clauses, DECL_ATTRIBUTES (fndecl));
+
+ DECL_ATTRIBUTES (fndecl)
+ = tree_cons (get_identifier ("oacc routine"),
+ NULL_TREE, DECL_ATTRIBUTES (fndecl));
}
}
===================================================================
@@ -3700,6 +3700,25 @@
decl = convert_from_reference (decl);
}
+
+ if (decl != error_mark_node
+ && current_function_decl
+ && TREE_CODE (decl) == VAR_DECL
+ && is_global_var (decl)
+ && lookup_attribute ("oacc routine",
+ DECL_ATTRIBUTES (current_function_decl)))
+ {
+ if (lookup_attribute ("omp declare target link",
+ DECL_ATTRIBUTES (decl))
+ || ((!lookup_attribute ("omp declare target",
+ DECL_ATTRIBUTES (decl))
+ && ((TREE_STATIC (decl) && !DECL_EXTERNAL (decl))
+ || (!TREE_STATIC (decl) && DECL_EXTERNAL (decl))))))
+ {
+ *error_msg = "invalid use in %<routine%> function";
+ return error_mark_node;
+ }
+ }
}
return cp_expr (decl, location);
===================================================================
@@ -1,3 +1,7 @@
+2016-01-07 James Norris <jnorris@codesourcery.com>
+
+ * c-c++-common/goacc/routine-5.c: Additional tests.
+
2016-01-07 Cesar Philippidis <cesar@codesourcery.com>
* g++.dg/goacc/routine-2.C: Add more coverage.
===================================================================
@@ -59,3 +59,49 @@
#pragma acc routine (Foo) gang // { dg-error "must be applied before definition" }
#pragma acc routine (Baz) // { dg-error "not been declared" }
+
+float vb1;
+
+#pragma acc routine
+int
+func1 (int a)
+{
+ vb1 = a + 1; /* { dg-error "invalid use in" } */
+
+ return vb1; /* { dg-error "invalid use in" } */
+}
+
+#pragma acc routine
+int
+func2 (int a)
+{
+ static int vb2;
+
+ vb2 = a + 1; /* { dg-error "invalid use in" } */
+
+ return vb2; /* { dg-error "invalid use in" } */
+}
+
+float vb3;
+#pragma acc declare link (vb3)
+
+#pragma acc routine
+int
+func3 (int a)
+{
+ vb3 = a + 1; /* { dg-error "invalid use in" } */
+
+ return vb3; /* { dg-error "invalid use in" } */
+}
+
+float vb4;
+#pragma acc declare create (vb4)
+
+#pragma acc routine
+int
+func4 (int a)
+{
+ vb4 = a + 1;
+
+ return vb4;
+}
===================================================================
@@ -1,3 +1,7 @@
+2016-01-07 James Norris <jnorris@codesourcery.com>
+
+ * testsuite/libgomp.oacc-c-c++-common/declare-4.c: Fix test.
+
2016-01-06 Cesar Philippidis <cesar@codesourcery.com>
* testsuite/libgomp.oacc-fortran/pr68813.f90: New test.
===================================================================
@@ -4,7 +4,7 @@
#include <openacc.h>
float b;
-#pragma acc declare link (b)
+#pragma acc declare create (b)
#pragma acc routine
int