aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimplify.c
diff options
context:
space:
mode:
authorJames Norris <jnorris@codesourcery.com>2016-02-02 19:17:37 +0000
committerJames Norris <jnorris@gcc.gnu.org>2016-02-02 19:17:37 +0000
commiteb07751679c5f2c0c823093a2c76e56613007651 (patch)
tree5c1b21dbfc6ecef6750b8b7f939ce5fdc942236e /gcc/gimplify.c
parent578fb2259b0f644142f9a795a3fc433cba5f2da6 (diff)
downloadgcc-eb07751679c5f2c0c823093a2c76e56613007651.zip
gcc-eb07751679c5f2c0c823093a2c76e56613007651.tar.gz
gcc-eb07751679c5f2c0c823093a2c76e56613007651.tar.bz2
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
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r--gcc/gimplify.c26
1 files changed, 25 insertions, 1 deletions
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 %<link%> clause used in %<routine%> function",
+ DECL_NAME (decl));
+ return false;
+ }
+ else if (!lookup_attribute ("omp declare target",
+ DECL_ATTRIBUTES (decl)))
+ {
+ error_at (loc,
+ "%qE requires a %<declare%> directive for use "
+ "in a %<routine%> function", DECL_NAME (decl));
+ return false;
+ }
+ }
}
n = splay_tree_lookup (ctx->variables, (splay_tree_key)decl);