From eb07751679c5f2c0c823093a2c76e56613007651 Mon Sep 17 00:00:00 2001 From: James Norris Date: Tue, 2 Feb 2016 19:17:37 +0000 Subject: gimplify.c (omp_notice_variable): Add usage check. gcc/ * gimplify.c (omp_notice_variable): Add usage check. gcc/testsuite/ * c-c++-common/goacc/routine-5.c: Add tests. From-SVN: r233089 --- gcc/gimplify.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'gcc/gimplify.c') diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 32bc1fd..b0ee27e 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -6087,9 +6087,9 @@ omp_notice_variable (struct gimplify_omp_ctx *ctx, tree decl, bool in_code) if (ctx->region_type == ORT_NONE) return lang_hooks.decls.omp_disregard_value_expr (decl, false); - /* Threadprivate variables are predetermined. */ if (is_global_var (decl)) { + /* Threadprivate variables are predetermined. */ if (DECL_THREAD_LOCAL_P (decl)) return omp_notice_threadprivate_variable (ctx, decl, NULL_TREE); @@ -6100,6 +6100,30 @@ omp_notice_variable (struct gimplify_omp_ctx *ctx, tree decl, bool in_code) if (value && DECL_P (value) && DECL_THREAD_LOCAL_P (value)) return omp_notice_threadprivate_variable (ctx, decl, value); } + + if (gimplify_omp_ctxp->outer_context == NULL + && VAR_P (decl) + && get_oacc_fn_attrib (current_function_decl)) + { + location_t loc = DECL_SOURCE_LOCATION (decl); + + if (lookup_attribute ("omp declare target link", + DECL_ATTRIBUTES (decl))) + { + error_at (loc, + "%qE with % clause used in % function", + DECL_NAME (decl)); + return false; + } + else if (!lookup_attribute ("omp declare target", + DECL_ATTRIBUTES (decl))) + { + error_at (loc, + "%qE requires a % directive for use " + "in a % function", DECL_NAME (decl)); + return false; + } + } } n = splay_tree_lookup (ctx->variables, (splay_tree_key)decl); -- cgit v1.1