aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimplify.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2021-10-30 08:58:08 +0200
committerJakub Jelinek <jakub@redhat.com>2021-10-30 08:58:08 +0200
commit6f449bb93b33d63fa8a1b8d021d8d36f27ffe054 (patch)
treef5a2300e60390e48f330670dc4f4f31b621cb007 /gcc/gimplify.c
parent4c61300f2b243756eb2e8c59997b4675aeb8f37a (diff)
downloadgcc-6f449bb93b33d63fa8a1b8d021d8d36f27ffe054.zip
gcc-6f449bb93b33d63fa8a1b8d021d8d36f27ffe054.tar.gz
gcc-6f449bb93b33d63fa8a1b8d021d8d36f27ffe054.tar.bz2
openmp: Diagnose threadprivate OpenMP loop iterators
We weren't diagnosing the The loop iteration variable may not appear in a threadprivate directive. restriction which used to be in 5.0 just among the Worksharing-Loop restrictions but in 5.1 it is among Canonical Loop Nest Form restrictions. This patch diagnoses those. 2021-10-30 Jakub Jelinek <jakub@redhat.com> * gimplify.c (gimplify_omp_for): Diagnose threadprivate iterators. * c-c++-common/gomp/loop-10.c: New test.
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r--gcc/gimplify.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index d8e4b13..8bb54fd 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -12298,6 +12298,24 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p)
gimplify_omp_ctxp->loop_iter_var.quick_push (decl);
}
+ if (for_stmt == orig_for_stmt)
+ {
+ tree orig_decl = decl;
+ if (OMP_FOR_ORIG_DECLS (for_stmt))
+ {
+ tree orig_decl = TREE_VEC_ELT (OMP_FOR_ORIG_DECLS (for_stmt), i);
+ if (TREE_CODE (orig_decl) == TREE_LIST)
+ {
+ orig_decl = TREE_PURPOSE (orig_decl);
+ if (!orig_decl)
+ orig_decl = decl;
+ }
+ }
+ if (is_global_var (orig_decl) && DECL_THREAD_LOCAL_P (orig_decl))
+ error_at (EXPR_LOCATION (for_stmt),
+ "threadprivate iteration variable %qD", orig_decl);
+ }
+
/* Make sure the iteration variable is private. */
tree c = NULL_TREE;
tree c2 = NULL_TREE;