From: Cesar Philippidis Date: Mon, 2 May 2016 18:49:15 +0000 (-0700) Subject: c-common.h (enum c_omp_region_type): Define. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=778864283e64809939a20aa70ee50c3d80fe10cf;p=gcc.git c-common.h (enum c_omp_region_type): Define. gcc/c-family/ * c-common.h (enum c_omp_region_type): Define. gcc/c/ * c-parser.c (c_parser_oacc_all_clauses): Update call to c_finish_omp_clauses. (c_parser_omp_all_clauses): Likewise. (c_parser_oacc_cache): Likewise. (c_parser_oacc_loop): Likewise. (omp_split_clauses): Likewise. (c_parser_omp_declare_target): Likewise. (c_parser_cilk_all_clauses): Likewise. (c_parser_cilk_for): Likewise. * c-typeck.c (c_finish_omp_clauses): Replace bool arguments is_omp, declare_simd, and is_cilk with enum c_omp_region_type ort. gcc/cp/ * cp-tree.h (finish_omp_clauses): Update prototype. * parser.c (cp_parser_oacc_all_clauses): Update call to finish_omp_clauses. (cp_parser_omp_all_clauses): Likewise. (cp_parser_omp_for_loop): Likewise. (cp_omp_split_clauses): Likewise. (cp_parser_oacc_cache): Likewise. (cp_parser_oacc_loop): Likewise. (cp_parser_omp_declare_target): (cp_parser_cilk_simd_all_clauses): Likewise. (cp_parser_cilk_for): Likewise. * pt.c (tsubst_omp_clauses): Replace allow_fields and declare_simd arguments with enum c_omp_region_type ort. (tsubst_omp_clauses): Update calls to finish_omp_clauses. (tsubst_omp_attribute): Update calls to tsubst_omp_clauses. (tsubst_omp_for_iterator): Update calls to finish_omp_clauses. (tsubst_expr): Update calls to tsubst_omp_clauses. * semantics.c (finish_omp_clauses): Replace bool arguments allow_fields, declare_simd, and is_cilk with bitmask ort. (finish_omp_for): Update call to finish_omp_clauses. From-SVN: r235780 --- diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 49012e14307..0afedff4ec9 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,7 @@ +2016-05-02 Cesar Philippidis + + * c-common.h (enum c_omp_region_type): Define. + 2016-05-02 Richard Sandiford * c-common.c (shorten_compare): Use wi::to_wide. diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 99fa3ab2937..1714284bc2e 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -1261,6 +1261,15 @@ enum c_omp_clause_split C_OMP_CLAUSE_SPLIT_TASKLOOP = C_OMP_CLAUSE_SPLIT_FOR }; +enum c_omp_region_type +{ + C_ORT_OMP = 1 << 0, + C_ORT_CILK = 1 << 1, + C_ORT_ACC = 1 << 2, + C_ORT_DECLARE_SIMD = 1 << 3, + C_ORT_OMP_DECLARE_SIMD = C_ORT_OMP | C_ORT_DECLARE_SIMD, +}; + extern tree c_finish_omp_master (location_t, tree); extern tree c_finish_omp_taskgroup (location_t, tree); extern tree c_finish_omp_critical (location_t, tree, tree, tree); diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 793186bfb63..a90972e7e09 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,17 @@ +2016-05-02 Cesar Philippidis + + * c-parser.c (c_parser_oacc_all_clauses): Update call to + c_finish_omp_clauses. + (c_parser_omp_all_clauses): Likewise. + (c_parser_oacc_cache): Likewise. + (c_parser_oacc_loop): Likewise. + (omp_split_clauses): Likewise. + (c_parser_omp_declare_target): Likewise. + (c_parser_cilk_all_clauses): Likewise. + (c_parser_cilk_for): Likewise. + * c-typeck.c (c_finish_omp_clauses): Replace bool arguments + is_omp, declare_simd, and is_cilk with enum c_omp_region_type ort. + 2016-05-02 Marek Polacek PR c/70851 diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 832b8dda486..701ab45ff89 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -13183,7 +13183,7 @@ c_parser_oacc_all_clauses (c_parser *parser, omp_clause_mask mask, c_parser_skip_to_pragma_eol (parser); if (finish_p) - return c_finish_omp_clauses (clauses, false); + return c_finish_omp_clauses (clauses, C_ORT_ACC); return clauses; } @@ -13468,8 +13468,8 @@ c_parser_omp_all_clauses (c_parser *parser, omp_clause_mask mask, if (finish_p) { if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_UNIFORM)) != 0) - return c_finish_omp_clauses (clauses, true, true); - return c_finish_omp_clauses (clauses, true); + return c_finish_omp_clauses (clauses, C_ORT_OMP_DECLARE_SIMD); + return c_finish_omp_clauses (clauses, C_ORT_OMP); } return clauses; @@ -13503,7 +13503,7 @@ c_parser_oacc_cache (location_t loc, c_parser *parser) tree stmt, clauses; clauses = c_parser_omp_var_list_parens (parser, OMP_CLAUSE__CACHE_, NULL); - clauses = c_finish_omp_clauses (clauses, false); + clauses = c_finish_omp_clauses (clauses, C_ORT_ACC); c_parser_skip_to_pragma_eol (parser); @@ -13839,9 +13839,9 @@ c_parser_oacc_loop (location_t loc, c_parser *parser, char *p_name, { clauses = c_oacc_split_loop_clauses (clauses, cclauses, is_parallel); if (*cclauses) - *cclauses = c_finish_omp_clauses (*cclauses, false); + *cclauses = c_finish_omp_clauses (*cclauses, C_ORT_ACC); if (clauses) - clauses = c_finish_omp_clauses (clauses, false); + clauses = c_finish_omp_clauses (clauses, C_ORT_ACC); } tree block = c_begin_compound_stmt (true); @@ -15015,7 +15015,7 @@ omp_split_clauses (location_t loc, enum tree_code code, c_omp_split_clauses (loc, code, mask, clauses, cclauses); for (i = 0; i < C_OMP_CLAUSE_SPLIT_COUNT; i++) if (cclauses[i]) - cclauses[i] = c_finish_omp_clauses (cclauses[i], true); + cclauses[i] = c_finish_omp_clauses (cclauses[i], C_ORT_OMP); } /* OpenMP 4.0: @@ -16546,7 +16546,7 @@ c_parser_omp_declare_target (c_parser *parser) { clauses = c_parser_omp_var_list_parens (parser, OMP_CLAUSE_TO_DECLARE, clauses); - clauses = c_finish_omp_clauses (clauses, true); + clauses = c_finish_omp_clauses (clauses, C_ORT_OMP); c_parser_skip_to_pragma_eol (parser); } else @@ -17515,7 +17515,7 @@ c_parser_cilk_all_clauses (c_parser *parser) saw_error: c_parser_skip_to_pragma_eol (parser); - return c_finish_omp_clauses (clauses, false, false, true); + return c_finish_omp_clauses (clauses, C_ORT_CILK); } /* This function helps parse the grainsize pragma for a _Cilk_for statement. @@ -17597,7 +17597,7 @@ c_parser_cilk_for (c_parser *parser, tree grain, bool *if_p) tree clauses = build_omp_clause (EXPR_LOCATION (grain), OMP_CLAUSE_SCHEDULE); OMP_CLAUSE_SCHEDULE_KIND (clauses) = OMP_CLAUSE_SCHEDULE_CILKFOR; OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clauses) = grain; - clauses = c_finish_omp_clauses (clauses, false); + clauses = c_finish_omp_clauses (clauses, C_ORT_CILK); tree block = c_begin_compound_stmt (true); tree sb = push_stmt_list (); @@ -17663,7 +17663,7 @@ c_parser_cilk_for (c_parser *parser, tree grain, bool *if_p) OMP_CLAUSE_OPERAND (c, 0) = cilk_for_number_of_iterations (omp_for); OMP_CLAUSE_CHAIN (c) = clauses; - OMP_PARALLEL_CLAUSES (omp_par) = c_finish_omp_clauses (c, true); + OMP_PARALLEL_CLAUSES (omp_par) = c_finish_omp_clauses (c, C_ORT_CILK); add_stmt (omp_par); } diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h index 4633182eef9..07d0f656094 100644 --- a/gcc/c/c-tree.h +++ b/gcc/c/c-tree.h @@ -661,7 +661,7 @@ extern tree c_begin_omp_task (void); extern tree c_finish_omp_task (location_t, tree, tree); extern void c_finish_omp_cancel (location_t, tree); extern void c_finish_omp_cancellation_point (location_t, tree); -extern tree c_finish_omp_clauses (tree, bool, bool = false, bool = false); +extern tree c_finish_omp_clauses (tree, enum c_omp_region_type); extern tree c_build_va_arg (location_t, tree, location_t, tree); extern tree c_finish_transaction (location_t, tree, int); extern bool c_tree_equal (tree, tree); diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 58c21393e47..0fa96539b95 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -12496,8 +12496,7 @@ c_find_omp_placeholder_r (tree *tp, int *, void *data) Remove any elements from the list that are invalid. */ tree -c_finish_omp_clauses (tree clauses, bool is_omp, bool declare_simd, - bool is_cilk) +c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) { bitmap_head generic_head, firstprivate_head, lastprivate_head; bitmap_head aligned_head, map_head, map_field_head; @@ -12540,7 +12539,7 @@ c_finish_omp_clauses (tree clauses, bool is_omp, bool declare_simd, t = OMP_CLAUSE_DECL (c); if (TREE_CODE (t) == TREE_LIST) { - if (handle_omp_array_sections (c, is_omp)) + if (handle_omp_array_sections (c, ort & C_ORT_OMP)) { remove = true; break; @@ -12768,10 +12767,10 @@ c_finish_omp_clauses (tree clauses, bool is_omp, bool declare_simd, goto check_dup_generic; case OMP_CLAUSE_LINEAR: - if (!declare_simd) + if (ort != C_ORT_OMP_DECLARE_SIMD) need_implicitly_determined = true; t = OMP_CLAUSE_DECL (c); - if (!declare_simd + if (ort != C_ORT_OMP_DECLARE_SIMD && OMP_CLAUSE_LINEAR_KIND (c) != OMP_CLAUSE_LINEAR_DEFAULT) { error_at (OMP_CLAUSE_LOCATION (c), @@ -12779,7 +12778,7 @@ c_finish_omp_clauses (tree clauses, bool is_omp, bool declare_simd, "clause on % or % constructs"); OMP_CLAUSE_LINEAR_KIND (c) = OMP_CLAUSE_LINEAR_DEFAULT; } - if (is_cilk) + if (ort & C_ORT_CILK) { if (!INTEGRAL_TYPE_P (TREE_TYPE (t)) && !SCALAR_FLOAT_TYPE_P (TREE_TYPE (t)) @@ -12805,7 +12804,7 @@ c_finish_omp_clauses (tree clauses, bool is_omp, bool declare_simd, break; } } - if (declare_simd) + if (ort == C_ORT_OMP_DECLARE_SIMD) { tree s = OMP_CLAUSE_LINEAR_STEP (c); if (TREE_CODE (s) == PARM_DECL) @@ -12984,7 +12983,7 @@ c_finish_omp_clauses (tree clauses, bool is_omp, bool declare_simd, } if (TREE_CODE (t) == TREE_LIST) { - if (handle_omp_array_sections (c, is_omp)) + if (handle_omp_array_sections (c, ort & C_ORT_OMP)) remove = true; break; } @@ -13007,7 +13006,7 @@ c_finish_omp_clauses (tree clauses, bool is_omp, bool declare_simd, t = OMP_CLAUSE_DECL (c); if (TREE_CODE (t) == TREE_LIST) { - if (handle_omp_array_sections (c, is_omp)) + if (handle_omp_array_sections (c, ort & C_ORT_OMP)) remove = true; else { @@ -13054,7 +13053,7 @@ c_finish_omp_clauses (tree clauses, bool is_omp, bool declare_simd, break; } if (TREE_CODE (t) == COMPONENT_REF - && is_omp + && (ort & C_ORT_OMP) && OMP_CLAUSE_CODE (c) != OMP_CLAUSE__CACHE_) { if (DECL_BIT_FIELD (TREE_OPERAND (t, 1))) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 18292e2a792..30dddeb765c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,26 @@ +2016-05-02 Cesar Philippidis + + * cp-tree.h (finish_omp_clauses): Update prototype. + * parser.c (cp_parser_oacc_all_clauses): Update call to + finish_omp_clauses. + (cp_parser_omp_all_clauses): Likewise. + (cp_parser_omp_for_loop): Likewise. + (cp_omp_split_clauses): Likewise. + (cp_parser_oacc_cache): Likewise. + (cp_parser_oacc_loop): Likewise. + (cp_parser_omp_declare_target): + (cp_parser_cilk_simd_all_clauses): Likewise. + (cp_parser_cilk_for): Likewise. + * pt.c (tsubst_omp_clauses): Replace allow_fields and declare_simd + arguments with enum c_omp_region_type ort. + (tsubst_omp_clauses): Update calls to finish_omp_clauses. + (tsubst_omp_attribute): Update calls to tsubst_omp_clauses. + (tsubst_omp_for_iterator): Update calls to finish_omp_clauses. + (tsubst_expr): Update calls to tsubst_omp_clauses. + * semantics.c (finish_omp_clauses): Replace bool arguments + allow_fields, declare_simd, and is_cilk with bitmask ort. + (finish_omp_for): Update call to finish_omp_clauses. + 2016-05-02 David Malcolm PR c++/62314 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 8a06609dc04..6665355b192 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -6399,8 +6399,7 @@ extern tree omp_reduction_id (enum tree_code, tree, tree); extern tree cp_remove_omp_priv_cleanup_stmt (tree *, int *, void *); extern void cp_check_omp_declare_reduction (tree); extern void finish_omp_declare_simd_methods (tree); -extern tree finish_omp_clauses (tree, bool, bool = false, - bool = false); +extern tree finish_omp_clauses (tree, enum c_omp_region_type); extern tree push_omp_privatization_clauses (bool); extern void pop_omp_privatization_clauses (tree); extern void save_omp_privatization_clauses (vec &); diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 667ed97cbec..c4941a05996 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -32275,7 +32275,7 @@ cp_parser_oacc_all_clauses (cp_parser *parser, omp_clause_mask mask, cp_parser_skip_to_pragma_eol (parser, pragma_tok); if (finish_p) - return finish_omp_clauses (clauses, false); + return finish_omp_clauses (clauses, C_ORT_ACC); return clauses; } @@ -32594,9 +32594,9 @@ cp_parser_omp_all_clauses (cp_parser *parser, omp_clause_mask mask, if (finish_p) { if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_UNIFORM)) != 0) - return finish_omp_clauses (clauses, false, true); + return finish_omp_clauses (clauses, C_ORT_OMP_DECLARE_SIMD); else - return finish_omp_clauses (clauses, true); + return finish_omp_clauses (clauses, C_ORT_OMP); } return clauses; } @@ -33671,7 +33671,7 @@ cp_parser_omp_for_loop (cp_parser *parser, enum tree_code code, tree clauses, else c = build_omp_clause (loc, OMP_CLAUSE_LASTPRIVATE); OMP_CLAUSE_DECL (c) = add_private_clause; - c = finish_omp_clauses (c, true); + c = finish_omp_clauses (c, C_ORT_OMP); if (c) { OMP_CLAUSE_CHAIN (c) = clauses; @@ -33823,7 +33823,7 @@ cp_omp_split_clauses (location_t loc, enum tree_code code, c_omp_split_clauses (loc, code, mask, clauses, cclauses); for (i = 0; i < C_OMP_CLAUSE_SPLIT_COUNT; i++) if (cclauses[i]) - cclauses[i] = finish_omp_clauses (cclauses[i], true); + cclauses[i] = finish_omp_clauses (cclauses[i], C_ORT_OMP); } /* OpenMP 4.0: @@ -35106,7 +35106,7 @@ cp_parser_oacc_cache (cp_parser *parser, cp_token *pragma_tok) tree stmt, clauses; clauses = cp_parser_omp_var_list (parser, OMP_CLAUSE__CACHE_, NULL_TREE); - clauses = finish_omp_clauses (clauses, false); + clauses = finish_omp_clauses (clauses, C_ORT_ACC); cp_parser_require_pragma_eol (parser, cp_lexer_peek_token (parser->lexer)); @@ -35433,9 +35433,9 @@ cp_parser_oacc_loop (cp_parser *parser, cp_token *pragma_tok, char *p_name, { clauses = c_oacc_split_loop_clauses (clauses, cclauses, is_parallel); if (*cclauses) - *cclauses = finish_omp_clauses (*cclauses, false); + *cclauses = finish_omp_clauses (*cclauses, C_ORT_ACC); if (clauses) - clauses = finish_omp_clauses (clauses, false); + clauses = finish_omp_clauses (clauses, C_ORT_ACC); } tree block = begin_omp_structured_block (); @@ -35800,7 +35800,7 @@ cp_parser_omp_declare_target (cp_parser *parser, cp_token *pragma_tok) { clauses = cp_parser_omp_var_list (parser, OMP_CLAUSE_TO_DECLARE, clauses); - clauses = finish_omp_clauses (clauses, true); + clauses = finish_omp_clauses (clauses, C_ORT_OMP); cp_parser_require_pragma_eol (parser, pragma_tok); } else @@ -37740,7 +37740,7 @@ cp_parser_cilk_simd_all_clauses (cp_parser *parser, cp_token *pragma_token) if (clauses == error_mark_node) return error_mark_node; else - return finish_omp_clauses (clauses, false, false, true); + return finish_omp_clauses (clauses, C_ORT_CILK); } /* Main entry-point for parsing Cilk Plus <#pragma simd> for loops. */ @@ -37785,7 +37785,7 @@ cp_parser_cilk_for (cp_parser *parser, tree grain, bool *if_p) tree clauses = build_omp_clause (EXPR_LOCATION (grain), OMP_CLAUSE_SCHEDULE); OMP_CLAUSE_SCHEDULE_KIND (clauses) = OMP_CLAUSE_SCHEDULE_CILKFOR; OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clauses) = grain; - clauses = finish_omp_clauses (clauses, false); + clauses = finish_omp_clauses (clauses, C_ORT_CILK); tree ret = cp_parser_omp_for_loop (parser, CILK_FOR, clauses, NULL, if_p); if (ret) diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 2d033e3771a..1289d64f071 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -9563,7 +9563,8 @@ can_complete_type_without_circularity (tree type) return 1; } -static tree tsubst_omp_clauses (tree, bool, bool, tree, tsubst_flags_t, tree); +static tree tsubst_omp_clauses (tree, enum c_omp_region_type, tree, + tsubst_flags_t, tree); /* Instantiate a single dependent attribute T (a TREE_LIST), and return either T or a new TREE_LIST, possibly a chain in the case of a pack expansion. */ @@ -9582,10 +9583,10 @@ tsubst_attribute (tree t, tree *decl_p, tree args, get_attribute_name (t))) { tree clauses = TREE_VALUE (val); - clauses = tsubst_omp_clauses (clauses, true, false, args, + clauses = tsubst_omp_clauses (clauses, C_ORT_OMP_DECLARE_SIMD, args, complain, in_decl); c_omp_declare_simd_clauses_to_decls (*decl_p, clauses); - clauses = finish_omp_clauses (clauses, false, true); + clauses = finish_omp_clauses (clauses, C_ORT_OMP_DECLARE_SIMD); tree parms = DECL_ARGUMENTS (*decl_p); clauses = c_omp_declare_simd_clauses_to_numbers (parms, clauses); @@ -14535,7 +14536,7 @@ tsubst_omp_clause_decl (tree decl, tree args, tsubst_flags_t complain, /* Like tsubst_copy, but specifically for OpenMP clauses. */ static tree -tsubst_omp_clauses (tree clauses, bool declare_simd, bool allow_fields, +tsubst_omp_clauses (tree clauses, enum c_omp_region_type ort, tree args, tsubst_flags_t complain, tree in_decl) { tree new_clauses = NULL_TREE, nc, oc; @@ -14685,7 +14686,7 @@ tsubst_omp_clauses (tree clauses, bool declare_simd, bool allow_fields, default: gcc_unreachable (); } - if (allow_fields) + if ((ort & C_ORT_OMP_DECLARE_SIMD) == C_ORT_OMP) switch (OMP_CLAUSE_CODE (nc)) { case OMP_CLAUSE_SHARED: @@ -14747,9 +14748,9 @@ tsubst_omp_clauses (tree clauses, bool declare_simd, bool allow_fields, } new_clauses = nreverse (new_clauses); - if (!declare_simd) + if (ort != C_ORT_OMP_DECLARE_SIMD) { - new_clauses = finish_omp_clauses (new_clauses, allow_fields); + new_clauses = finish_omp_clauses (new_clauses, ort); if (linear_no_step) for (nc = new_clauses; nc; nc = OMP_CLAUSE_CHAIN (nc)) if (nc == linear_no_step) @@ -14970,7 +14971,7 @@ tsubst_omp_for_iterator (tree t, int i, tree declv, tree orig_declv, { tree c = build_omp_clause (input_location, OMP_CLAUSE_PRIVATE); OMP_CLAUSE_DECL (c) = decl; - c = finish_omp_clauses (c, true); + c = finish_omp_clauses (c, C_ORT_OMP); if (c) { OMP_CLAUSE_CHAIN (c) = *clauses; @@ -15452,7 +15453,7 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, case OACC_KERNELS: case OACC_PARALLEL: - tmp = tsubst_omp_clauses (OMP_CLAUSES (t), false, false, args, complain, + tmp = tsubst_omp_clauses (OMP_CLAUSES (t), C_ORT_ACC, args, complain, in_decl); stmt = begin_omp_parallel (); RECUR (OMP_BODY (t)); @@ -15461,8 +15462,8 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, case OMP_PARALLEL: r = push_omp_privatization_clauses (OMP_PARALLEL_COMBINED (t)); - tmp = tsubst_omp_clauses (OMP_PARALLEL_CLAUSES (t), false, true, - args, complain, in_decl); + tmp = tsubst_omp_clauses (OMP_PARALLEL_CLAUSES (t), C_ORT_OMP, args, + complain, in_decl); if (OMP_PARALLEL_COMBINED (t)) omp_parallel_combined_clauses = &tmp; stmt = begin_omp_parallel (); @@ -15475,8 +15476,8 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, case OMP_TASK: r = push_omp_privatization_clauses (false); - tmp = tsubst_omp_clauses (OMP_TASK_CLAUSES (t), false, true, - args, complain, in_decl); + tmp = tsubst_omp_clauses (OMP_TASK_CLAUSES (t), C_ORT_OMP, args, + complain, in_decl); stmt = begin_omp_task (); RECUR (OMP_TASK_BODY (t)); finish_omp_task (tmp, stmt); @@ -15495,12 +15496,17 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, tree declv = NULL_TREE, initv = NULL_TREE, condv = NULL_TREE; tree orig_declv = NULL_TREE; tree incrv = NULL_TREE; + enum c_omp_region_type ort = C_ORT_OMP; int i; + if (TREE_CODE (t) == CILK_SIMD || TREE_CODE (t) == CILK_FOR) + ort = C_ORT_CILK; + else if (TREE_CODE (t) == OACC_LOOP) + ort = C_ORT_ACC; + r = push_omp_privatization_clauses (OMP_FOR_INIT (t) == NULL_TREE); - clauses = tsubst_omp_clauses (OMP_FOR_CLAUSES (t), false, - TREE_CODE (t) != OACC_LOOP, - args, complain, in_decl); + clauses = tsubst_omp_clauses (OMP_FOR_CLAUSES (t), ort, args, complain, + in_decl); if (OMP_FOR_INIT (t) != NULL_TREE) { declv = make_tree_vec (TREE_VEC_LENGTH (OMP_FOR_INIT (t))); @@ -15556,8 +15562,8 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, case OMP_CRITICAL: r = push_omp_privatization_clauses (TREE_CODE (t) == OMP_TEAMS && OMP_TEAMS_COMBINED (t)); - tmp = tsubst_omp_clauses (OMP_CLAUSES (t), false, true, - args, complain, in_decl); + tmp = tsubst_omp_clauses (OMP_CLAUSES (t), C_ORT_OMP, args, complain, + in_decl); stmt = push_stmt_list (); RECUR (OMP_BODY (t)); stmt = pop_stmt_list (stmt); @@ -15572,9 +15578,9 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, case OACC_DATA: case OMP_TARGET_DATA: case OMP_TARGET: - tmp = tsubst_omp_clauses (OMP_CLAUSES (t), false, - TREE_CODE (t) != OACC_DATA, - args, complain, in_decl); + tmp = tsubst_omp_clauses (OMP_CLAUSES (t), (TREE_CODE (t) == OACC_DATA) + ? C_ORT_ACC : C_ORT_OMP, args, complain, + in_decl); keep_next_level (true); stmt = begin_omp_structured_block (); @@ -15619,8 +15625,8 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, case OACC_DECLARE: t = copy_node (t); - tmp = tsubst_omp_clauses (OACC_DECLARE_CLAUSES (t), false, false, - args, complain, in_decl); + tmp = tsubst_omp_clauses (OACC_DECLARE_CLAUSES (t), C_ORT_ACC, args, + complain, in_decl); OACC_DECLARE_CLAUSES (t) = tmp; add_stmt (t); break; @@ -15628,8 +15634,8 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, case OMP_TARGET_UPDATE: case OMP_TARGET_ENTER_DATA: case OMP_TARGET_EXIT_DATA: - tmp = tsubst_omp_clauses (OMP_STANDALONE_CLAUSES (t), false, true, - args, complain, in_decl); + tmp = tsubst_omp_clauses (OMP_STANDALONE_CLAUSES (t), C_ORT_OMP, args, + complain, in_decl); t = copy_node (t); OMP_STANDALONE_CLAUSES (t) = tmp; add_stmt (t); @@ -15638,16 +15644,16 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, case OACC_ENTER_DATA: case OACC_EXIT_DATA: case OACC_UPDATE: - tmp = tsubst_omp_clauses (OMP_STANDALONE_CLAUSES (t), false, false, - args, complain, in_decl); + tmp = tsubst_omp_clauses (OMP_STANDALONE_CLAUSES (t), C_ORT_ACC, args, + complain, in_decl); t = copy_node (t); OMP_STANDALONE_CLAUSES (t) = tmp; add_stmt (t); break; case OMP_ORDERED: - tmp = tsubst_omp_clauses (OMP_ORDERED_CLAUSES (t), false, true, - args, complain, in_decl); + tmp = tsubst_omp_clauses (OMP_ORDERED_CLAUSES (t), C_ORT_OMP, args, + complain, in_decl); stmt = push_stmt_list (); RECUR (OMP_BODY (t)); stmt = pop_stmt_list (stmt); diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 2365a732cbe..fed7e88e8db 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -5793,8 +5793,7 @@ cp_finish_omp_clause_depend_sink (tree sink_clause) Remove any elements from the list that are invalid. */ tree -finish_omp_clauses (tree clauses, bool allow_fields, bool declare_simd, - bool is_cilk) +finish_omp_clauses (tree clauses, enum c_omp_region_type ort) { bitmap_head generic_head, firstprivate_head, lastprivate_head; bitmap_head aligned_head, map_head, map_field_head; @@ -5820,17 +5819,18 @@ finish_omp_clauses (tree clauses, bool allow_fields, bool declare_simd, switch (OMP_CLAUSE_CODE (c)) { case OMP_CLAUSE_SHARED: - field_ok = allow_fields; + field_ok = ((ort & C_ORT_OMP_DECLARE_SIMD) == C_ORT_OMP); goto check_dup_generic; case OMP_CLAUSE_PRIVATE: - field_ok = allow_fields; + field_ok = ((ort & C_ORT_OMP_DECLARE_SIMD) == C_ORT_OMP); goto check_dup_generic; case OMP_CLAUSE_REDUCTION: - field_ok = allow_fields; + field_ok = ((ort & C_ORT_OMP_DECLARE_SIMD) == C_ORT_OMP); t = OMP_CLAUSE_DECL (c); if (TREE_CODE (t) == TREE_LIST) { - if (handle_omp_array_sections (c, allow_fields)) + if (handle_omp_array_sections (c, ((ort & C_ORT_OMP_DECLARE_SIMD) + == C_ORT_OMP))) { remove = true; break; @@ -5858,14 +5858,14 @@ finish_omp_clauses (tree clauses, bool allow_fields, bool declare_simd, goto check_dup_generic; case OMP_CLAUSE_COPYPRIVATE: copyprivate_seen = true; - field_ok = allow_fields; + field_ok = ((ort & C_ORT_OMP_DECLARE_SIMD) == C_ORT_OMP); goto check_dup_generic; case OMP_CLAUSE_COPYIN: goto check_dup_generic; case OMP_CLAUSE_LINEAR: - field_ok = allow_fields; + field_ok = ((ort & C_ORT_OMP_DECLARE_SIMD) == C_ORT_OMP); t = OMP_CLAUSE_DECL (c); - if (!declare_simd + if (ort != C_ORT_OMP_DECLARE_SIMD && OMP_CLAUSE_LINEAR_KIND (c) != OMP_CLAUSE_LINEAR_DEFAULT) { error_at (OMP_CLAUSE_LOCATION (c), @@ -5890,7 +5890,7 @@ finish_omp_clauses (tree clauses, bool allow_fields, bool declare_simd, } if (TREE_CODE (type) == REFERENCE_TYPE) type = TREE_TYPE (type); - if (is_cilk) + if (ort == C_ORT_CILK) { if (!INTEGRAL_TYPE_P (type) && !SCALAR_FLOAT_TYPE_P (type) @@ -5925,7 +5925,7 @@ finish_omp_clauses (tree clauses, bool allow_fields, bool declare_simd, } else if (!type_dependent_expression_p (t) && !INTEGRAL_TYPE_P (TREE_TYPE (t)) - && (!declare_simd + && (ort != C_ORT_OMP_DECLARE_SIMD || TREE_CODE (t) != PARM_DECL || TREE_CODE (TREE_TYPE (t)) != REFERENCE_TYPE || !INTEGRAL_TYPE_P (TREE_TYPE (TREE_TYPE (t))))) @@ -5937,7 +5937,7 @@ finish_omp_clauses (tree clauses, bool allow_fields, bool declare_simd, else { t = mark_rvalue_use (t); - if (declare_simd && TREE_CODE (t) == PARM_DECL) + if (ort == C_ORT_OMP_DECLARE_SIMD && TREE_CODE (t) == PARM_DECL) { OMP_CLAUSE_LINEAR_VARIABLE_STRIDE (c) = 1; goto check_dup_generic; @@ -5946,7 +5946,7 @@ finish_omp_clauses (tree clauses, bool allow_fields, bool declare_simd, && (VAR_P (OMP_CLAUSE_DECL (c)) || TREE_CODE (OMP_CLAUSE_DECL (c)) == PARM_DECL)) { - if (declare_simd) + if (ort == C_ORT_OMP_DECLARE_SIMD) { t = maybe_constant_value (t); if (TREE_CODE (t) != INTEGER_CST) @@ -5981,7 +5981,7 @@ finish_omp_clauses (tree clauses, bool allow_fields, bool declare_simd, else if (TREE_CODE (type) == POINTER_TYPE /* Can't multiply the step yet if *this is still incomplete type. */ - && (!declare_simd + && (ort != C_ORT_OMP_DECLARE_SIMD || TREE_CODE (OMP_CLAUSE_DECL (c)) != PARM_DECL || !DECL_ARTIFICIAL (OMP_CLAUSE_DECL (c)) || DECL_NAME (OMP_CLAUSE_DECL (c)) @@ -6018,7 +6018,7 @@ finish_omp_clauses (tree clauses, bool allow_fields, bool declare_simd, t = OMP_CLAUSE_DECL (c); check_dup_generic_t: if (t == current_class_ptr - && (!declare_simd + && (ort != C_ORT_OMP_DECLARE_SIMD || (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_LINEAR && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_UNIFORM))) { @@ -6084,7 +6084,8 @@ finish_omp_clauses (tree clauses, bool allow_fields, bool declare_simd, break; } if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL - && (!allow_fields || TREE_CODE (t) != FIELD_DECL)) + && ((ort & C_ORT_OMP_DECLARE_SIMD) != C_ORT_OMP + || TREE_CODE (t) != FIELD_DECL)) { if (processing_template_decl) break; @@ -6123,7 +6124,8 @@ finish_omp_clauses (tree clauses, bool allow_fields, bool declare_simd, break; } if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL - && (!allow_fields || TREE_CODE (t) != FIELD_DECL)) + && ((ort & C_ORT_OMP_DECLARE_SIMD) != C_ORT_OMP + || TREE_CODE (t) != FIELD_DECL)) { if (processing_template_decl) break; @@ -6466,7 +6468,7 @@ finish_omp_clauses (tree clauses, bool allow_fields, bool declare_simd, case OMP_CLAUSE_ALIGNED: t = OMP_CLAUSE_DECL (c); - if (t == current_class_ptr && !declare_simd) + if (t == current_class_ptr && ort != C_ORT_OMP_DECLARE_SIMD) { error ("% allowed in OpenMP only in %" " clauses"); @@ -6549,7 +6551,8 @@ finish_omp_clauses (tree clauses, bool allow_fields, bool declare_simd, } if (TREE_CODE (t) == TREE_LIST) { - if (handle_omp_array_sections (c, allow_fields)) + if (handle_omp_array_sections (c, ((ort & C_ORT_OMP_DECLARE_SIMD) + == C_ORT_OMP))) remove = true; break; } @@ -6583,7 +6586,8 @@ finish_omp_clauses (tree clauses, bool allow_fields, bool declare_simd, t = OMP_CLAUSE_DECL (c); if (TREE_CODE (t) == TREE_LIST) { - if (handle_omp_array_sections (c, allow_fields)) + if (handle_omp_array_sections (c, ((ort & C_ORT_OMP_DECLARE_SIMD) + == C_ORT_OMP))) remove = true; else { @@ -6638,7 +6642,7 @@ finish_omp_clauses (tree clauses, bool allow_fields, bool declare_simd, OMP_CLAUSE_DECL (c) = t; } if (TREE_CODE (t) == COMPONENT_REF - && allow_fields + && (ort & C_ORT_OMP_DECLARE_SIMD) == C_ORT_OMP && OMP_CLAUSE_CODE (c) != OMP_CLAUSE__CACHE_) { if (type_dependent_expression_p (t)) @@ -6778,7 +6782,7 @@ finish_omp_clauses (tree clauses, bool allow_fields, bool declare_simd, handle_map_references: if (!remove && !processing_template_decl - && allow_fields + && (ort & C_ORT_OMP_DECLARE_SIMD) == C_ORT_OMP && TREE_CODE (TREE_TYPE (OMP_CLAUSE_DECL (c))) == REFERENCE_TYPE) { t = OMP_CLAUSE_DECL (c); @@ -6972,7 +6976,7 @@ finish_omp_clauses (tree clauses, bool allow_fields, bool declare_simd, case OMP_CLAUSE_IS_DEVICE_PTR: case OMP_CLAUSE_USE_DEVICE_PTR: - field_ok = allow_fields; + field_ok = (ort & C_ORT_OMP_DECLARE_SIMD) == C_ORT_OMP; t = OMP_CLAUSE_DECL (c); if (!type_dependent_expression_p (t)) { @@ -7112,7 +7116,7 @@ finish_omp_clauses (tree clauses, bool allow_fields, bool declare_simd, need_implicitly_determined = true; break; case OMP_CLAUSE_LINEAR: - if (!declare_simd) + if (ort != C_ORT_OMP_DECLARE_SIMD) need_implicitly_determined = true; else if (OMP_CLAUSE_LINEAR_VARIABLE_STRIDE (c) && !bitmap_bit_p (&map_head, @@ -8342,7 +8346,7 @@ finish_omp_for (location_t locus, enum tree_code code, tree declv, OMP_CLAUSE_OPERAND (c, 0) = cilk_for_number_of_iterations (omp_for); OMP_CLAUSE_CHAIN (c) = clauses; - OMP_PARALLEL_CLAUSES (omp_par) = finish_omp_clauses (c, false); + OMP_PARALLEL_CLAUSES (omp_par) = finish_omp_clauses (c, C_ORT_CILK); add_stmt (omp_par); return omp_par; }