@@ -5866,6 +5866,9 @@ extern unsigned HOST_WIDE_INT compute_bu
extern unsigned HOST_WIDE_INT highest_pow2_factor (const_tree);
extern tree build_personality_function (const char *);
+/* In omp-low.c. */
+extern tree find_omp_clause (tree, enum omp_clause_code);
+
/* In trans-mem.c. */
extern tree build_tm_abort_call (location_t, bool);
extern bool is_tm_safe (const_tree);
@@ -392,7 +392,6 @@ extern struct omp_region *new_omp_region
struct omp_region *);
extern void free_omp_regions (void);
void omp_expand_local (basic_block);
-extern tree find_omp_clause (tree, enum omp_clause_code);
tree copy_var_decl (tree, tree, tree);
/*---------------------------------------------------------------------------
@@ -10082,6 +10082,7 @@ c_parser_omp_for_loop (location_t loc,
stmt = c_finish_omp_for (loc, declv, initv, condv, incrv, body, NULL);
if (stmt)
{
+ add_stmt (stmt);
if (par_clauses != NULL)
{
tree *c;
@@ -576,7 +576,7 @@ c_finish_omp_for (location_t locus, tree
OMP_FOR_PRE_BODY (t) = pre_body;
SET_EXPR_LOCATION (t, locus);
- return add_stmt (t);
+ return t;
}
}
@@ -4384,7 +4384,7 @@ begin_omp_parallel (void)
tree
finish_omp_parallel (tree clauses, tree body)
{
- tree stmt;
+ tree stmt, ret;
body = finish_omp_structured_block (body);
@@ -4392,8 +4392,13 @@ finish_omp_parallel (tree clauses, tree
TREE_TYPE (stmt) = void_type_node;
OMP_PARALLEL_CLAUSES (stmt) = clauses;
OMP_PARALLEL_BODY (stmt) = body;
+ ret = stmt;
+ if (find_omp_clause (clauses, OMP_CLAUSE_IF)
+ || find_omp_clause (clauses, OMP_CLAUSE_NUM_THREADS))
+ stmt = maybe_cleanup_point_expr (stmt);
+ add_stmt (stmt);
- return add_stmt (stmt);
+ return ret;
}
tree
@@ -4406,7 +4411,7 @@ begin_omp_task (void)
tree
finish_omp_task (tree clauses, tree body)
{
- tree stmt;
+ tree stmt, ret;
body = finish_omp_structured_block (body);
@@ -4414,8 +4419,13 @@ finish_omp_task (tree clauses, tree body
TREE_TYPE (stmt) = void_type_node;
OMP_TASK_CLAUSES (stmt) = clauses;
OMP_TASK_BODY (stmt) = body;
+ ret = stmt;
+ if (find_omp_clause (clauses, OMP_CLAUSE_IF)
+ || find_omp_clause (clauses, OMP_CLAUSE_FINAL))
+ stmt = maybe_cleanup_point_expr (stmt);
+ add_stmt (stmt);
- return add_stmt (stmt);
+ return ret;
}
/* Helper function for finish_omp_for. Convert Ith random access iterator
@@ -4876,7 +4886,13 @@ finish_omp_for (location_t locus, tree d
TREE_VEC_ELT (OMP_FOR_INCR (omp_for), i) = TREE_VEC_ELT (orig_incr, i);
}
if (omp_for != NULL)
- OMP_FOR_CLAUSES (omp_for) = clauses;
+ {
+ tree stmt = omp_for;
+ OMP_FOR_CLAUSES (omp_for) = clauses;
+ if (find_omp_clause (clauses, OMP_CLAUSE_SCHEDULE))
+ stmt = maybe_cleanup_point_expr (stmt);
+ add_stmt (stmt);
+ }
return omp_for;
}
@@ -0,0 +1,32 @@
+// PR c++/51669
+// { dg-do compile }
+// { dg-options "-fopenmp" }
+
+template <typename T> const T & min (const T &, const T &);
+
+void
+f1 ()
+{
+#pragma omp parallel num_threads (min (4, 5))
+ ;
+}
+
+struct A { A (); ~A (); };
+int foo (const A &);
+
+void
+f2 ()
+{
+ int i;
+#pragma omp parallel if (foo (A ())) num_threads (foo (A ()))
+ ;
+#pragma omp task if (foo (A ())) final (foo (A ()))
+ ;
+#pragma omp for schedule (static, foo (A ()))
+ for (i = 0; i < 10; i++)
+ ;
+#pragma omp parallel for schedule (static, foo (A ())) \
+ if (foo (A ())) num_threads (foo (A ()))
+ for (i = 0; i < 10; i++)
+ ;
+}