aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2018-11-08 18:13:04 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2018-11-08 18:13:04 +0100
commit28567c40e2c7c88e424283e8a1a6ff8cb7ba440c (patch)
treed35b0640fcabbdcf16b6254688aa76a6fbc4f4a7 /gcc/cp
parentdfe2a550e8879f9af11e8e2c7c4eb10ea626a7e6 (diff)
downloadgcc-28567c40e2c7c88e424283e8a1a6ff8cb7ba440c.zip
gcc-28567c40e2c7c88e424283e8a1a6ff8cb7ba440c.tar.gz
gcc-28567c40e2c7c88e424283e8a1a6ff8cb7ba440c.tar.bz2
builtin-types.def (BT_FN_VOID_BOOL, [...]): New.
* builtin-types.def (BT_FN_VOID_BOOL, BT_FN_VOID_SIZE_SIZE_PTR, BT_FN_UINT_UINT_PTR_PTR, BT_FN_UINT_OMPFN_PTR_UINT_UINT, BT_FN_BOOL_UINT_LONGPTR_LONG_LONG_LONGPTR_LONGPTR_PTR_PTR, BT_FN_BOOL_UINT_ULLPTR_LONG_ULL_ULLPTR_ULLPTR_PTR_PTR, BT_FN_BOOL_LONG_LONG_LONG_LONG_LONG_LONGPTR_LONGPTR_PTR_PTR, BT_FN_BOOL_BOOL_ULL_ULL_ULL_LONG_ULL_ULLPTR_ULLPTR_PTR_PTR): New. * gengtype.c (open_base_files): Add omp-general.h. * gimple.c (gimple_build_omp_critical): (gimple_build_omp_taskgroup): Add CLAUSES argument. Call gimple_omp_taskgroup_set_clauses. (gimple_build_omp_atomic_load): Add mo argument, call gimple_omp_atomic_set_memory_order. (gimple_build_omp_atomic_store): Likewise. (gimple_copy): Adjust handling of GIMPLE_OMP_TASKGROUP. * gimple.def (GIMPLE_OMP_TASKGROUP): Use GSS_OMP_SINGLE_LAYOUT instead of GSS_OMP. (GIMPLE_OMP_TEAMS): Use GSS_OMP_PARALLEL_LAYOUT instead of GSS_OMP_SINGLE_LAYOUT, adjust comments. * gimple.h (enum gf_mask): Add GF_OMP_TEAMS_HOST, GF_OMP_TASK_TASKWAIT and GF_OMP_ATOMIC_MEMORY_ORDER. Remove GF_OMP_ATOMIC_SEQ_CST, use different value for GF_OMP_ATOMIC_NEED_VALUE. (struct gimple_statement_omp_taskreg): Add GIMPLE_OMP_TEAMS to comments. (struct gimple_statement_omp_single_layout): And remove here. (struct gomp_teams): Inherit from gimple_statement_omp_taskreg rather than gimple_statement_omp_single_layout. (is_a_helper <gimple_statement_omp_taskreg *>::test): Allow GIMPLE_OMP_TEAMS. (is_a_helper <const gimple_statement_omp_taskreg *>::test): Likewise. (gimple_omp_subcode): Formatting fix. (gimple_omp_teams_child_fn, gimple_omp_teams_child_fn_ptr, gimple_omp_teams_set_child_fn, gimple_omp_teams_data_arg, gimple_omp_teams_data_arg_ptr, gimple_omp_teams_set_data_arg, gimple_omp_teams_host, gimple_omp_teams_set_host, gimple_omp_task_taskwait_p, gimple_omp_task_set_taskwait_p, gimple_omp_taskgroup_clauses, gimple_omp_taskgroup_clauses_ptr, gimple_omp_taskgroup_set_clauses): New inline functions. (gimple_build_omp_atomic_load): Add enum omp_memory_order argument. (gimple_build_omp_atomic_store): Likewise. (gimple_omp_atomic_seq_cst_p): Remove. (gimple_omp_atomic_memory_order): New function. (gimple_omp_atomic_set_seq_cst): Remove. (gimple_omp_atomic_set_memory_order): New function. (gimple_build_omp_taskgroup): Add clauses argument. * gimple-pretty-print.c (dump_gimple_omp_taskgroup): New function. (dump_gimple_omp_task): Print taskwait with depend clauses. (dump_gimple_omp_atomic_load, dump_gimple_omp_atomic_store): Use dump_omp_atomic_memory_order. (pp_gimple_stmt_1): Handle GIMPLE_OMP_TASKGROUP. * gimplify.c (enum gimplify_omp_var_data): Add GOVD_MAP_ALLOC_ONLY, GOVD_MAP_FROM_ONLY and GOVD_NONTEMPORAL. (enum omp_region_type): Reserve bits 1 and 2 for auxiliary flags, renumber values of most of ORT_* enumerators, add ORT_HOST_TEAMS, ORT_COMBINED_HOST_TEAMS, ORT_TASKGROUP, ORT_TASKLOOP and ORT_UNTIED_TASKLOOP enumerators. (enum gimplify_defaultmap_kind): New. (struct gimplify_omp_ctx): Remove target_map_scalars_firstprivate and target_map_pointers_as_0len_arrays members, add defaultmap. (new_omp_context): Initialize defaultmap member. (gimple_add_tmp_var): Handle ORT_TASKGROUP like ORT_WORKSHARE. (maybe_fold_stmt): Don't fold even in host teams regions. (omp_firstprivatize_variable): Handle ORT_TASKGROUP like ORT_WORKSHARE. Test ctx->defaultmap[GDMK_SCALAR] instead of ctx->omp_firstprivatize_variable. (omp_add_variable): Don't add private/firstprivate for VLAs in ORT_TASKGROUP. (omp_default_clause): Print "taskloop" rather than "task" if ORT_*TASKLOOP. (omp_notice_variable): Handle ORT_TASKGROUP like ORT_WORKSHARE. Handle new defaultmap clause kinds. (omp_is_private): Handle ORT_TASKGROUP like ORT_WORKSHARE. Allow simd iterator to be lastprivate or private. Fix up diagnostics if linear is used on collapse>1 simd iterator. (omp_check_private): Handle ORT_TASKGROUP like ORT_WORKSHARE. (gimplify_omp_depend): New function. (gimplify_scan_omp_clauses): Add shared clause on parallel for combined parallel master taskloop{, simd} if taskloop has firstprivate, lastprivate or reduction clause. Handle OMP_CLAUSE_REDUCTION_TASK diagnostics. Adjust tests for ORT_COMBINED_TEAMS. Gimplify depend clauses with iterators. Handle cancel and simd OMP_CLAUSE_IF_MODIFIERs. Handle OMP_CLAUSE_NONTEMPORAL. Handle new defaultmap clause kinds. Handle OMP_CLAUSE_{TASK,IN}_REDUCTION. Diagnose invalid conditional lastprivate. (gimplify_adjust_omp_clauses_1): Ignore GOVD_NONTEMPORAL. Handle GOVD_MAP_ALLOC_ONLY and GOVD_MAP_FROM_ONLY. (gimplify_adjust_omp_clauses): Handle OMP_CLAUSE_NONTEMPORAL. Handle OMP_CLAUSE_{TASK,IN}_REDUCTION. (gimplify_omp_task): Handle taskwait with depend clauses. (gimplify_omp_for): Add shared clause on parallel for combined parallel master taskloop{, simd} if taskloop has firstprivate, lastprivate or reduction clause. Use ORT_TASKLOOP or ORT_UNTIED_TASKLOOP instead of ORT_TASK or ORT_UNTIED_TASK. Adjust tests for ORT_COMBINED_TEAMS. Handle C++ range for loops with NULL TREE_PURPOSE in OMP_FOR_ORIG_DECLS. Firstprivatize __for_end and __for_range temporaries on OMP_PARALLEL for distribute parallel for{, simd}. Move OMP_CLAUSE_REDUCTION and OMP_CLAUSE_IN_REDUCTION from taskloop to the task construct sandwiched in between two taskloops. (computable_teams_clause): Test ctx->defaultmap[GDMK_SCALAR] instead of ctx->omp_firstprivatize_variable. (gimplify_omp_workshare): Set ort to ORT_HOST_TEAMS or ORT_COMBINED_HOST_TEAMS if not inside of target construct. If host teams, use gimplify_and_return_first etc. for body like for target or target data constructs, and at the end call gimple_omp_teams_set_host on the GIMPLE_OMP_TEAMS object. (gimplify_omp_atomic): Use OMP_ATOMIC_MEMORY_ORDER instead of OMP_ATOMIC_SEQ_CST, pass it as new argument to gimple_build_omp_atomic_load and gimple_build_omp_atomic_store, remove gimple_omp_atomic_set_seq_cst calls. (gimplify_expr) <case OMP_TASKGROUP>: Move handling into a separate case, handle taskgroup clauses. * lto-streamer-out.c (hash_tree): Handle OMP_CLAUSE_{TASK,IN}_REDUCTION. * Makefile.in (GTFILES): Add omp-general.h. * omp-builtins.def (BUILT_IN_GOMP_TASKWAIT_DEPEND, BUILT_IN_GOMP_LOOP_NONMONOTONIC_RUNTIME_START, BUILT_IN_GOMP_LOOP_MAYBE_NONMONOTONIC_RUNTIME_START, BUILT_IN_GOMP_LOOP_START, BUILT_IN_GOMP_LOOP_ORDERED_START, BUILT_IN_GOMP_LOOP_DOACROSS_START, BUILT_IN_GOMP_LOOP_NONMONOTONIC_RUNTIME_NEXT, BUILT_IN_GOMP_LOOP_MAYBE_NONMONOTONIC_RUNTIME_NEXT, BUILT_IN_GOMP_LOOP_ULL_NONMONOTONIC_RUNTIME_START, BUILT_IN_GOMP_LOOP_ULL_MAYBE_NONMONOTONIC_RUNTIME_START, BUILT_IN_GOMP_LOOP_ULL_START, BUILT_IN_GOMP_LOOP_ULL_ORDERED_START, BUILT_IN_GOMP_LOOP_ULL_DOACROSS_START, BUILT_IN_GOMP_LOOP_ULL_NONMONOTONIC_RUNTIME_NEXT, BUILT_IN_GOMP_LOOP_ULL_MAYBE_NONMONOTONIC_RUNTIME_NEXT, BUILT_IN_GOMP_PARALLEL_LOOP_NONMONOTONIC_RUNTIME, BUILT_IN_GOMP_PARALLEL_LOOP_MAYBE_NONMONOTONIC_RUNTIME, BUILT_IN_GOMP_PARALLEL_REDUCTIONS, BUILT_IN_GOMP_SECTIONS2_START, BUILT_IN_GOMP_TEAMS_REG, BUILT_IN_GOMP_TASKGROUP_REDUCTION_REGISTER, BUILT_IN_GOMP_TASKGROUP_REDUCTION_UNREGISTER, BUILT_IN_GOMP_TASK_REDUCTION_REMAP, BUILT_IN_GOMP_WORKSHARE_TASK_REDUCTION_UNREGISTER): New builtins. * omp-expand.c (workshare_safe_to_combine_p): Return false for non-worksharing loops. (omp_adjust_chunk_size): Don't adjust anything if chunk_size is zero. (determine_parallel_type): Don't combine parallel with worksharing which has _reductemp_ clause. (expand_parallel_call): Emit the GOMP_*nonmonotonic_runtime* or GOMP_*maybe_nonmonotonic_runtime* builtins instead of GOMP_*runtime* if there is nonmonotonic modifier or if there is no modifier and no ordered clause. For dynamic and guided schedule without monotonic and nonmonotonic modifier, default to nonmonotonic. (expand_omp_for): Likewise. Adjust expand_omp_for_generic caller, use GOMP_loop{,_ull}{,_ordered,_doacross}_start builtins if there are task reductions. (expand_task_call): Add GOMP_TASK_FLAG_REDUCTION flag to flags if there are any reduction clauses. (expand_taskwait_call): New function. (expand_teams_call): New function. (expand_omp_taskreg): Allow GIMPLE_OMP_TEAMS and call expand_teams_call for it. Formatting fix. Handle taskwait with depend clauses. (expand_omp_for_generic): Add SCHED_ARG argument. Handle expansion of worksharing loops with task reductions. (expand_omp_for_static_nochunk, expand_omp_for_static_chunk): Handle expansion of worksharing loops with task reductions. (expand_omp_sections): Handle expansion of sections with task reductions. (expand_omp_synch): For host teams call expand_omp_taskreg. (omp_memory_order_to_memmodel): New function. (expand_omp_atomic_load, expand_omp_atomic_store, expand_omp_atomic_fetch_op): Use it and gimple_omp_atomic_memory_order instead of gimple_omp_atomic_seq_cst_p. (build_omp_regions_1, omp_make_gimple_edges): Treat taskwait with depend clauses as a standalone directive. * omp-general.c (enum omp_requires): New variable. (omp_extract_for_data): Initialize have_reductemp member. Allow NE_EXPR even in OpenMP loops, transform them into LT_EXPR or GT_EXPR loops depending on incr sign. Formatting fixes. * omp-general.h (struct omp_for_data): Add have_reductemp member. (enum omp_requires): New enum. (omp_requires_mask): Declare. * omp-grid.c (grid_eliminate_combined_simd_part): Formatting fix. Fix comment typos. * omp-low.c (struct omp_context): Add task_reductions and task_reduction_map fields. (is_host_teams_ctx): New function. (is_taskreg_ctx): Return true also if is_host_teams_ctx. (use_pointer_for_field): Use is_global_var instead of TREE_STATIC || DECL_EXTERNAL, and apply only if not privatized in outer contexts. (build_outer_var_ref): Ignore taskgroup outer contexts. (delete_omp_context): Release task_reductions and task_reduction_map. (scan_sharing_clauses): Don't add any fields for reduction clause on taskloop. Handle OMP_CLAUSE__REDUCTEMP_. Handle OMP_CLAUSE_{IN,TASK}_REDUCTION and OMP_CLAUSE_REDUCTION with task modifier. Don't ignore shared clauses in is_host_teams_ctx contexts. Handle OMP_CLAUSE_NONTEMPORAL. (add_taskreg_looptemp_clauses): Add OMP_CLAUSE__REDUCTEMP_ clause if needed. (scan_omp_parallel): Add _reductemp_ clause if there are any reduction clauses with task modifier. (scan_omp_task): Handle taskwait with depend clauses. (finish_taskreg_scan): Move field corresponding to _reductemp_ clause first. Move also OMP_CLAUSE__REDUCTEMP_ clause in front if present. Handle GIMPLE_OMP_TEAMS like GIMPLE_OMP_PARALLEL. (scan_omp_for): Fix comment formatting. (scan_omp_teams): Handle host teams constructs. (check_omp_nesting_restrictions): Allow teams with no outer OpenMP context. Adjust diagnostics for teams strictly nested into some explicit OpenMP construct other than target. Allow OpenMP atomics inside of simd regions. (scan_omp_1_stmt): Call scan_sharing_clauses for taskgroups. (scan_omp_1_stmt) <case GIMPLE_OMP_TEAMS>: Temporarily bump taskreg_nesting_level while scanning host teams construct. (task_reduction_read): New function. (lower_rec_input_clauses): Handle OMP_CLAUSE_REDUCTION on taskloop construct. Handle OMP_CLAUSE_IN_REDUCTION and OMP_CLAUSE__REDUCTEMP_ clauses. Handle OMP_CLAUSE_REDUCTION with task modifier. Remove second argument create_tmp_var if it is NULL. Don't ignore shared clauses in is_host_teams_ctx contexts. Handle OMP_CLAUSE_FIRSTPRIVATE_NO_REFERENCE on OMP_CLAUSE_FIRSTPRIVATE clauses. (lower_reduction_clauses): Ignore reduction clauses with task modifier. Remove second argument create_tmp_var if it is NULL. Initialize OMP_ATOMIC_MEMORY_ORDER to relaxed. (lower_send_clauses): Ignore reduction clauses with task modifier. Handle OMP_CLAUSE__REDUCTEMP_. Don't send anything for OMP_CLAUSE_REDUCTION on taskloop. Handle OMP_CLAUSE_IN_REDUCTION. (maybe_add_implicit_barrier_cancel): Add OMP_RETURN argument, don't rely that it is the last stmt in body so far. Ignore outer taskgroup contexts. (omp_task_reductions_find_first, omp_task_reduction_iterate, lower_omp_task_reductions): New functions. (lower_omp_sections): Handle reduction clauses with taskgroup modifiers. Adjust maybe_add_implicit_barrier_cancel caller. (lower_omp_single): Adjust maybe_add_implicit_barrier_cancel caller. (lower_omp_for): Likewise. Handle reduction clauses with taskgroup modifiers. (lower_omp_taskgroup): Handle taskgroup reductions. (create_task_copyfn): Copy over OMP_CLAUSE__REDUCTEMP_ pointer. Handle OMP_CLAUSE_IN_REDUCTION and OMP_CLAUSE_REDUCTION clauses. (lower_depend_clauses): If there are any OMP_CLAUSE_DEPEND_DEPOBJ or OMP_CLAUSE_DEPEND_MUTEXINOUTSET depend clauses, use a new array format. If OMP_CLAUSE_DEPEND_LAST is seen, assume lowering is done already and return early. Set kind on artificial depend clause to OMP_CLAUSE_DEPEND_LAST. (lower_omp_taskreg): Handle reduction clauses with task modifier on parallel construct. Handle reduction clause on taskloop construct. Handle taskwait with depend clauses. (lower_omp_1): Use lower_omp_taskreg instead of lower_omp_teams for host teams constructs. * tree.c (omp_clause_num_ops): Add in_reduction, task_reduction, nontemporal and _reductemp_ clause entries. (omp_clause_code_name): Likewise. (walk_tree_1): Handle OMP_CLAUSE_{IN,TASK}_REDUCTION, OMP_CLAUSE_NONTEMPORAL and OMP_CLAUSE__REDUCTEMP_. * tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_{{IN,TASK}_REDUCTION,NONTEMPORAL,_REDUCTEMP_}. (enum omp_clause_defaultmap_kind, enum omp_memory_order): New. (struct tree_base): Add omp_atomic_memory_order field into union. Remove OMP_ATOMIC_SEQ_CST comment. (enum omp_clause_depend_kind): Add OMP_CLAUSE_DEPEND_MUTEXINOUTSET and OMP_CLAUSE_DEPEND_DEPOBJ. (struct tree_omp_clause): Add subcode.defaultmap_kind. * tree.def (OMP_TASKGROUP): Add another operand, move next to other OpenMP constructs with body and clauses operands. * tree.h (OMP_BODY): Use OMP_MASTER instead of OMP_TASKGROUP. (OMP_CLAUSES): Use OMP_TASKGROUP instead of OMP_SINGLE. (OMP_TASKGROUP_CLAUSES): Define. (OMP_CLAUSE_DECL): Use OMP_CLAUSE__REDUCTEMP_ instead of OMP_CLAUSE__LOOPTEMP_. (OMP_ATOMIC_SEQ_CST): Remove. (OMP_ATOMIC_MEMORY_ORDER, OMP_CLAUSE_FIRSTPRIVATE_NO_REFERENCE, OMP_CLAUSE_LASTPRIVATE_CONDITIONAL): Define. (OMP_CLAUSE_REDUCTION_CODE, OMP_CLAUSE_REDUCTION_INIT, OMP_CLAUSE_REDUCTION_MERGE, OMP_CLAUSE_REDUCTION_PLACEHOLDER, OMP_CLAUSE_REDUCTION_DECL_PLACEHOLDER, OMP_CLAUSE_REDUCTION_OMP_ORIG_REF): Handle OMP_CLAUSE_{,IN_,TASK_}REDUCTION. (OMP_CLAUSE_REDUCTION_TASK, OMP_CLAUSE_REDUCTION_INSCAN, OMP_CLAUSE_DEFAULTMAP_KIND, OMP_CLAUSE_DEFAULTMAP_CATEGORY, OMP_CLAUSE_DEFAULTMAP_BEHAVIOR, OMP_CLAUSE_DEFAULTMAP_SET_KIND): Define. * tree-inline.c (remap_gimple_stmt): Remap taskgroup clauses. * tree-nested.c (convert_nonlocal_omp_clauses): Handle OMP_CLAUSE__REDUCTEMP_, OMP_CLAUSE_NONTEMPORAL. (convert_local_omp_clauses): Likewise. Remove useless test. * tree-parloops.c (create_call_for_reduction_1): Pass OMP_MEMORY_ORDER_RELAXED as new argument to dump_gimple_omp_atomic_load and dump_gimple_omp_atomic_store. * tree-pretty-print.c (dump_omp_iterators): New function. (dump_omp_clause): Handle OMP_CLAUSE__REDUCTEMP_, OMP_CLAUSE_NONTEMPORAL, OMP_CLAUSE_{TASK,IN}_REDUCTION. Print reduction modifiers. Handle OMP_CLAUSE_DEPEND_DEPOBJ and OMP_CLAUSE_DEPEND_MUTEXINOUTSET. Print iterators in depend clauses. Print __internal__ for OMP_CLAUSE_DEPEND_LAST. Handle cancel and simd OMP_CLAUSE_IF_MODIFIERs. Handle new kinds of OMP_CLAUSE_DEFAULTMAP. Print conditional: for OMP_CLAUSE_LASTPRIVATE_CONDITIONAL. (dump_omp_atomic_memory_order): New function. (dump_generic_node): Use it. Print taskgroup clauses. Print taskwait with depend clauses. * tree-pretty-print.h (dump_omp_atomic_memory_order): Declare. * tree-streamer-in.c (unpack_ts_omp_clause_value_fields): Handle OMP_CLAUSE_{TASK,IN}_REDUCTION. * tree-streamer-out.c (pack_ts_omp_clause_value_fields, write_ts_omp_clause_tree_pointers): Likewise. gcc/c-family/ * c-common.h (c_finish_omp_taskgroup): Add CLAUSES argument. (c_finish_omp_atomic): Replace bool SEQ_CST argument with enum omp_memory_order MEMORY_ORDER. (c_finish_omp_flush): Add MO argument. (c_omp_depend_t_p, c_finish_omp_depobj): Declare. (c_finish_omp_for): Add FINAL_P argument. * c-omp.c: Include memmodel.h. (c_finish_omp_taskgroup): Add CLAUSES argument. Set OMP_TASKGROUP_CLAUSES to it. (c_finish_omp_atomic): Replace bool SEQ_CST argument with enum omp_memory_order MEMORY_ORDER. Set OMP_ATOMIC_MEMORY_ORDER instead of OMP_ATOMIC_SEQ_CST. (c_omp_depend_t_p, c_finish_omp_depobj): New functions. (c_finish_omp_flush): Add MO argument, if not MEMMODEL_LAST, emit __atomic_thread_fence call with the given value. (check_omp_for_incr_expr): Formatting fixes. (c_finish_omp_for): Add FINAL_P argument. Allow NE_EXPR even in OpenMP loops, diagnose if NE_EXPR and incr expression is not constant expression 1 or -1. Transform NE_EXPR loops with iterators pointers to VLA into LT_EXPR or GT_EXPR loops. (c_omp_check_loop_iv_r): Look for orig decl of C++ range for loops too. (c_omp_split_clauses): Add support for combined #pragma omp parallel master and #pragma omp {,parallel }master taskloop{, simd} constructs. Handle OMP_CLAUSE_IN_REDUCTION. Handle OMP_CLAUSE_REDUCTION_TASK. Handle OMP_CLAUSE_NONTEMPORAL. Handle splitting OMP_CLAUSE_IF also to OMP_SIMD. Copy OMP_CLAUSE_LASTPRIVATE_CONDITIONAL. (c_omp_predetermined_sharing): Don't return OMP_CLAUSE_DEFAULT_SHARED for const qualified decls. * c-pragma.c (omp_pragmas): Add PRAGMA_OMP_DEPOBJ and PRAGMA_OMP_REQUIRES. * c-pragma.h (enum pragma_kind): Likewise. (enum pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_NONTEMPORAL and PRAGMA_OMP_CLAUSE_{IN,TASK}_REDUCTION. gcc/c/ * c-parser.c: Include memmode.h. (c_parser_omp_depobj, c_parser_omp_requires): New functions. (c_parser_pragma): Handle PRAGMA_OMP_DEPOBJ and PRAGMA_OMP_REQUIRES. (c_parser_omp_clause_name): Handle nontemporal, in_reduction and task_reduction clauses. (c_parser_omp_variable_list): Handle OMP_CLAUSE_{IN,TASK}_REDUCTION. For OMP_CLAUSE_DEPEND, parse clause operands as either an array section, or lvalue assignment expression. (c_parser_omp_clause_if): Handle cancel and simd modifiers. (c_parser_omp_clause_lastprivate): Parse optional conditional: modifier. (c_parser_omp_clause_hint): Require constant integer expression rather than just integer expression. (c_parser_omp_clause_defaultmap): Parse new kinds of defaultmap clause. (c_parser_omp_clause_reduction): Add IS_OMP and KIND arguments. Parse reduction modifiers. Pass KIND to c_parser_omp_variable_list. (c_parser_omp_clause_nontemporal, c_parser_omp_iterators): New functions. (c_parser_omp_clause_depend): Parse iterator modifier and handle iterators. Parse mutexinoutset and depobj kinds. (c_parser_oacc_all_clauses): Adjust c_parser_omp_clause_reduction callers. (c_parser_omp_all_clauses): Likewise. Handle PRAGMA_OMP_CLAUSE_NONTEMPORAL and PRAGMA_OMP_CLAUSE_{IN,TASK}_REDUCTION. (c_parser_omp_atomic): Parse hint and memory order clauses. Handle default memory order from requires directive if any. Adjust c_finish_omp_atomic caller. (c_parser_omp_critical): Allow comma in between (name) and hint clause. (c_parser_omp_flush): Parse flush with memory-order-clause. (c_parser_omp_for_loop): Allow NE_EXPR even in OpenMP loops, adjust c_finish_omp_for caller. (OMP_SIMD_CLAUSE_MASK): Add if and nontemporal clauses. (c_parser_omp_master): Add p_name, mask and cclauses arguments. Allow to be called while parsing combined parallel master. Parse combined master taskloop{, simd}. (c_parser_omp_parallel): Parse combined parallel master{, taskloop{, simd}} constructs. (OMP_TASK_CLAUSE_MASK): Add in_reduction clause. (OMP_TASKGROUP_CLAUSE_MASK): Define. (c_parser_omp_taskgroup): Add LOC argument. Parse taskgroup clauses. (OMP_TASKWAIT_CLAUSE_MASK): Define. (c_parser_omp_taskwait): Handle taskwait with depend clauses. (c_parser_omp_teams): Force a BIND_EXPR with BLOCK around teams body. Use SET_EXPR_LOCATION. (c_parser_omp_target_data): Allow target data with only use_device_ptr clauses. (c_parser_omp_target): Use SET_EXPR_LOCATION. Set OMP_REQUIRES_TARGET_USED bit in omp_requires_mask. (c_parser_omp_requires): New function. (c_finish_taskloop_clauses): New function. (OMP_TASKLOOP_CLAUSE_MASK): Add reduction and in_reduction clauses. (c_parser_omp_taskloop): Use c_finish_taskloop_clauses. Add forward declaration. Disallow in_reduction clause when combined with parallel master. (c_parser_omp_construct): Adjust c_parser_omp_master and c_parser_omp_taskgroup callers. * c-typeck.c (c_finish_omp_cancel): Diagnose if clause with modifier other than cancel. (handle_omp_array_sections_1): Handle OMP_CLAUSE_{IN,TASK}_REDUCTION like OMP_CLAUSE_REDUCTION. (handle_omp_array_sections): Likewise. Call save_expr on array reductions before calling build_index_type. Handle depend clauses with iterators. (struct c_find_omp_var_s): New type. (c_find_omp_var_r, c_omp_finish_iterators): New functions. (c_finish_omp_clauses): Don't diagnose nonmonotonic clause with static, runtime or auto schedule kinds. Call save_expr for whole array reduction sizes. Diagnose reductions with zero sized elements or variable length structures. Diagnose nogroup clause used with reduction clause(s). Handle depend clause with OMP_CLAUSE_DEPEND_DEPOBJ. Diagnose bit-fields. Require omp_depend_t type for OMP_CLAUSE_DEPEND_DEPOBJ kinds and some different type for other kinds. Use build_unary_op with ADDR_EXPR and build_indirect_ref instead of c_mark_addressable. Handle depend clauses with iterators. Remove no longer needed special case that predetermined const qualified vars may be specified in firstprivate clause. Complain if const qualified vars are mentioned in data-sharing clauses other than firstprivate or shared. Use error_at with OMP_CLAUSE_LOCATION (c) as first argument instead of error. Formatting fix. Handle OMP_CLAUSE_NONTEMPORAL and OMP_CLAUSE_{IN,TASK}_REDUCTION. Allow any lvalue as OMP_CLAUSE_DEPEND operand (besides array section), adjust diagnostics. gcc/cp/ * constexpr.c (potential_constant_expression_1): Handle OMP_DEPOBJ. * cp-gimplify.c (cp_genericize_r): Handle OMP_CLAUSE_{IN,TASK}_REDUCTION. (cxx_omp_predetermined_sharing_1): Don't return OMP_CLAUSE_DEFAULT_SHARED for const qualified decls with no mutable member. Return OMP_CLAUSE_DEFAULT_FIRSTPRIVATE for this pointer. * cp-objcp-common.c (cp_common_init_ts): Handle OMP_DEPOBJ. * cp-tree.def (OMP_DEPOBJ): New tree code. * cp-tree.h (OMP_ATOMIC_DEPENDENT_P): Return true also for first argument being OMP_CLAUSE. (OMP_DEPOBJ_DEPOBJ, OMP_DEPOBJ_CLAUSES): Define. (cp_convert_omp_range_for, cp_finish_omp_range_for): Declare. (finish_omp_atomic): Add LOC, CLAUSES and MO arguments. Remove SEQ_CST argument. (finish_omp_for_block): Declare. (finish_omp_flush): Add MO argument. (finish_omp_depobj): Declare. * cxx-pretty-print.c (cxx_pretty_printer::statement): Handle OMP_DEPOBJ. * dump.c (cp_dump_tree): Likewise. * lex.c (cxx_init): Likewise. * parser.c: Include memmodel.h. (cp_parser_for): Pass false as new is_omp argument to cp_parser_range_for. (cp_parser_range_for): Add IS_OMP argument, return before finalizing if it is true. (cp_parser_omp_clause_name): Handle nontemporal, in_reduction and task_reduction clauses. (cp_parser_omp_var_list_no_open): Handle OMP_CLAUSE_{IN,TASK}_REDUCTION. For OMP_CLAUSE_DEPEND, parse clause operands as either an array section, or lvalue assignment expression. (cp_parser_omp_clause_if): Handle cancel and simd modifiers. (cp_parser_omp_clause_defaultmap): Parse new kinds of defaultmap clause. (cp_parser_omp_clause_reduction): Add IS_OMP and KIND arguments. Parse reduction modifiers. Pass KIND to c_parser_omp_variable_list. (cp_parser_omp_clause_lastprivate, cp_parser_omp_iterators): New functions. (cp_parser_omp_clause_depend): Parse iterator modifier and handle iterators. Parse mutexinoutset and depobj kinds. (cp_parser_oacc_all_clauses): Adjust cp_parser_omp_clause_reduction callers. (cp_parser_omp_all_clauses): Likewise. Handle PRAGMA_OMP_CLAUSE_NONTEMPORAL and PRAGMA_OMP_CLAUSE_{IN,TASK}_REDUCTION. Call cp_parser_omp_clause_lastprivate for OpenMP lastprivate clause. (cp_parser_omp_atomic): Pass pragma_tok->location as LOC to finish_omp_atomic. Parse hint and memory order clauses. Handle default memory order from requires directive if any. Adjust finish_omp_atomic caller. (cp_parser_omp_critical): Allow comma in between (name) and hint clause. (cp_parser_omp_depobj): New function. (cp_parser_omp_flush): Parse flush with memory-order-clause. (cp_parser_omp_for_cond): Allow NE_EXPR even in OpenMP loops. (cp_convert_omp_range_for, cp_finish_omp_range_for): New functions. (cp_parser_omp_for_loop): Parse C++11 range for loops among omp loops. Handle OMP_CLAUSE_IN_REDUCTION like OMP_CLAUSE_REDUCTION. (OMP_SIMD_CLAUSE_MASK): Add if and nontemporal clauses. (cp_parser_omp_simd, cp_parser_omp_for): Call keep_next_level before begin_omp_structured_block and call finish_omp_for_block on finish_omp_structured_block result. (cp_parser_omp_master): Add p_name, mask and cclauses arguments. Allow to be called while parsing combined parallel master. Parse combined master taskloop{, simd}. (cp_parser_omp_parallel): Parse combined parallel master{, taskloop{, simd}} constructs. (cp_parser_omp_single): Use SET_EXPR_LOCATION. (OMP_TASK_CLAUSE_MASK): Add in_reduction clause. (OMP_TASKWAIT_CLAUSE_MASK): Define. (cp_parser_omp_taskwait): Handle taskwait with depend clauses. (OMP_TASKGROUP_CLAUSE_MASK): Define. (cp_parser_omp_taskgroup): Parse taskgroup clauses, adjust c_finish_omp_taskgroup caller. (cp_parser_omp_distribute): Call keep_next_level before begin_omp_structured_block and call finish_omp_for_block on finish_omp_structured_block result. (cp_parser_omp_teams): Force a BIND_EXPR with BLOCK around teams body. (cp_parser_omp_target_data): Allow target data with only use_device_ptr clauses. (cp_parser_omp_target): Set OMP_REQUIRES_TARGET_USED bit in omp_requires_mask. (cp_parser_omp_requires): New function. (OMP_TASKLOOP_CLAUSE_MASK): Add reduction and in_reduction clauses. (cp_parser_omp_taskloop): Add forward declaration. Disallow in_reduction clause when combined with parallel master. Call keep_next_level before begin_omp_structured_block and call finish_omp_for_block on finish_omp_structured_block result. (cp_parser_omp_construct): Adjust cp_parser_omp_master caller. (cp_parser_pragma): Handle PRAGMA_OMP_DEPOBJ and PRAGMA_OMP_REQUIRES. * pt.c (tsubst_omp_clause_decl): Add iterators_cache argument. Adjust recursive calls. Handle iterators. (tsubst_omp_clauses): Handle OMP_CLAUSE_{IN,TASK}_REDUCTION and OMP_CLAUSE_NONTEMPORAL. Adjust tsubst_omp_clause_decl callers. (tsubst_decomp_names): (tsubst_omp_for_iterator): Change orig_declv into a reference. Handle range for loops. Move orig_declv handling after declv/initv handling. (tsubst_expr): Force a BIND_EXPR with BLOCK around teams body. Adjust finish_omp_atomic caller. Call keep_next_level before begin_omp_structured_block. Call cp_finish_omp_range_for for range for loops and use {begin,finish}_omp_structured_block instead of {push,pop}_stmt_list if there are any range for loops. Call finish_omp_for_block on finish_omp_structured_block result. Handle OMP_DEPOBJ. Handle taskwait with depend clauses. For OMP_ATOMIC call tsubst_omp_clauses on clauses if any, adjust finish_omp_atomic caller. Use OMP_ATOMIC_MEMORY_ORDER rather than OMP_ATOMIC_SEQ_CST. Handle clauses on OMP_TASKGROUP. (dependent_omp_for_p): Always return true for range for loops if processing_template_decl. Return true if class type iterator does not have INTEGER_CST increment. * semantics.c: Include memmodel.h. (handle_omp_array_sections_1): Handle OMP_CLAUSE_{IN,TASK}_REDUCTION like OMP_CLAUSE_REDUCTION. (handle_omp_array_sections): Likewise. Call save_expr on array reductions before calling build_index_type. Handle depend clauses with iterators. (finish_omp_reduction_clause): Call save_expr for whole array reduction sizes. Don't mark OMP_CLAUSE_DECL addressable if it has reference type. Do mark decl_placeholder addressable if needed. Use error_at with OMP_CLAUSE_LOCATION (c) as first argument instead of error. (cp_omp_finish_iterators): New function. (finish_omp_clauses): Don't diagnose nonmonotonic clause with static, runtime or auto schedule kinds. Diagnose nogroup clause used with reduction clause(s). Handle depend clause with OMP_CLAUSE_DEPEND_DEPOBJ. Diagnose bit-fields. Require omp_depend_t type for OMP_CLAUSE_DEPEND_DEPOBJ kinds and some different type for other kinds. Use cp_build_addr_expr and cp_build_indirect_ref instead of cxx_mark_addressable. Handle depend clauses with iterators. Only handle static data members in the special case that const qualified vars may be specified in firstprivate clause. Complain if const qualified vars without mutable members are mentioned in data-sharing clauses other than firstprivate or shared. Use error_at with OMP_CLAUSE_LOCATION (c) as first argument instead of error. Diagnose more than one nontemporal clause refering to the same variable. Use error_at rather than error for priority and hint clause diagnostics. Fix pasto for hint clause. Diagnose hint expression that doesn't fold into INTEGER_CST. Diagnose if clause with modifier other than cancel. Handle OMP_CLAUSE_{IN,TASK}_REDUCTION like OMP_CLAUSE_REDUCTION. Allow any lvalue as OMP_CLAUSE_DEPEND operand (besides array section), adjust diagnostics. (handle_omp_for_class_iterator): Don't create a new TREE_LIST if one has been created already for range for, just fill TREE_PURPOSE and TREE_VALUE. Call cp_fully_fold on incr. (finish_omp_for): Don't check cond/incr if cond is global_namespace. Pass to c_omp_check_loop_iv_exprs orig_declv if non-NULL. Don't use IS_EMPTY_STMT on NULL pre_body. Adjust c_finish_omp_for caller. (finish_omp_for_block): New function. (finish_omp_atomic): Add LOC argument, pass it through to c_finish_omp_atomic and set it as location of OMP_ATOMIC* trees. Remove SEQ_CST argument. Add CLAUSES and MO arguments. Adjust c_finish_omp_atomic caller. Stick clauses if any into first argument of wrapping OMP_ATOMIC. (finish_omp_depobj): New function. (finish_omp_flush): Add MO argument, if not MEMMODEL_LAST, emit __atomic_thread_fence call with the given value. (finish_omp_cancel): Diagnose if clause with modifier other than cancel. gcc/fortran/ * trans-openmp.c (gfc_trans_omp_clauses): Use OMP_CLAUSE_DEFAULTMAP_SET_KIND. (gfc_trans_omp_atomic): Set OMP_ATOMIC_MEMORY_ORDER rather than OMP_ATOMIC_SEQ_CST. (gfc_trans_omp_taskgroup): Build OMP_TASKGROUP using make_node instead of build1_loc. * types.def (BT_FN_VOID_BOOL, BT_FN_VOID_SIZE_SIZE_PTR, BT_FN_UINT_UINT_PTR_PTR, BT_FN_UINT_OMPFN_PTR_UINT_UINT, BT_FN_BOOL_UINT_LONGPTR_LONG_LONG_LONGPTR_LONGPTR_PTR_PTR, BT_FN_BOOL_UINT_ULLPTR_LONG_ULL_ULLPTR_ULLPTR_PTR_PTR, BT_FN_BOOL_LONG_LONG_LONG_LONG_LONG_LONGPTR_LONGPTR_PTR_PTR, BT_FN_BOOL_BOOL_ULL_ULL_ULL_LONG_ULL_ULLPTR_ULLPTR_PTR_PTR): New. (BT_FN_VOID_INT_OMPFN_SIZE_PTR_PTR_PTR_UINT_PTR_PTR): Formatting fix. gcc/testsuite/ * c-c++-common/gomp/atomic-17.c: New test. * c-c++-common/gomp/atomic-18.c: New test. * c-c++-common/gomp/atomic-19.c: New test. * c-c++-common/gomp/atomic-20.c: New test. * c-c++-common/gomp/atomic-21.c: New test. * c-c++-common/gomp/atomic-22.c: New test. * c-c++-common/gomp/clauses-1.c (r2): New variable. (foo): Add ntm argument and test if and nontemporal clauses on constructs with simd. (bar): Put taskloop simd inside of taskgroup with task_reduction, use in_reduction clause instead of reduction. Add another taskloop simd without nogroup clause, but with reduction clause and a new in_reduction. Add ntm and i3 arguments. Test if and nontemporal clauses on constructs with simd. Change if clauses on some constructs from specific to the particular constituents to one without a modifier. Add new tests for combined host teams and for new parallel master and {,parallel }master taskloop{, simd} combined constructs. (baz): New function with host teams tests. * gcc.dg/gomp/combined-1.c: Moved to ... * c-c++-common/gomp/combined-1.c: ... here. Adjust expected library call. * c-c++-common/gomp/combined-2.c: New test. * c-c++-common/gomp/combined-3.c: New test. * c-c++-common/gomp/critical-1.c: New test. * c-c++-common/gomp/critical-2.c: New test. * c-c++-common/gomp/default-1.c: New test. * c-c++-common/gomp/defaultmap-1.c: New test. * c-c++-common/gomp/defaultmap-2.c: New test. * c-c++-common/gomp/defaultmap-3.c: New test. * c-c++-common/gomp/depend-5.c: New test. * c-c++-common/gomp/depend-6.c: New test. * c-c++-common/gomp/depend-iterator-1.c: New test. * c-c++-common/gomp/depend-iterator-2.c: New test. * c-c++-common/gomp/depobj-1.c: New test. * c-c++-common/gomp/flush-1.c: New test. * c-c++-common/gomp/flush-2.c: New test. * c-c++-common/gomp/for-1.c: New test. * c-c++-common/gomp/for-2.c: New test. * c-c++-common/gomp/for-3.c: New test. * c-c++-common/gomp/for-4.c: New test. * c-c++-common/gomp/for-5.c: New test. * c-c++-common/gomp/for-6.c: New test. * c-c++-common/gomp/for-7.c: New test. * c-c++-common/gomp/if-1.c (foo): Add some further tests. * c-c++-common/gomp/if-2.c (foo): Likewise. Expect slightly different diagnostics wording in one case. * c-c++-common/gomp/if-3.c: New test. * c-c++-common/gomp/master-combined-1.c: New test. * c-c++-common/gomp/master-combined-2.c: New test. * c-c++-common/gomp/nontemporal-1.c: New test. * c-c++-common/gomp/nontemporal-2.c: New test. * c-c++-common/gomp/reduction-task-1.c: New test. * c-c++-common/gomp/reduction-task-2.c: New test. * c-c++-common/gomp/requires-1.c: New test. * c-c++-common/gomp/requires-2.c: New test. * c-c++-common/gomp/requires-3.c: New test. * c-c++-common/gomp/requires-4.c: New test. * c-c++-common/gomp/schedule-modifiers-1.c (bar): Don't expect diagnostics for nonmonotonic modifier with static, runtime or auto schedule kinds. * c-c++-common/gomp/simd7.c: New test. * c-c++-common/gomp/target-data-1.c: New test. * c-c++-common/gomp/taskloop-reduction-1.c: New test. * c-c++-common/gomp/taskwait-depend-1.c: New test. * c-c++-common/gomp/teams-1.c: New test. * c-c++-common/gomp/teams-2.c: New test. * gcc.dg/gomp/appendix-a/a.24.1.c: Update from OpenMP examples. Add shared(c) clause. * gcc.dg/gomp/atomic-5.c (f1): Add another expected error. * gcc.dg/gomp/clause-1.c: Adjust expected diagnostics for const qualified vars without mutable member no longer being predeterined shared. * gcc.dg/gomp/sharing-1.c: Likewise. * g++.dg/gomp/clause-3.C: Likewise. * g++.dg/gomp/member-2.C: Likewise. * g++.dg/gomp/predetermined-1.C: Likewise. * g++.dg/gomp/private-1.C: Likewise. * g++.dg/gomp/sharing-1.C: Likewise. * g++.dg/gomp/sharing-2.C: Likewise. Add a few tests with aggregate const static data member without mutable elements. * gcc.dg/gomp/for-4.c: Expected nonmonotonic functions in the dumps. * gcc.dg/gomp/for-5.c: Likewise. * gcc.dg/gomp/for-6.c: Change expected library call. * gcc.dg/gomp/pr39495-2.c (foo): Don't expect errors on !=. * gcc.dg/gomp/reduction-2.c: New test. * gcc.dg/gomp/simd-1.c: New test. * gcc.dg/gomp/teams-1.c: Adjust expected diagnostic lines. * g++.dg/gomp/atomic-18.C: New test. * g++.dg/gomp/atomic-19.C: New test. * g++.dg/gomp/atomic-5.C (f1): Adjust expected lines of read-only variable messages. Add another expected error. * g++.dg/gomp/critical-3.C: New test. * g++.dg/gomp/depend-iterator-1.C: New test. * g++.dg/gomp/depend-iterator-2.C: New test. * g++.dg/gomp/depobj-1.C: New test. * g++.dg/gomp/doacross-1.C: New test. * g++.dg/gomp/for-21.C: New test. * g++.dg/gomp/for-4.C: Expected nonmonotonic functions in the dumps. * g++.dg/gomp/for-5.C: Likewise. * g++.dg/gomp/for-6.C: Change expected library call. * g++.dg/gomp/loop-4.C: New test. * g++.dg/gomp/pr33372-1.C: Adjust location of the expected diagnostics. * g++.dg/gomp/pr33372-3.C: Likewise. * g++.dg/gomp/pr39495-2.C (foo): Don't expect errors on !=. * g++.dg/gomp/simd-2.C: New test. * g++.dg/gomp/tpl-atomic-2.C: Adjust expected diagnostic lines. include/ * gomp-constants.h (GOMP_TASK_FLAG_REDUCTION, GOMP_DEPEND_IN, GOMP_DEPEND_OUT, GOMP_DEPEND_INOUT, GOMP_DEPEND_MUTEXINOUTSET): Define. libgomp/ * affinity.c (gomp_display_affinity_place): New function. * affinity-fmt.c: New file. * alloc.c (gomp_aligned_alloc, gomp_aligned_free): New functions. * config/linux/affinity.c (gomp_display_affinity_place): New function. * config/nvptx/icv-device.c (omp_get_num_teams, omp_get_team_num): Move these functions to ... * config/nvptx/teams.c: ... here. New file. * config/nvptx/target.c (omp_pause_resource, omp_pause_resource_all): New functions. * config/nvptx/team.c (gomp_team_start, gomp_pause_host): New functions. * configure.ac: Check for aligned_alloc, posix_memalign, memalign and _aligned_malloc. (HAVE_UNAME, HAVE_GETHOSTNAME, HAVE_GETPID): Add new tests. * configure.tgt: Add -DUSING_INITIAL_EXEC_TLS to XCFLAGS for Linux. * env.c (gomp_display_affinity_var, gomp_affinity_format_var, gomp_affinity_format_len): New variables. (parse_schedule): Parse monotonic and nonmonotonic modifiers in OMP_SCHEDULE variable. Set GFS_MONOTONIC for monotonic schedules. (handle_omp_display_env): Display monotonic/nonmonotonic schedule modifiers. Display (non-default) chunk sizes. Print OMP_DISPLAY_AFFINITY and OMP_AFFINITY_FORMAT. (initialize_env): Don't call pthread_attr_setdetachstate. Handle OMP_DISPLAY_AFFINITY and OMP_AFFINITY_FORMAT env vars. * fortran.c: Include stdio.h and string.h. (omp_pause_resource, omp_pause_resource_all): Add ialias_redirect. (omp_get_schedule_, omp_get_schedule_8_): Mask off GFS_MONOTONIC bit. (omp_set_affinity_format_, omp_get_affinity_format_, omp_display_affinity_, omp_capture_affinity_, omp_pause_resource_, omp_pause_resource_all_): New functions. * icv.c (omp_set_schedule): Mask off omp_sched_monotonic bit in switch. * icv-device.c (omp_get_num_teams, omp_get_team_num): Move these functions to ... * teams.c: ... here. New file. * libgomp_g.h: Include gstdint.h. (GOMP_loop_nonmonotonic_runtime_start, GOMP_loop_maybe_nonmonotonic_runtime_start, GOMP_loop_start, GOMP_loop_ordered_start, GOMP_loop_nonmonotonic_runtime_next, GOMP_loop_maybe_nonmonotonic_runtime_next, GOMP_loop_doacross_start, GOMP_parallel_loop_nonmonotonic_runtime, GOMP_parallel_loop_maybe_nonmonotonic_runtime, GOMP_loop_ull_nonmonotonic_runtime_start, GOMP_loop_ull_maybe_nonmonotonic_runtime_start, GOMP_loop_ull_start, GOMP_loop_ull_ordered_start, GOMP_loop_ull_nonmonotonic_runtime_next, GOMP_loop_ull_maybe_nonmonotonic_runtime_next, GOMP_loop_ull_doacross_start, GOMP_parallel_reductions, GOMP_taskwait_depend, GOMP_taskgroup_reduction_register, GOMP_taskgroup_reduction_unregister, GOMP_task_reduction_remap, GOMP_workshare_task_reduction_unregister, GOMP_sections2_start, GOMP_teams_reg): Declare. * libgomp.h (GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC): Define unless gomp_aligned_alloc uses fallback implementation. (gomp_aligned_alloc, gomp_aligned_free): Declare. (enum gomp_schedule_type): Add GFS_MONOTONIC. (struct gomp_doacross_work_share): Add extra field. (struct gomp_work_share): Add task_reductions field. (struct gomp_taskgroup): Add workshare and reductions fields. (GOMP_NEEDS_THREAD_HANDLE): Define if needed. (gomp_thread_handle): New typedef. (gomp_display_affinity_place, gomp_set_affinity_format, gomp_display_string, gomp_display_affinity, gomp_display_affinity_thread): Declare. (gomp_doacross_init, gomp_doacross_ull_init): Add size_t argument. (gomp_parallel_reduction_register, gomp_workshare_taskgroup_start, gomp_workshare_task_reduction_register): Declare. (gomp_team_start): Add taskgroup argument. (gomp_pause_host): Declare. (gomp_init_work_share, gomp_work_share_start): Change bool argument to size_t. (gomp_thread_self, gomp_thread_to_pthread_t): New inline functions. * libgomp.map (GOMP_5.0): Export GOMP_loop_start, GOMP_loop_ordered_start, GOMP_loop_doacross_start, GOMP_loop_ull_start, GOMP_loop_ull_ordered_start, GOMP_loop_ull_doacross_start, GOMP_workshare_task_reduction_unregister, GOMP_sections2_start, GOMP_loop_maybe_nonmonotonic_runtime_next, GOMP_loop_maybe_nonmonotonic_runtime_start, GOMP_loop_nonmonotonic_runtime_next, GOMP_loop_nonmonotonic_runtime_start, GOMP_loop_ull_maybe_nonmonotonic_runtime_next, GOMP_loop_ull_maybe_nonmonotonic_runtime_start, GOMP_loop_ull_nonmonotonic_runtime_next, GOMP_loop_ull_nonmonotonic_runtime_start, GOMP_parallel_loop_maybe_nonmonotonic_runtime, GOMP_parallel_loop_nonmonotonic_runtime, GOMP_parallel_reductions, GOMP_taskgroup_reduction_register, GOMP_taskgroup_reduction_unregister, GOMP_task_reduction_remap, GOMP_teams_reg and GOMP_taskwait_depend. (OMP_5.0): Export omp_pause_resource{,_all}{,_}, omp_{capture,display}_affinity{,_}, and omp_[gs]et_affinity_format{,_}. * loop.c: Include string.h. (GOMP_loop_runtime_next): Add ialias. (GOMP_taskgroup_reduction_register): Add ialias_redirect. (gomp_loop_static_start, gomp_loop_dynamic_start, gomp_loop_guided_start, gomp_loop_ordered_static_start, gomp_loop_ordered_dynamic_start, gomp_loop_ordered_guided_start, gomp_loop_doacross_static_start, gomp_loop_doacross_dynamic_start, gomp_loop_doacross_guided_start): Adjust gomp_work_share_start or gomp_doacross_init callers. (gomp_adjust_sched, GOMP_loop_start, GOMP_loop_ordered_start, GOMP_loop_doacross_start): New functions. (GOMP_loop_runtime_start, GOMP_loop_ordered_runtime_start, GOMP_loop_doacross_runtime_start, GOMP_parallel_loop_runtime_start): Mask off GFS_MONOTONIC bit. (GOMP_loop_maybe_nonmonotonic_runtime_next, GOMP_loop_maybe_nonmonotonic_runtime_start, GOMP_loop_nonmonotonic_runtime_next, GOMP_loop_nonmonotonic_runtime_start, GOMP_parallel_loop_maybe_nonmonotonic_runtime, GOMP_parallel_loop_nonmonotonic_runtime): New aliases or wrapper functions. (gomp_parallel_loop_start): Pass NULL as taskgroup to gomp_team_start. * loop_ull.c: Include string.h. (GOMP_loop_ull_runtime_next): Add ialias. (GOMP_taskgroup_reduction_register): Add ialias_redirect. (gomp_loop_ull_static_start, gomp_loop_ull_dynamic_start, gomp_loop_ull_guided_start, gomp_loop_ull_ordered_static_start, gomp_loop_ull_ordered_dynamic_start, gomp_loop_ull_ordered_guided_start, gomp_loop_ull_doacross_static_start, gomp_loop_ull_doacross_dynamic_start, gomp_loop_ull_doacross_guided_start): Adjust gomp_work_share_start and gomp_doacross_ull_init callers. (gomp_adjust_sched, GOMP_loop_ull_start, GOMP_loop_ull_ordered_start, GOMP_loop_ull_doacross_start): New functions. (GOMP_loop_ull_runtime_start, GOMP_loop_ull_ordered_runtime_start, GOMP_loop_ull_doacross_runtime_start): Mask off GFS_MONOTONIC bit. (GOMP_loop_ull_maybe_nonmonotonic_runtime_next, GOMP_loop_ull_maybe_nonmonotonic_runtime_start, GOMP_loop_ull_nonmonotonic_runtime_next, GOMP_loop_ull_nonmonotonic_runtime_start): Likewise. * Makefile.am (libgomp_la_SOURCES): Add teams.c and affinity-fmt.c. * omp.h.in (enum omp_sched_t): Add omp_sched_monotonic. (omp_pause_resource_t, omp_depend_t): New typedefs. (enum omp_lock_hint_t): Renamed to ... (enum omp_sync_hint_t): ... this. Define omp_sync_hint_* enumerators using numbers and omp_lock_hint_* as their aliases. (omp_lock_hint_t): New typedef. Rename to ... (omp_sync_hint_t): ... this. (omp_init_lock_with_hint, omp_init_nest_lock_with_hint): Use omp_sync_hint_t instead of omp_lock_hint_t. (omp_pause_resource, omp_pause_resource_all, omp_set_affinity_format, omp_get_affinity_format, omp_display_affinity, omp_capture_affinity): Declare. (omp_target_is_present, omp_target_disassociate_ptr): Change first argument from void * to const void *. (omp_target_memcpy, omp_target_memcpy_rect): Change second argument from void * to const void *. (omp_target_associate_ptr): Change first and second arguments from void * to const void *. * omp_lib.f90.in (omp_pause_resource_kind, omp_pause_soft, omp_pause_hard): New parameters. (omp_pause_resource, omp_pause_resource_all, omp_set_affinity_format, omp_get_affinity_format, omp_display_affinity, omp_capture_affinity): New interfaces. * omp_lib.h.in (omp_pause_resource_kind, omp_pause_soft, omp_pause_hard): New parameters. (omp_pause_resource, omp_pause_resource_all, omp_set_affinity_format, omp_get_affinity_format, omp_display_affinity, omp_capture_affinity): New externals. * ordered.c (gomp_doacross_init, gomp_doacross_ull_init): Add EXTRA argument. If not needed to prepare array, if extra is 0, clear ws->doacross, otherwise allocate just doacross structure and extra payload. If array is needed, allocate also extra payload. (GOMP_doacross_post, GOMP_doacross_wait, GOMP_doacross_ull_post, GOMP_doacross_ull_wait): Handle doacross->array == NULL like doacross == NULL. * parallel.c (GOMP_parallel_start): Pass NULL as taskgroup to gomp_team_start. (GOMP_parallel): Likewise. Formatting fix. (GOMP_parallel_reductions): New function. (GOMP_cancellation_point): If taskgroup has workshare flag set, check cancelled of prev taskgroup if any. (GOMP_cancel): If taskgroup has workshare flag set, set cancelled on prev taskgroup if any. * sections.c: Include string.h. (GOMP_taskgroup_reduction_register): Add ialias_redirect. (GOMP_sections_start): Adjust gomp_work_share_start caller. (GOMP_sections2_start): New function. (GOMP_parallel_sections_start, GOMP_parallel_sections): Pass NULL as taskgroup to gomp_team_start. * single.c (GOMP_single_start, GOMP_single_copy_start): Adjust gomp_work_share_start callers. * target.c (GOMP_target_update_ext, GOMP_target_enter_exit_data): If taskgroup has workshare flag set, check cancelled on prev taskgroup if any. Guard all cancellation tests with gomp_cancel_var test. (omp_target_is_present, omp_target_disassociate_ptr): Change ptr argument from void * to const void *. (omp_target_memcpy): Change src argument from void * to const void *. (omp_target_memcpy_rect): Likewise. (omp_target_memcpy_rect_worker): Likewise. Use const char * casts instead of char * where needed. (omp_target_associate_ptr): Change host_ptr and device_ptr arguments from void * to const void *. (omp_pause_resource, omp_pause_resource_all): New functions. * task.c (gomp_task_handle_depend): Handle new depend array format in addition to the old. Handle mutexinoutset kinds the same as inout for now, handle unspecified kinds. (gomp_create_target_task): If taskgroup has workshare flag set, check cancelled on prev taskgroup if any. Guard all cancellation tests with gomp_cancel_var test. Handle new depend array format count in addition to the old. (GOMP_task): Likewise. Adjust function comment. (gomp_task_run_pre): If taskgroup has workshare flag set, check cancelled on prev taskgroup if any. Guard all cancellation tests with gomp_cancel_var test. (GOMP_taskwait_depend): New function. (gomp_task_maybe_wait_for_dependencies): Handle new depend array format in addition to the old. Handle mutexinoutset kinds the same as inout for now, handle unspecified kinds. Fix a function comment typo. (gomp_taskgroup_init): New function. (GOMP_taskgroup_start): Use it. (gomp_reduction_register, gomp_create_artificial_team, GOMP_taskgroup_reduction_register, GOMP_taskgroup_reduction_unregister, GOMP_task_reduction_remap, gomp_parallel_reduction_register, gomp_workshare_task_reduction_register, gomp_workshare_taskgroup_start, GOMP_workshare_task_reduction_unregister): New functions. * taskloop.c (GOMP_taskloop): If taskgroup has workshare flag set, check cancelled on prev taskgroup if any. Guard all cancellation tests with gomp_cancel_var test. Handle GOMP_TASK_FLAG_REDUCTION flag by calling GOMP_taskgroup_reduction_register. * team.c (gomp_thread_attr): Remove comment. (struct gomp_thread_start_data): Add handle field. (gomp_thread_start): Call pthread_detach. (gomp_new_team): Adjust gomp_init_work_share caller. (gomp_free_pool_helper): Call pthread_detach. (gomp_team_start): Add taskgroup argument, initialize implicit tasks' taskgroup field to that. Don't call pthread_attr_setdetachstate. Handle OMP_DISPLAY_AFFINITY env var. (gomp_team_end): Determine nesting by thr->ts.level != 0 rather than thr->ts.team != NULL. (gomp_pause_pool_helper, gomp_pause_host): New functions. * work.c (alloc_work_share): Use gomp_aligned_alloc instead of gomp_malloc if GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC is defined. (gomp_init_work_share): Change ORDERED argument from bool to size_t, if more than 1 allocate also extra payload at the end of array. Never keep ordered_team_ids NULL, set it to inline_ordered_team_ids instead. (gomp_work_share_start): Change ORDERED argument from bool to size_t, return true instead of ws. * Makefile.in: Regenerated. * configure: Regenerated. * config.h.in: Regenerated. * testsuite/libgomp.c/cancel-for-2.c (foo): Use cancel modifier in some cases. * testsuite/libgomp.c-c++-common/cancel-parallel-1.c: New test. * testsuite/libgomp.c-c++-common/cancel-taskgroup-3.c: New test. * testsuite/libgomp.c-c++-common/depend-iterator-1.c: New test. * testsuite/libgomp.c-c++-common/depend-iterator-2.c: New test. * testsuite/libgomp.c-c++-common/depend-mutexinout-1.c: New test. * testsuite/libgomp.c-c++-common/depend-mutexinout-2.c: New test. * testsuite/libgomp.c-c++-common/depobj-1.c: New test. * testsuite/libgomp.c-c++-common/display-affinity-1.c: New test. * testsuite/libgomp.c-c++-common/for-10.c: New test. * testsuite/libgomp.c-c++-common/for-11.c: New test. * testsuite/libgomp.c-c++-common/for-12.c: New test. * testsuite/libgomp.c-c++-common/for-13.c: New test. * testsuite/libgomp.c-c++-common/for-14.c: New test. * testsuite/libgomp.c-c++-common/for-15.c: New test. * testsuite/libgomp.c-c++-common/for-2.h: If CONDNE macro is defined, define a different N(test), don't define N(f0) to N(f14), but instead define N(f20) to N(f34) using != comparisons. * testsuite/libgomp.c-c++-common/for-7.c: New test. * testsuite/libgomp.c-c++-common/for-8.c: New test. * testsuite/libgomp.c-c++-common/for-9.c: New test. * testsuite/libgomp.c-c++-common/master-combined-1.c: New test. * testsuite/libgomp.c-c++-common/pause-1.c: New test. * testsuite/libgomp.c-c++-common/pause-2.c: New test. * testsuite/libgomp.c-c++-common/pr66199-10.c: New test. * testsuite/libgomp.c-c++-common/pr66199-11.c: New test. * testsuite/libgomp.c-c++-common/pr66199-12.c: New test. * testsuite/libgomp.c-c++-common/pr66199-13.c: New test. * testsuite/libgomp.c-c++-common/pr66199-14.c: New test. * testsuite/libgomp.c-c++-common/simd-1.c: New test. * testsuite/libgomp.c-c++-common/taskloop-reduction-1.c: New test. * testsuite/libgomp.c-c++-common/taskloop-reduction-2.c: New test. * testsuite/libgomp.c-c++-common/taskloop-reduction-3.c: New test. * testsuite/libgomp.c-c++-common/taskloop-reduction-4.c: New test. * testsuite/libgomp.c-c++-common/task-reduction-11.c: New test. * testsuite/libgomp.c-c++-common/task-reduction-12.c: New test. * testsuite/libgomp.c-c++-common/task-reduction-1.c: New test. * testsuite/libgomp.c-c++-common/task-reduction-2.c: New test. * testsuite/libgomp.c-c++-common/task-reduction-3.c: New test. * testsuite/libgomp.c-c++-common/task-reduction-4.c: New test. * testsuite/libgomp.c-c++-common/task-reduction-5.c: New test. * testsuite/libgomp.c-c++-common/task-reduction-6.c: New test. * testsuite/libgomp.c-c++-common/task-reduction-7.c: New test. * testsuite/libgomp.c-c++-common/task-reduction-8.c: New test. * testsuite/libgomp.c-c++-common/task-reduction-9.c: New test. * testsuite/libgomp.c-c++-common/taskwait-depend-1.c: New test. * testsuite/libgomp.c++/depend-1.C: New test. * testsuite/libgomp.c++/depend-iterator-1.C: New test. * testsuite/libgomp.c++/depobj-1.C: New test. * testsuite/libgomp.c++/for-16.C: New test. * testsuite/libgomp.c++/for-21.C: New test. * testsuite/libgomp.c++/for-22.C: New test. * testsuite/libgomp.c++/for-23.C: New test. * testsuite/libgomp.c++/for-24.C: New test. * testsuite/libgomp.c++/for-25.C: New test. * testsuite/libgomp.c++/for-26.C: New test. * testsuite/libgomp.c++/taskloop-reduction-1.C: New test. * testsuite/libgomp.c++/taskloop-reduction-2.C: New test. * testsuite/libgomp.c++/taskloop-reduction-3.C: New test. * testsuite/libgomp.c++/taskloop-reduction-4.C: New test. * testsuite/libgomp.c++/task-reduction-10.C: New test. * testsuite/libgomp.c++/task-reduction-11.C: New test. * testsuite/libgomp.c++/task-reduction-12.C: New test. * testsuite/libgomp.c++/task-reduction-13.C: New test. * testsuite/libgomp.c++/task-reduction-14.C: New test. * testsuite/libgomp.c++/task-reduction-15.C: New test. * testsuite/libgomp.c++/task-reduction-16.C: New test. * testsuite/libgomp.c++/task-reduction-17.C: New test. * testsuite/libgomp.c++/task-reduction-18.C: New test. * testsuite/libgomp.c++/task-reduction-19.C: New test. * testsuite/libgomp.c/task-reduction-1.c: New test. * testsuite/libgomp.c++/task-reduction-1.C: New test. * testsuite/libgomp.c/task-reduction-2.c: New test. * testsuite/libgomp.c++/task-reduction-2.C: New test. * testsuite/libgomp.c++/task-reduction-3.C: New test. * testsuite/libgomp.c++/task-reduction-4.C: New test. * testsuite/libgomp.c++/task-reduction-5.C: New test. * testsuite/libgomp.c++/task-reduction-6.C: New test. * testsuite/libgomp.c++/task-reduction-7.C: New test. * testsuite/libgomp.c++/task-reduction-8.C: New test. * testsuite/libgomp.c++/task-reduction-9.C: New test. * testsuite/libgomp.c/teams-1.c: New test. * testsuite/libgomp.c/teams-2.c: New test. * testsuite/libgomp.c/thread-limit-4.c: New test. * testsuite/libgomp.c/thread-limit-5.c: New test. * testsuite/libgomp.fortran/display-affinity-1.f90: New test. From-SVN: r265930
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog164
-rw-r--r--gcc/cp/constexpr.c1
-rw-r--r--gcc/cp/cp-gimplify.c10
-rw-r--r--gcc/cp/cp-objcp-common.c1
-rw-r--r--gcc/cp/cp-tree.def5
-rw-r--r--gcc/cp/cp-tree.h28
-rw-r--r--gcc/cp/cxx-pretty-print.c36
-rw-r--r--gcc/cp/dump.c6
-rw-r--r--gcc/cp/lex.c2
-rw-r--r--gcc/cp/parser.c1475
-rw-r--r--gcc/cp/pt.c299
-rw-r--r--gcc/cp/semantics.c813
12 files changed, 2491 insertions, 349 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 79cc673..1497dab 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,167 @@
+2018-11-08 Jakub Jelinek <jakub@redhat.com>
+
+ * constexpr.c (potential_constant_expression_1): Handle OMP_DEPOBJ.
+ * cp-gimplify.c (cp_genericize_r): Handle
+ OMP_CLAUSE_{IN,TASK}_REDUCTION.
+ (cxx_omp_predetermined_sharing_1): Don't return
+ OMP_CLAUSE_DEFAULT_SHARED for const qualified decls with no mutable
+ member. Return OMP_CLAUSE_DEFAULT_FIRSTPRIVATE for this pointer.
+ * cp-objcp-common.c (cp_common_init_ts): Handle OMP_DEPOBJ.
+ * cp-tree.def (OMP_DEPOBJ): New tree code.
+ * cp-tree.h (OMP_ATOMIC_DEPENDENT_P): Return true also for first
+ argument being OMP_CLAUSE.
+ (OMP_DEPOBJ_DEPOBJ, OMP_DEPOBJ_CLAUSES): Define.
+ (cp_convert_omp_range_for, cp_finish_omp_range_for): Declare.
+ (finish_omp_atomic): Add LOC, CLAUSES and MO arguments. Remove
+ SEQ_CST argument.
+ (finish_omp_for_block): Declare.
+ (finish_omp_flush): Add MO argument.
+ (finish_omp_depobj): Declare.
+ * cxx-pretty-print.c (cxx_pretty_printer::statement): Handle
+ OMP_DEPOBJ.
+ * dump.c (cp_dump_tree): Likewise.
+ * lex.c (cxx_init): Likewise.
+ * parser.c: Include memmodel.h.
+ (cp_parser_for): Pass false as new is_omp argument to
+ cp_parser_range_for.
+ (cp_parser_range_for): Add IS_OMP argument, return before finalizing
+ if it is true.
+ (cp_parser_omp_clause_name): Handle nontemporal, in_reduction and
+ task_reduction clauses.
+ (cp_parser_omp_var_list_no_open): Handle
+ OMP_CLAUSE_{IN,TASK}_REDUCTION. For OMP_CLAUSE_DEPEND, parse clause
+ operands as either an array section, or lvalue assignment expression.
+ (cp_parser_omp_clause_if): Handle cancel and simd modifiers.
+ (cp_parser_omp_clause_defaultmap): Parse new kinds of defaultmap
+ clause.
+ (cp_parser_omp_clause_reduction): Add IS_OMP and KIND arguments.
+ Parse reduction modifiers. Pass KIND to c_parser_omp_variable_list.
+ (cp_parser_omp_clause_lastprivate, cp_parser_omp_iterators): New
+ functions.
+ (cp_parser_omp_clause_depend): Parse iterator modifier and handle
+ iterators. Parse mutexinoutset and depobj kinds.
+ (cp_parser_oacc_all_clauses): Adjust cp_parser_omp_clause_reduction
+ callers.
+ (cp_parser_omp_all_clauses): Likewise. Handle
+ PRAGMA_OMP_CLAUSE_NONTEMPORAL and
+ PRAGMA_OMP_CLAUSE_{IN,TASK}_REDUCTION. Call
+ cp_parser_omp_clause_lastprivate for OpenMP lastprivate clause.
+ (cp_parser_omp_atomic): Pass pragma_tok->location as
+ LOC to finish_omp_atomic. Parse hint and memory order clauses.
+ Handle default memory order from requires directive if any. Adjust
+ finish_omp_atomic caller.
+ (cp_parser_omp_critical): Allow comma in between (name) and hint
+ clause.
+ (cp_parser_omp_depobj): New function.
+ (cp_parser_omp_flush): Parse flush with memory-order-clause.
+ (cp_parser_omp_for_cond): Allow NE_EXPR even in OpenMP loops.
+ (cp_convert_omp_range_for, cp_finish_omp_range_for): New functions.
+ (cp_parser_omp_for_loop): Parse C++11 range for loops among omp
+ loops. Handle OMP_CLAUSE_IN_REDUCTION like OMP_CLAUSE_REDUCTION.
+ (OMP_SIMD_CLAUSE_MASK): Add if and nontemporal clauses.
+ (cp_parser_omp_simd, cp_parser_omp_for): Call keep_next_level before
+ begin_omp_structured_block and call finish_omp_for_block on
+ finish_omp_structured_block result.
+ (cp_parser_omp_master): Add p_name, mask and cclauses arguments.
+ Allow to be called while parsing combined parallel master.
+ Parse combined master taskloop{, simd}.
+ (cp_parser_omp_parallel): Parse combined
+ parallel master{, taskloop{, simd}} constructs.
+ (cp_parser_omp_single): Use SET_EXPR_LOCATION.
+ (OMP_TASK_CLAUSE_MASK): Add in_reduction clause.
+ (OMP_TASKWAIT_CLAUSE_MASK): Define.
+ (cp_parser_omp_taskwait): Handle taskwait with depend clauses.
+ (OMP_TASKGROUP_CLAUSE_MASK): Define.
+ (cp_parser_omp_taskgroup): Parse taskgroup clauses, adjust
+ c_finish_omp_taskgroup caller.
+ (cp_parser_omp_distribute): Call keep_next_level before
+ begin_omp_structured_block and call finish_omp_for_block on
+ finish_omp_structured_block result.
+ (cp_parser_omp_teams): Force a BIND_EXPR with BLOCK around teams
+ body.
+ (cp_parser_omp_target_data): Allow target data with only
+ use_device_ptr clauses.
+ (cp_parser_omp_target): Set OMP_REQUIRES_TARGET_USED bit in
+ omp_requires_mask.
+ (cp_parser_omp_requires): New function.
+ (OMP_TASKLOOP_CLAUSE_MASK): Add reduction and in_reduction clauses.
+ (cp_parser_omp_taskloop): Add forward declaration. Disallow
+ in_reduction clause when combined with parallel master. Call
+ keep_next_level before begin_omp_structured_block and call
+ finish_omp_for_block on finish_omp_structured_block result.
+ (cp_parser_omp_construct): Adjust cp_parser_omp_master caller.
+ (cp_parser_pragma): Handle PRAGMA_OMP_DEPOBJ and PRAGMA_OMP_REQUIRES.
+ * pt.c (tsubst_omp_clause_decl): Add iterators_cache argument.
+ Adjust recursive calls. Handle iterators.
+ (tsubst_omp_clauses): Handle OMP_CLAUSE_{IN,TASK}_REDUCTION and
+ OMP_CLAUSE_NONTEMPORAL. Adjust tsubst_omp_clause_decl callers.
+ (tsubst_decomp_names):
+ (tsubst_omp_for_iterator): Change orig_declv into a reference.
+ Handle range for loops. Move orig_declv handling after declv/initv
+ handling.
+ (tsubst_expr): Force a BIND_EXPR with BLOCK around teams body.
+ Adjust finish_omp_atomic caller. Call keep_next_level before
+ begin_omp_structured_block. Call cp_finish_omp_range_for for range
+ for loops and use {begin,finish}_omp_structured_block instead of
+ {push,pop}_stmt_list if there are any range for loops. Call
+ finish_omp_for_block on finish_omp_structured_block result.
+ Handle OMP_DEPOBJ. Handle taskwait with depend clauses. For
+ OMP_ATOMIC call tsubst_omp_clauses on clauses if any, adjust
+ finish_omp_atomic caller. Use OMP_ATOMIC_MEMORY_ORDER rather
+ than OMP_ATOMIC_SEQ_CST. Handle clauses on OMP_TASKGROUP.
+ (dependent_omp_for_p): Always return true for range for loops if
+ processing_template_decl. Return true if class type iterator
+ does not have INTEGER_CST increment.
+ * semantics.c: Include memmodel.h.
+ (handle_omp_array_sections_1): Handle OMP_CLAUSE_{IN,TASK}_REDUCTION
+ like OMP_CLAUSE_REDUCTION.
+ (handle_omp_array_sections): Likewise. Call save_expr on array
+ reductions before calling build_index_type. Handle depend clauses
+ with iterators.
+ (finish_omp_reduction_clause): Call save_expr for whole array
+ reduction sizes. Don't mark OMP_CLAUSE_DECL addressable if it has
+ reference type. Do mark decl_placeholder addressable if needed.
+ Use error_at with OMP_CLAUSE_LOCATION (c) as first argument instead
+ of error.
+ (cp_omp_finish_iterators): New function.
+ (finish_omp_clauses): Don't diagnose nonmonotonic clause with static,
+ runtime or auto schedule kinds. Diagnose nogroup clause used with
+ reduction clause(s). Handle depend clause with
+ OMP_CLAUSE_DEPEND_DEPOBJ. Diagnose bit-fields. Require
+ omp_depend_t type for OMP_CLAUSE_DEPEND_DEPOBJ kinds and
+ some different type for other kinds. Use cp_build_addr_expr
+ and cp_build_indirect_ref instead of cxx_mark_addressable.
+ Handle depend clauses with iterators. Only handle static data members
+ in the special case that const qualified vars may be specified in
+ firstprivate clause. Complain if const qualified vars without mutable
+ members are mentioned in data-sharing clauses other than firstprivate
+ or shared. Use error_at with OMP_CLAUSE_LOCATION (c) as first
+ argument instead of error. Diagnose more than one nontemporal clause
+ refering to the same variable. Use error_at rather than error for
+ priority and hint clause diagnostics. Fix pasto for hint clause.
+ Diagnose hint expression that doesn't fold into INTEGER_CST.
+ Diagnose if clause with modifier other than cancel. Handle
+ OMP_CLAUSE_{IN,TASK}_REDUCTION like OMP_CLAUSE_REDUCTION. Allow any
+ lvalue as OMP_CLAUSE_DEPEND operand (besides array section), adjust
+ diagnostics.
+ (handle_omp_for_class_iterator): Don't create a new TREE_LIST if one
+ has been created already for range for, just fill TREE_PURPOSE and
+ TREE_VALUE. Call cp_fully_fold on incr.
+ (finish_omp_for): Don't check cond/incr if cond is global_namespace.
+ Pass to c_omp_check_loop_iv_exprs orig_declv if non-NULL. Don't
+ use IS_EMPTY_STMT on NULL pre_body. Adjust c_finish_omp_for caller.
+ (finish_omp_for_block): New function.
+ (finish_omp_atomic): Add LOC argument, pass it through
+ to c_finish_omp_atomic and set it as location of OMP_ATOMIC* trees.
+ Remove SEQ_CST argument. Add CLAUSES and MO arguments. Adjust
+ c_finish_omp_atomic caller. Stick clauses if any into first argument
+ of wrapping OMP_ATOMIC.
+ (finish_omp_depobj): New function.
+ (finish_omp_flush): Add MO argument, if not
+ MEMMODEL_LAST, emit __atomic_thread_fence call with the given value.
+ (finish_omp_cancel): Diagnose if clause with modifier other than
+ cancel.
+
2018-11-07 Nathan Sidwell <nathan@acm.org>
PR c++/87904
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 4fb1ba5..7b696da 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -5917,6 +5917,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now,
case OMP_ATOMIC_READ:
case OMP_ATOMIC_CAPTURE_OLD:
case OMP_ATOMIC_CAPTURE_NEW:
+ case OMP_DEPOBJ:
case OACC_PARALLEL:
case OACC_KERNELS:
case OACC_DATA:
diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index 90a8f9f..eb761b1 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -1178,6 +1178,8 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data)
*walk_subtrees = 0;
break;
case OMP_CLAUSE_REDUCTION:
+ case OMP_CLAUSE_IN_REDUCTION:
+ case OMP_CLAUSE_TASK_REDUCTION:
/* Don't dereference an invisiref in reduction clause's
OMP_CLAUSE_DECL either. OMP_CLAUSE_REDUCTION_{INIT,MERGE}
still needs to be genericized. */
@@ -1986,10 +1988,10 @@ cxx_omp_predetermined_sharing_1 (tree decl)
return OMP_CLAUSE_DEFAULT_SHARED;
}
- /* Const qualified vars having no mutable member are predetermined
- shared. */
- if (cxx_omp_const_qual_no_mutable (decl))
- return OMP_CLAUSE_DEFAULT_SHARED;
+ /* this may not be specified in data-sharing clauses, still we need
+ to predetermined it firstprivate. */
+ if (decl == current_class_ptr)
+ return OMP_CLAUSE_DEFAULT_FIRSTPRIVATE;
return OMP_CLAUSE_DEFAULT_UNSPECIFIED;
}
diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c
index eef7ed6..584f428 100644
--- a/gcc/cp/cp-objcp-common.c
+++ b/gcc/cp/cp-objcp-common.c
@@ -446,6 +446,7 @@ cp_common_init_ts (void)
MARK_TS_TYPED (UNARY_RIGHT_FOLD_EXPR);
MARK_TS_TYPED (BINARY_LEFT_FOLD_EXPR);
MARK_TS_TYPED (BINARY_RIGHT_FOLD_EXPR);
+ MARK_TS_TYPED (OMP_DEPOBJ);
}
#include "gt-cp-cp-objcp-common.h"
diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def
index c64225d..43d90eb 100644
--- a/gcc/cp/cp-tree.def
+++ b/gcc/cp/cp-tree.def
@@ -499,6 +499,11 @@ DEFTREECODE (BASES, "bases", tcc_type, 0)
instantiation time. */
DEFTREECODE (TEMPLATE_INFO, "template_info", tcc_exceptional, 0)
+/* OpenMP - #pragma omp depobj
+ Operand 0: OMP_DEPOBJ_DEPOBJ: Depobj expression
+ Operand 1: OMP_DEPOBJ_CLAUSES: List of clauses. */
+DEFTREECODE (OMP_DEPOBJ, "omp_depobj", tcc_statement, 2)
+
/* Extensions for Concepts. */
/* Used to represent information associated with constrained declarations. */
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 91f5755..6ca138d 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -4874,9 +4874,10 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
(TREE_LANG_FLAG_1 (SCOPE_REF_CHECK (NODE)))
/* True for an OMP_ATOMIC that has dependent parameters. These are stored
- as an expr in operand 1, and integer_zero_node in operand 0. */
+ as an expr in operand 1, and integer_zero_node or clauses in operand 0. */
#define OMP_ATOMIC_DEPENDENT_P(NODE) \
- (TREE_CODE (TREE_OPERAND (OMP_ATOMIC_CHECK (NODE), 0)) == INTEGER_CST)
+ (TREE_CODE (TREE_OPERAND (OMP_ATOMIC_CHECK (NODE), 0)) == INTEGER_CST \
+ || TREE_CODE (TREE_OPERAND (OMP_ATOMIC_CHECK (NODE), 0)) == OMP_CLAUSE)
/* Used while gimplifying continue statements bound to OMP_FOR nodes. */
#define OMP_FOR_GIMPLIFYING_P(NODE) \
@@ -5016,6 +5017,13 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
#define ALIGNOF_EXPR_STD_P(NODE) \
TREE_LANG_FLAG_0 (ALIGNOF_EXPR_CHECK (NODE))
+/* OMP_DEPOBJ accessors. These give access to the depobj expression of the
+ #pragma omp depobj directive and the clauses, respectively. If
+ OMP_DEPOBJ_CLAUSES is INTEGER_CST, it is instead the update clause kind
+ or OMP_CLAUSE_DEPEND_LAST for destroy clause. */
+#define OMP_DEPOBJ_DEPOBJ(NODE) TREE_OPERAND (OMP_DEPOBJ_CHECK (NODE), 0)
+#define OMP_DEPOBJ_CLAUSES(NODE) TREE_OPERAND (OMP_DEPOBJ_CHECK (NODE), 1)
+
/* An enumeration of the kind of tags that C++ accepts. */
enum tag_types {
none_type = 0, /* Not a tag type. */
@@ -6630,6 +6638,9 @@ extern bool maybe_clone_body (tree);
/* In parser.c */
extern tree cp_convert_range_for (tree, tree, tree, tree, unsigned int, bool,
unsigned short);
+extern void cp_convert_omp_range_for (tree &, vec<tree, va_gc> *, tree &,
+ tree &, tree &, tree &, tree &, tree &);
+extern void cp_finish_omp_range_for (tree, tree);
extern bool parsing_nsdmi (void);
extern bool parsing_default_capturing_generic_lambda_in_template (void);
extern void inject_this_parameter (tree, cp_cv_quals);
@@ -7054,11 +7065,16 @@ extern tree finish_omp_task (tree, tree);
extern tree finish_omp_for (location_t, enum tree_code,
tree, tree, tree, tree, tree,
tree, tree, vec<tree> *, tree);
-extern void finish_omp_atomic (enum tree_code, enum tree_code,
- tree, tree, tree, tree, tree,
- bool);
+extern tree finish_omp_for_block (tree, tree);
+extern void finish_omp_atomic (location_t, enum tree_code,
+ enum tree_code, tree, tree,
+ tree, tree, tree, tree,
+ enum omp_memory_order);
extern void finish_omp_barrier (void);
-extern void finish_omp_flush (void);
+extern void finish_omp_depobj (location_t, tree,
+ enum omp_clause_depend_kind,
+ tree);
+extern void finish_omp_flush (int);
extern void finish_omp_taskwait (void);
extern void finish_omp_taskyield (void);
extern void finish_omp_cancel (tree);
diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c
index c138c50..b79ff51 100644
--- a/gcc/cp/cxx-pretty-print.c
+++ b/gcc/cp/cxx-pretty-print.c
@@ -2112,6 +2112,42 @@ cxx_pretty_printer::statement (tree t)
declaration (t);
break;
+ case OMP_DEPOBJ:
+ pp_cxx_ws_string (this, "#pragma omp depobj");
+ pp_space (this);
+ pp_cxx_left_paren (this);
+ expression (OMP_DEPOBJ_DEPOBJ (t));
+ pp_cxx_right_paren (this);
+ if (OMP_DEPOBJ_CLAUSES (t) && OMP_DEPOBJ_CLAUSES (t) != error_mark_node)
+ {
+ if (TREE_CODE (OMP_DEPOBJ_CLAUSES (t)) == OMP_CLAUSE)
+ dump_omp_clauses (this, OMP_DEPOBJ_CLAUSES (t),
+ pp_indentation (this), TDF_NONE);
+ else
+ switch (tree_to_uhwi (OMP_DEPOBJ_CLAUSES (t)))
+ {
+ case OMP_CLAUSE_DEPEND_IN:
+ pp_cxx_ws_string (this, " update(in)");
+ break;
+ case OMP_CLAUSE_DEPEND_INOUT:
+ pp_cxx_ws_string (this, " update(inout)");
+ break;
+ case OMP_CLAUSE_DEPEND_OUT:
+ pp_cxx_ws_string (this, " update(out)");
+ break;
+ case OMP_CLAUSE_DEPEND_MUTEXINOUTSET:
+ pp_cxx_ws_string (this, " update(mutexinoutset)");
+ break;
+ case OMP_CLAUSE_DEPEND_LAST:
+ pp_cxx_ws_string (this, " destroy");
+ break;
+ default:
+ break;
+ }
+ }
+ pp_needs_newline (this) = true;
+ break;
+
default:
c_pretty_printer::statement (t);
break;
diff --git a/gcc/cp/dump.c b/gcc/cp/dump.c
index d9b868b..1653886 100644
--- a/gcc/cp/dump.c
+++ b/gcc/cp/dump.c
@@ -328,6 +328,12 @@ cp_dump_tree (void* dump_info, tree t)
dump_child ("expr", EXPR_STMT_EXPR (t));
break;
+ case OMP_DEPOBJ:
+ dump_stmt (di, t);
+ dump_child ("depobj", OMP_DEPOBJ_DEPOBJ (t));
+ dump_child ("clauses", OMP_DEPOBJ_CLAUSES (t));
+ break;
+
default:
break;
}
diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c
index 26ec52f..49bcf51 100644
--- a/gcc/cp/lex.c
+++ b/gcc/cp/lex.c
@@ -293,7 +293,7 @@ cxx_init (void)
IF_STMT, CLEANUP_STMT, FOR_STMT,
RANGE_FOR_STMT, WHILE_STMT, DO_STMT,
BREAK_STMT, CONTINUE_STMT, SWITCH_STMT,
- EXPR_STMT
+ EXPR_STMT, OMP_DEPOBJ
};
memset (&statement_code_p, 0, sizeof (statement_code_p));
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 30a4766..deaca5c 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -44,6 +44,7 @@ along with GCC; see the file COPYING3. If not see
#include "gcc-rich-location.h"
#include "tree-iterator.h"
#include "cp-name-hint.h"
+#include "memmodel.h"
/* The lexer. */
@@ -2110,7 +2111,7 @@ static tree cp_parser_for
static tree cp_parser_c_for
(cp_parser *, tree, tree, bool, unsigned short);
static tree cp_parser_range_for
- (cp_parser *, tree, tree, tree, bool, unsigned short);
+ (cp_parser *, tree, tree, tree, bool, unsigned short, bool);
static void do_range_for_auto_deduction
(tree, tree);
static tree cp_parser_perform_range_for_lookup
@@ -11843,7 +11844,8 @@ cp_parser_for (cp_parser *parser, bool ivdep, unsigned short unroll)
is_range_for = cp_parser_init_statement (parser, &decl);
if (is_range_for)
- return cp_parser_range_for (parser, scope, init, decl, ivdep, unroll);
+ return cp_parser_range_for (parser, scope, init, decl, ivdep, unroll,
+ false);
else
return cp_parser_c_for (parser, scope, init, ivdep, unroll);
}
@@ -11901,7 +11903,7 @@ cp_parser_c_for (cp_parser *parser, tree scope, tree init, bool ivdep,
static tree
cp_parser_range_for (cp_parser *parser, tree scope, tree init, tree range_decl,
- bool ivdep, unsigned short unroll)
+ bool ivdep, unsigned short unroll, bool is_omp)
{
tree stmt, range_expr;
auto_vec <cxx_binding *, 16> bindings;
@@ -11961,6 +11963,11 @@ cp_parser_range_for (cp_parser *parser, tree scope, tree init, tree range_decl,
IDENTIFIER_BINDING (names[i]) = binding;
}
+ /* finish_omp_for has its own code for the following, so just
+ return the range_expr instead. */
+ if (is_omp)
+ return range_expr;
+
/* If in template, STMT is converted to a normal for-statement
at instantiation. If not, it is done just ahead. */
if (processing_template_decl)
@@ -31490,7 +31497,7 @@ cp_parser_objc_at_dynamic_declaration (cp_parser *parser)
}
-/* OpenMP 2.5 / 3.0 / 3.1 / 4.0 parsing routines. */
+/* OpenMP 2.5 / 3.0 / 3.1 / 4.0 / 4.5 / 5.0 parsing routines. */
/* Returns name of the next clause.
If the clause is not recognized PRAGMA_OMP_CLAUSE_NONE is returned and
@@ -31580,6 +31587,8 @@ cp_parser_omp_clause_name (cp_parser *parser)
case 'i':
if (!strcmp ("if_present", p))
result = PRAGMA_OACC_CLAUSE_IF_PRESENT;
+ else if (!strcmp ("in_reduction", p))
+ result = PRAGMA_OMP_CLAUSE_IN_REDUCTION;
else if (!strcmp ("inbranch", p))
result = PRAGMA_OMP_CLAUSE_INBRANCH;
else if (!strcmp ("independent", p))
@@ -31604,6 +31613,8 @@ cp_parser_omp_clause_name (cp_parser *parser)
case 'n':
if (!strcmp ("nogroup", p))
result = PRAGMA_OMP_CLAUSE_NOGROUP;
+ else if (!strcmp ("nontemporal", p))
+ result = PRAGMA_OMP_CLAUSE_NONTEMPORAL;
else if (!strcmp ("notinbranch", p))
result = PRAGMA_OMP_CLAUSE_NOTINBRANCH;
else if (!strcmp ("nowait", p))
@@ -31668,7 +31679,9 @@ cp_parser_omp_clause_name (cp_parser *parser)
result = PRAGMA_OMP_CLAUSE_SIMDLEN;
break;
case 't':
- if (!strcmp ("taskgroup", p))
+ if (!strcmp ("task_reduction", p))
+ result = PRAGMA_OMP_CLAUSE_TASK_REDUCTION;
+ else if (!strcmp ("taskgroup", p))
result = PRAGMA_OMP_CLAUSE_TASKGROUP;
else if (!strcmp ("thread_limit", p))
result = PRAGMA_OMP_CLAUSE_THREAD_LIMIT;
@@ -31759,6 +31772,8 @@ cp_parser_omp_var_list_no_open (cp_parser *parser, enum omp_clause_code kind,
{
tree name, decl;
+ if (kind == OMP_CLAUSE_DEPEND)
+ cp_parser_parse_tentatively (parser);
token = cp_lexer_peek_token (parser->lexer);
if (kind != 0
&& current_class_ptr
@@ -31778,15 +31793,25 @@ cp_parser_omp_var_list_no_open (cp_parser *parser, enum omp_clause_code kind,
/*declarator_p=*/false,
/*optional_p=*/false);
if (name == error_mark_node)
- goto skip_comma;
+ {
+ if (kind == OMP_CLAUSE_DEPEND
+ && cp_parser_simulate_error (parser))
+ goto depend_lvalue;
+ goto skip_comma;
+ }
if (identifier_p (name))
decl = cp_parser_lookup_name_simple (parser, name, token->location);
else
decl = name;
if (decl == error_mark_node)
- cp_parser_name_lookup_error (parser, name, decl, NLE_NULL,
- token->location);
+ {
+ if (kind == OMP_CLAUSE_DEPEND
+ && cp_parser_simulate_error (parser))
+ goto depend_lvalue;
+ cp_parser_name_lookup_error (parser, name, decl, NLE_NULL,
+ token->location);
+ }
}
if (decl == error_mark_node)
;
@@ -31822,6 +31847,8 @@ cp_parser_omp_var_list_no_open (cp_parser *parser, enum omp_clause_code kind,
/* FALLTHROUGH. */
case OMP_CLAUSE_DEPEND:
case OMP_CLAUSE_REDUCTION:
+ case OMP_CLAUSE_IN_REDUCTION:
+ case OMP_CLAUSE_TASK_REDUCTION:
while (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_SQUARE))
{
tree low_bound = NULL_TREE, length = NULL_TREE;
@@ -31839,7 +31866,14 @@ cp_parser_omp_var_list_no_open (cp_parser *parser, enum omp_clause_code kind,
{
/* Look for `:'. */
if (!cp_parser_require (parser, CPP_COLON, RT_COLON))
- goto skip_comma;
+ {
+ if (kind == OMP_CLAUSE_DEPEND
+ && cp_parser_simulate_error (parser))
+ goto depend_lvalue;
+ goto skip_comma;
+ }
+ if (kind == OMP_CLAUSE_DEPEND)
+ cp_parser_commit_to_tentative_parse (parser);
if (!cp_lexer_next_token_is (parser->lexer,
CPP_CLOSE_SQUARE))
length = cp_parser_expression (parser);
@@ -31847,7 +31881,12 @@ cp_parser_omp_var_list_no_open (cp_parser *parser, enum omp_clause_code kind,
/* Look for the closing `]'. */
if (!cp_parser_require (parser, CPP_CLOSE_SQUARE,
RT_CLOSE_SQUARE))
- goto skip_comma;
+ {
+ if (kind == OMP_CLAUSE_DEPEND
+ && cp_parser_simulate_error (parser))
+ goto depend_lvalue;
+ goto skip_comma;
+ }
decl = tree_cons (low_bound, length, decl);
}
@@ -31856,6 +31895,21 @@ cp_parser_omp_var_list_no_open (cp_parser *parser, enum omp_clause_code kind,
break;
}
+ if (kind == OMP_CLAUSE_DEPEND)
+ {
+ if (cp_lexer_next_token_is_not (parser->lexer, CPP_COMMA)
+ && cp_lexer_next_token_is_not (parser->lexer, CPP_CLOSE_PAREN)
+ && cp_parser_simulate_error (parser))
+ {
+ depend_lvalue:
+ cp_parser_abort_tentative_parse (parser);
+ decl = cp_parser_assignment_expression (parser, NULL,
+ false, false);
+ }
+ else
+ cp_parser_parse_definitely (parser);
+ }
+
tree u = build_omp_clause (token->location, kind);
OMP_CLAUSE_DECL (u) = decl;
OMP_CLAUSE_CHAIN (u) = list;
@@ -32440,7 +32494,11 @@ cp_parser_omp_clause_final (cp_parser *parser, tree list, location_t location)
directive-name-modifier:
parallel | task | taskloop | target data | target | target update
- | target enter data | target exit data */
+ | target enter data | target exit data
+
+ OpenMP 5.0:
+ directive-name-modifier:
+ ... | simd | cancel */
static tree
cp_parser_omp_clause_if (cp_parser *parser, tree list, location_t location,
@@ -32459,8 +32517,12 @@ cp_parser_omp_clause_if (cp_parser *parser, tree list, location_t location,
const char *p = IDENTIFIER_POINTER (id);
int n = 2;
- if (strcmp ("parallel", p) == 0)
+ if (strcmp ("cancel", p) == 0)
+ if_modifier = VOID_CST;
+ else if (strcmp ("parallel", p) == 0)
if_modifier = OMP_PARALLEL;
+ else if (strcmp ("simd", p) == 0)
+ if_modifier = OMP_SIMD;
else if (strcmp ("task", p) == 0)
if_modifier = OMP_TASK;
else if (strcmp ("taskloop", p) == 0)
@@ -32547,7 +32609,9 @@ cp_parser_omp_clause_if (cp_parser *parser, tree list, location_t location,
const char *p = NULL;
switch (if_modifier)
{
+ case VOID_CST: p = "cancel"; break;
case OMP_PARALLEL: p = "parallel"; break;
+ case OMP_SIMD: p = "simd"; break;
case OMP_TASK: p = "task"; break;
case OMP_TASKLOOP: p = "taskloop"; break;
case OMP_TARGET_DATA: p = "target data"; break;
@@ -32774,7 +32838,10 @@ cp_parser_omp_clause_hint (cp_parser *parser, tree list,
}
/* OpenMP 4.5:
- defaultmap ( tofrom : scalar ) */
+ defaultmap ( tofrom : scalar )
+
+ OpenMP 5.0:
+ defaultmap ( implicit-behavior [ : variable-category ] ) */
static tree
cp_parser_omp_clause_defaultmap (cp_parser *parser, tree list,
@@ -32782,47 +32849,163 @@ cp_parser_omp_clause_defaultmap (cp_parser *parser, tree list,
{
tree c, id;
const char *p;
+ enum omp_clause_defaultmap_kind behavior = OMP_CLAUSE_DEFAULTMAP_DEFAULT;
+ enum omp_clause_defaultmap_kind category
+ = OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED;
matching_parens parens;
if (!parens.require_open (parser))
return list;
- if (!cp_lexer_next_token_is (parser->lexer, CPP_NAME))
+ if (cp_lexer_next_token_is_keyword (parser->lexer, RID_DEFAULT))
+ p = "default";
+ else if (!cp_lexer_next_token_is (parser->lexer, CPP_NAME))
{
- cp_parser_error (parser, "expected %<tofrom%>");
+ invalid_behavior:
+ cp_parser_error (parser, "expected %<alloc%>, %<to%>, %<from%>, "
+ "%<tofrom%>, %<firstprivate%>, %<none%> "
+ "or %<default%>");
goto out_err;
}
- id = cp_lexer_peek_token (parser->lexer)->u.value;
- p = IDENTIFIER_POINTER (id);
- if (strcmp (p, "tofrom") != 0)
+ else
{
- cp_parser_error (parser, "expected %<tofrom%>");
- goto out_err;
+ id = cp_lexer_peek_token (parser->lexer)->u.value;
+ p = IDENTIFIER_POINTER (id);
}
- cp_lexer_consume_token (parser->lexer);
- if (!cp_parser_require (parser, CPP_COLON, RT_COLON))
- goto out_err;
- if (!cp_lexer_next_token_is (parser->lexer, CPP_NAME))
+ switch (p[0])
{
- cp_parser_error (parser, "expected %<scalar%>");
- goto out_err;
+ case 'a':
+ if (strcmp ("alloc", p) == 0)
+ behavior = OMP_CLAUSE_DEFAULTMAP_ALLOC;
+ else
+ goto invalid_behavior;
+ break;
+
+ case 'd':
+ if (strcmp ("default", p) == 0)
+ behavior = OMP_CLAUSE_DEFAULTMAP_DEFAULT;
+ else
+ goto invalid_behavior;
+ break;
+
+ case 'f':
+ if (strcmp ("firstprivate", p) == 0)
+ behavior = OMP_CLAUSE_DEFAULTMAP_FIRSTPRIVATE;
+ else if (strcmp ("from", p) == 0)
+ behavior = OMP_CLAUSE_DEFAULTMAP_FROM;
+ else
+ goto invalid_behavior;
+ break;
+
+ case 'n':
+ if (strcmp ("none", p) == 0)
+ behavior = OMP_CLAUSE_DEFAULTMAP_NONE;
+ else
+ goto invalid_behavior;
+ break;
+
+ case 't':
+ if (strcmp ("tofrom", p) == 0)
+ behavior = OMP_CLAUSE_DEFAULTMAP_TOFROM;
+ else if (strcmp ("to", p) == 0)
+ behavior = OMP_CLAUSE_DEFAULTMAP_TO;
+ else
+ goto invalid_behavior;
+ break;
+
+ default:
+ goto invalid_behavior;
}
- id = cp_lexer_peek_token (parser->lexer)->u.value;
- p = IDENTIFIER_POINTER (id);
- if (strcmp (p, "scalar") != 0)
+ cp_lexer_consume_token (parser->lexer);
+
+ if (!cp_lexer_next_token_is (parser->lexer, CPP_CLOSE_PAREN))
{
- cp_parser_error (parser, "expected %<scalar%>");
- goto out_err;
+ if (!cp_parser_require (parser, CPP_COLON, RT_COLON))
+ goto out_err;
+
+ if (!cp_lexer_next_token_is (parser->lexer, CPP_NAME))
+ {
+ invalid_category:
+ cp_parser_error (parser, "expected %<scalar%>, %<aggregate%> or "
+ "%<pointer%>");
+ goto out_err;
+ }
+ id = cp_lexer_peek_token (parser->lexer)->u.value;
+ p = IDENTIFIER_POINTER (id);
+
+ switch (p[0])
+ {
+ case 'a':
+ if (strcmp ("aggregate", p) == 0)
+ category = OMP_CLAUSE_DEFAULTMAP_CATEGORY_AGGREGATE;
+ else
+ goto invalid_category;
+ break;
+
+ case 'p':
+ if (strcmp ("pointer", p) == 0)
+ category = OMP_CLAUSE_DEFAULTMAP_CATEGORY_POINTER;
+ else
+ goto invalid_category;
+ break;
+
+ case 's':
+ if (strcmp ("scalar", p) == 0)
+ category = OMP_CLAUSE_DEFAULTMAP_CATEGORY_SCALAR;
+ else
+ goto invalid_category;
+ break;
+
+ default:
+ goto invalid_category;
+ }
+
+ cp_lexer_consume_token (parser->lexer);
}
- cp_lexer_consume_token (parser->lexer);
if (!parens.require_close (parser))
goto out_err;
- check_no_duplicate_clause (list, OMP_CLAUSE_DEFAULTMAP, "defaultmap",
- location);
+ for (c = list; c ; c = OMP_CLAUSE_CHAIN (c))
+ if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEFAULTMAP
+ && (category == OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED
+ || OMP_CLAUSE_DEFAULTMAP_CATEGORY (c) == category
+ || (OMP_CLAUSE_DEFAULTMAP_CATEGORY (c)
+ == OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED)))
+ {
+ enum omp_clause_defaultmap_kind cat = category;
+ location_t loc = OMP_CLAUSE_LOCATION (c);
+ if (cat == OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED)
+ cat = OMP_CLAUSE_DEFAULTMAP_CATEGORY (c);
+ p = NULL;
+ switch (cat)
+ {
+ case OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED:
+ p = NULL;
+ break;
+ case OMP_CLAUSE_DEFAULTMAP_CATEGORY_AGGREGATE:
+ p = "aggregate";
+ break;
+ case OMP_CLAUSE_DEFAULTMAP_CATEGORY_POINTER:
+ p = "pointer";
+ break;
+ case OMP_CLAUSE_DEFAULTMAP_CATEGORY_SCALAR:
+ p = "scalar";
+ break;
+ default:
+ gcc_unreachable ();
+ }
+ if (p)
+ error_at (loc, "too many %<defaultmap%> clauses with %qs category",
+ p);
+ else
+ error_at (loc, "too many %<defaultmap%> clauses with unspecified "
+ "category");
+ break;
+ }
c = build_omp_clause (location, OMP_CLAUSE_DEFAULTMAP);
+ OMP_CLAUSE_DEFAULTMAP_SET_KIND (c, behavior, category);
OMP_CLAUSE_CHAIN (c) = list;
return c;
@@ -32897,17 +33080,50 @@ cp_parser_omp_clause_ordered (cp_parser *parser,
reduction-operator:
One of: + * - & ^ | && ||
- id-expression */
+ id-expression
+
+ OpenMP 5.0:
+ reduction ( reduction-modifier, reduction-operator : variable-list )
+ in_reduction ( reduction-operator : variable-list )
+ task_reduction ( reduction-operator : variable-list ) */
static tree
-cp_parser_omp_clause_reduction (cp_parser *parser, tree list)
+cp_parser_omp_clause_reduction (cp_parser *parser, enum omp_clause_code kind,
+ bool is_omp, tree list)
{
enum tree_code code = ERROR_MARK;
tree nlist, c, id = NULL_TREE;
+ bool task = false;
+ bool inscan = false;
if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN))
return list;
+ if (kind == OMP_CLAUSE_REDUCTION && is_omp)
+ {
+ if (cp_lexer_next_token_is_keyword (parser->lexer, RID_DEFAULT)
+ && cp_lexer_nth_token_is (parser->lexer, 2, CPP_COMMA))
+ {
+ cp_lexer_consume_token (parser->lexer);
+ cp_lexer_consume_token (parser->lexer);
+ }
+ else if (cp_lexer_next_token_is (parser->lexer, CPP_NAME)
+ && cp_lexer_nth_token_is (parser->lexer, 2, CPP_COMMA))
+ {
+ tree id = cp_lexer_peek_token (parser->lexer)->u.value;
+ const char *p = IDENTIFIER_POINTER (id);
+ if (strcmp (p, "task") == 0)
+ task = true;
+ else if (strcmp (p, "inscan") == 0)
+ inscan = true;
+ if (task || inscan)
+ {
+ cp_lexer_consume_token (parser->lexer);
+ cp_lexer_consume_token (parser->lexer);
+ }
+ }
+ }
+
switch (cp_lexer_peek_token (parser->lexer)->type)
{
case CPP_PLUS: code = PLUS_EXPR; break;
@@ -32980,11 +33196,15 @@ cp_parser_omp_clause_reduction (cp_parser *parser, tree list)
if (!cp_parser_require (parser, CPP_COLON, RT_COLON))
goto resync_fail;
- nlist = cp_parser_omp_var_list_no_open (parser, OMP_CLAUSE_REDUCTION, list,
+ nlist = cp_parser_omp_var_list_no_open (parser, kind, list,
NULL);
for (c = nlist; c != list; c = OMP_CLAUSE_CHAIN (c))
{
OMP_CLAUSE_REDUCTION_CODE (c) = code;
+ if (task)
+ OMP_CLAUSE_REDUCTION_TASK (c) = 1;
+ else if (inscan)
+ OMP_CLAUSE_REDUCTION_INSCAN (c) = 1;
OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) = id;
}
@@ -33303,6 +33523,43 @@ cp_parser_omp_clause_aligned (cp_parser *parser, tree list)
return nlist;
}
+/* OpenMP 2.5:
+ lastprivate ( variable-list )
+
+ OpenMP 5.0:
+ lastprivate ( [ lastprivate-modifier : ] variable-list ) */
+
+static tree
+cp_parser_omp_clause_lastprivate (cp_parser *parser, tree list)
+{
+ bool conditional = false;
+
+ if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN))
+ return list;
+
+ if (cp_lexer_next_token_is (parser->lexer, CPP_NAME)
+ && cp_lexer_nth_token_is (parser->lexer, 2, CPP_COLON))
+ {
+ tree id = cp_lexer_peek_token (parser->lexer)->u.value;
+ const char *p = IDENTIFIER_POINTER (id);
+
+ if (strcmp ("conditional", p) == 0)
+ {
+ conditional = true;
+ cp_lexer_consume_token (parser->lexer);
+ cp_lexer_consume_token (parser->lexer);
+ }
+ }
+
+ tree nlist = cp_parser_omp_var_list_no_open (parser, OMP_CLAUSE_LASTPRIVATE,
+ list, NULL);
+
+ if (conditional)
+ for (tree c = nlist; c != list; c = OMP_CLAUSE_CHAIN (c))
+ OMP_CLAUSE_LASTPRIVATE_CONDITIONAL (c) = 1;
+ return nlist;
+}
+
/* OpenMP 4.0:
linear ( variable-list )
linear ( variable-list : expression )
@@ -33545,6 +33802,118 @@ cp_parser_omp_clause_depend_sink (cp_parser *parser, location_t clause_loc,
return list;
}
+/* OpenMP 5.0:
+ iterators ( iterators-definition )
+
+ iterators-definition:
+ iterator-specifier
+ iterator-specifier , iterators-definition
+
+ iterator-specifier:
+ identifier = range-specification
+ iterator-type identifier = range-specification
+
+ range-specification:
+ begin : end
+ begin : end : step */
+
+static tree
+cp_parser_omp_iterators (cp_parser *parser)
+{
+ tree ret = NULL_TREE, *last = &ret;
+ cp_lexer_consume_token (parser->lexer);
+
+ matching_parens parens;
+ if (!parens.require_open (parser))
+ return error_mark_node;
+
+ bool saved_colon_corrects_to_scope_p
+ = parser->colon_corrects_to_scope_p;
+ bool saved_colon_doesnt_start_class_def_p
+ = parser->colon_doesnt_start_class_def_p;
+
+ do
+ {
+ tree iter_type;
+ if (cp_lexer_next_token_is (parser->lexer, CPP_NAME)
+ && cp_lexer_nth_token_is (parser->lexer, 2, CPP_EQ))
+ iter_type = integer_type_node;
+ else
+ {
+ const char *saved_message
+ = parser->type_definition_forbidden_message;
+ parser->type_definition_forbidden_message
+ = G_("types may not be defined in iterator type");
+
+ iter_type = cp_parser_type_id (parser);
+
+ parser->type_definition_forbidden_message = saved_message;
+ }
+
+ location_t loc = cp_lexer_peek_token (parser->lexer)->location;
+ if (cp_lexer_next_token_is_not (parser->lexer, CPP_NAME))
+ {
+ cp_parser_error (parser, "expected identifier");
+ break;
+ }
+
+ tree id = cp_parser_identifier (parser);
+ if (id == error_mark_node)
+ break;
+
+ if (!cp_parser_require (parser, CPP_EQ, RT_EQ))
+ break;
+
+ parser->colon_corrects_to_scope_p = false;
+ parser->colon_doesnt_start_class_def_p = true;
+ tree begin = cp_parser_assignment_expression (parser);
+
+ if (!cp_parser_require (parser, CPP_COLON, RT_COLON))
+ break;
+
+ tree end = cp_parser_assignment_expression (parser);
+
+ tree step = integer_one_node;
+ if (cp_lexer_next_token_is (parser->lexer, CPP_COLON))
+ {
+ cp_lexer_consume_token (parser->lexer);
+ step = cp_parser_assignment_expression (parser);
+ }
+
+ tree iter_var = build_decl (loc, VAR_DECL, id, iter_type);
+ DECL_ARTIFICIAL (iter_var) = 1;
+ DECL_CONTEXT (iter_var) = current_function_decl;
+ pushdecl (iter_var);
+
+ *last = make_tree_vec (6);
+ TREE_VEC_ELT (*last, 0) = iter_var;
+ TREE_VEC_ELT (*last, 1) = begin;
+ TREE_VEC_ELT (*last, 2) = end;
+ TREE_VEC_ELT (*last, 3) = step;
+ last = &TREE_CHAIN (*last);
+
+ if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA))
+ {
+ cp_lexer_consume_token (parser->lexer);
+ continue;
+ }
+ break;
+ }
+ while (1);
+
+ parser->colon_corrects_to_scope_p = saved_colon_corrects_to_scope_p;
+ parser->colon_doesnt_start_class_def_p
+ = saved_colon_doesnt_start_class_def_p;
+
+ if (!parens.require_close (parser))
+ cp_parser_skip_to_closing_parenthesis (parser,
+ /*recovering=*/true,
+ /*or_comma=*/false,
+ /*consume_paren=*/true);
+
+ return ret ? ret : error_mark_node;
+}
+
/* OpenMP 4.0:
depend ( depend-kind : variable-list )
@@ -33554,41 +33923,73 @@ cp_parser_omp_clause_depend_sink (cp_parser *parser, location_t clause_loc,
OpenMP 4.5:
depend ( source )
- depend ( sink : vec ) */
+ depend ( sink : vec )
+
+ OpenMP 5.0:
+ depend ( depend-modifier , depend-kind: variable-list )
+
+ depend-kind:
+ in | out | inout | mutexinoutset | depobj
+
+ depend-modifier:
+ iterator ( iterators-definition ) */
static tree
cp_parser_omp_clause_depend (cp_parser *parser, tree list, location_t loc)
{
- tree nlist, c;
- enum omp_clause_depend_kind kind = OMP_CLAUSE_DEPEND_INOUT;
+ tree nlist, c, iterators = NULL_TREE;
+ enum omp_clause_depend_kind kind = OMP_CLAUSE_DEPEND_LAST;
matching_parens parens;
if (!parens.require_open (parser))
return list;
- if (cp_lexer_next_token_is (parser->lexer, CPP_NAME))
+ do
{
+ if (cp_lexer_next_token_is_not (parser->lexer, CPP_NAME))
+ goto invalid_kind;
+
tree id = cp_lexer_peek_token (parser->lexer)->u.value;
const char *p = IDENTIFIER_POINTER (id);
+ if (strcmp ("iterator", p) == 0 && iterators == NULL_TREE)
+ {
+ begin_scope (sk_omp, NULL);
+ iterators = cp_parser_omp_iterators (parser);
+ cp_parser_require (parser, CPP_COMMA, RT_COMMA);
+ continue;
+ }
if (strcmp ("in", p) == 0)
kind = OMP_CLAUSE_DEPEND_IN;
else if (strcmp ("inout", p) == 0)
kind = OMP_CLAUSE_DEPEND_INOUT;
+ else if (strcmp ("mutexinoutset", p) == 0)
+ kind = OMP_CLAUSE_DEPEND_MUTEXINOUTSET;
else if (strcmp ("out", p) == 0)
kind = OMP_CLAUSE_DEPEND_OUT;
- else if (strcmp ("source", p) == 0)
- kind = OMP_CLAUSE_DEPEND_SOURCE;
+ else if (strcmp ("depobj", p) == 0)
+ kind = OMP_CLAUSE_DEPEND_DEPOBJ;
else if (strcmp ("sink", p) == 0)
kind = OMP_CLAUSE_DEPEND_SINK;
+ else if (strcmp ("source", p) == 0)
+ kind = OMP_CLAUSE_DEPEND_SOURCE;
else
goto invalid_kind;
+ break;
}
- else
- goto invalid_kind;
+ while (1);
cp_lexer_consume_token (parser->lexer);
+ if (iterators
+ && (kind == OMP_CLAUSE_DEPEND_SOURCE || kind == OMP_CLAUSE_DEPEND_SINK))
+ {
+ poplevel (0, 1, 0);
+ error_at (loc, "%<iterator%> modifier incompatible with %qs",
+ kind == OMP_CLAUSE_DEPEND_SOURCE ? "source" : "sink");
+ iterators = NULL_TREE;
+ }
+
if (kind == OMP_CLAUSE_DEPEND_SOURCE)
{
c = build_omp_clause (loc, OMP_CLAUSE_DEPEND);
@@ -33612,14 +34013,30 @@ cp_parser_omp_clause_depend (cp_parser *parser, tree list, location_t loc)
nlist = cp_parser_omp_var_list_no_open (parser, OMP_CLAUSE_DEPEND,
list, NULL);
+ if (iterators)
+ {
+ tree block = poplevel (1, 1, 0);
+ if (iterators == error_mark_node)
+ iterators = NULL_TREE;
+ else
+ TREE_VEC_ELT (iterators, 5) = block;
+ }
+
for (c = nlist; c != list; c = OMP_CLAUSE_CHAIN (c))
- OMP_CLAUSE_DEPEND_KIND (c) = kind;
+ {
+ OMP_CLAUSE_DEPEND_KIND (c) = kind;
+ if (iterators)
+ OMP_CLAUSE_DECL (c)
+ = build_tree_list (iterators, OMP_CLAUSE_DECL (c));
+ }
}
return nlist;
invalid_kind:
cp_parser_error (parser, "invalid depend kind");
resync_fail:
+ if (iterators)
+ poplevel (0, 1, 0);
cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true,
/*or_comma=*/false,
/*consume_paren=*/true);
@@ -34022,7 +34439,9 @@ cp_parser_oacc_all_clauses (cp_parser *parser, omp_clause_mask mask,
c_name = "private";
break;
case PRAGMA_OACC_CLAUSE_REDUCTION:
- clauses = cp_parser_omp_clause_reduction (parser, clauses);
+ clauses
+ = cp_parser_omp_clause_reduction (parser, OMP_CLAUSE_REDUCTION,
+ false, clauses);
c_name = "reduction";
break;
case PRAGMA_OACC_CLAUSE_SEQ:
@@ -34169,9 +34588,14 @@ cp_parser_omp_all_clauses (cp_parser *parser, omp_clause_mask mask,
true);
c_name = "if";
break;
+ case PRAGMA_OMP_CLAUSE_IN_REDUCTION:
+ clauses
+ = cp_parser_omp_clause_reduction (parser, OMP_CLAUSE_IN_REDUCTION,
+ true, clauses);
+ c_name = "in_reduction";
+ break;
case PRAGMA_OMP_CLAUSE_LASTPRIVATE:
- clauses = cp_parser_omp_var_list (parser, OMP_CLAUSE_LASTPRIVATE,
- clauses);
+ clauses = cp_parser_omp_clause_lastprivate (parser, clauses);
c_name = "lastprivate";
break;
case PRAGMA_OMP_CLAUSE_MERGEABLE:
@@ -34209,7 +34633,9 @@ cp_parser_omp_all_clauses (cp_parser *parser, omp_clause_mask mask,
c_name = "private";
break;
case PRAGMA_OMP_CLAUSE_REDUCTION:
- clauses = cp_parser_omp_clause_reduction (parser, clauses);
+ clauses
+ = cp_parser_omp_clause_reduction (parser, OMP_CLAUSE_REDUCTION,
+ true, clauses);
c_name = "reduction";
break;
case PRAGMA_OMP_CLAUSE_SCHEDULE:
@@ -34222,6 +34648,13 @@ cp_parser_omp_all_clauses (cp_parser *parser, omp_clause_mask mask,
clauses);
c_name = "shared";
break;
+ case PRAGMA_OMP_CLAUSE_TASK_REDUCTION:
+ clauses
+ = cp_parser_omp_clause_reduction (parser,
+ OMP_CLAUSE_TASK_REDUCTION,
+ true, clauses);
+ c_name = "task_reduction";
+ break;
case PRAGMA_OMP_CLAUSE_UNTIED:
clauses = cp_parser_omp_clause_untied (parser, clauses,
token->location);
@@ -34232,6 +34665,11 @@ cp_parser_omp_all_clauses (cp_parser *parser, omp_clause_mask mask,
clauses, token->location);
c_name = "inbranch";
break;
+ case PRAGMA_OMP_CLAUSE_NONTEMPORAL:
+ clauses = cp_parser_omp_var_list (parser, OMP_CLAUSE_NONTEMPORAL,
+ clauses);
+ c_name = "nontemporal";
+ break;
case PRAGMA_OMP_CLAUSE_NOTINBRANCH:
clauses = cp_parser_omp_clause_branch (parser,
OMP_CLAUSE_NOTINBRANCH,
@@ -34494,62 +34932,154 @@ cp_parser_omp_atomic (cp_parser *parser, cp_token *pragma_tok)
{
tree lhs = NULL_TREE, rhs = NULL_TREE, v = NULL_TREE, lhs1 = NULL_TREE;
tree rhs1 = NULL_TREE, orig_lhs;
- enum tree_code code = OMP_ATOMIC, opcode = NOP_EXPR;
+ location_t loc = pragma_tok->location;
+ enum tree_code code = ERROR_MARK, opcode = NOP_EXPR;
+ enum omp_memory_order memory_order = OMP_MEMORY_ORDER_UNSPECIFIED;
bool structured_block = false;
- bool seq_cst = false;
-
- if (cp_lexer_next_token_is (parser->lexer, CPP_NAME))
- {
- tree id = cp_lexer_peek_token (parser->lexer)->u.value;
- const char *p = IDENTIFIER_POINTER (id);
-
- if (!strcmp (p, "seq_cst"))
- {
- seq_cst = true;
- cp_lexer_consume_token (parser->lexer);
- if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA)
- && cp_lexer_peek_nth_token (parser->lexer, 2)->type == CPP_NAME)
- cp_lexer_consume_token (parser->lexer);
- }
- }
- if (cp_lexer_next_token_is (parser->lexer, CPP_NAME))
- {
- tree id = cp_lexer_peek_token (parser->lexer)->u.value;
- const char *p = IDENTIFIER_POINTER (id);
+ bool first = true;
+ tree clauses = NULL_TREE;
- if (!strcmp (p, "read"))
- code = OMP_ATOMIC_READ;
- else if (!strcmp (p, "write"))
- code = NOP_EXPR;
- else if (!strcmp (p, "update"))
- code = OMP_ATOMIC;
- else if (!strcmp (p, "capture"))
- code = OMP_ATOMIC_CAPTURE_NEW;
- else
- p = NULL;
- if (p)
- cp_lexer_consume_token (parser->lexer);
- }
- if (!seq_cst)
+ while (cp_lexer_next_token_is_not (parser->lexer, CPP_PRAGMA_EOL))
{
- if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA)
- && cp_lexer_peek_nth_token (parser->lexer, 2)->type == CPP_NAME)
+ if (!first && cp_lexer_next_token_is (parser->lexer, CPP_COMMA))
cp_lexer_consume_token (parser->lexer);
+ first = false;
+
if (cp_lexer_next_token_is (parser->lexer, CPP_NAME))
{
tree id = cp_lexer_peek_token (parser->lexer)->u.value;
+ location_t cloc = cp_lexer_peek_token (parser->lexer)->location;
const char *p = IDENTIFIER_POINTER (id);
-
- if (!strcmp (p, "seq_cst"))
+ enum tree_code new_code = ERROR_MARK;
+ enum omp_memory_order new_memory_order
+ = OMP_MEMORY_ORDER_UNSPECIFIED;
+
+ if (!strcmp (p, "read"))
+ new_code = OMP_ATOMIC_READ;
+ else if (!strcmp (p, "write"))
+ new_code = NOP_EXPR;
+ else if (!strcmp (p, "update"))
+ new_code = OMP_ATOMIC;
+ else if (!strcmp (p, "capture"))
+ new_code = OMP_ATOMIC_CAPTURE_NEW;
+ else if (!strcmp (p, "seq_cst"))
+ new_memory_order = OMP_MEMORY_ORDER_SEQ_CST;
+ else if (!strcmp (p, "acq_rel"))
+ new_memory_order = OMP_MEMORY_ORDER_ACQ_REL;
+ else if (!strcmp (p, "release"))
+ new_memory_order = OMP_MEMORY_ORDER_RELEASE;
+ else if (!strcmp (p, "acquire"))
+ new_memory_order = OMP_MEMORY_ORDER_ACQUIRE;
+ else if (!strcmp (p, "relaxed"))
+ new_memory_order = OMP_MEMORY_ORDER_RELAXED;
+ else if (!strcmp (p, "hint"))
{
- seq_cst = true;
cp_lexer_consume_token (parser->lexer);
+ clauses = cp_parser_omp_clause_hint (parser, clauses, cloc);
+ continue;
+ }
+ else
+ {
+ p = NULL;
+ error_at (cloc, "expected %<read%>, %<write%>, %<update%>, "
+ "%<capture%>, %<seq_cst%>, %<acq_rel%>, "
+ "%<release%>, %<relaxed%> or %<hint%> clause");
+ }
+ if (p)
+ {
+ if (new_code != ERROR_MARK)
+ {
+ if (code != ERROR_MARK)
+ error_at (cloc, "too many atomic clauses");
+ else
+ code = new_code;
+ }
+ else if (new_memory_order != OMP_MEMORY_ORDER_UNSPECIFIED)
+ {
+ if (memory_order != OMP_MEMORY_ORDER_UNSPECIFIED)
+ error_at (cloc, "too many memory order clauses");
+ else
+ memory_order = new_memory_order;
+ }
+ cp_lexer_consume_token (parser->lexer);
+ continue;
}
}
+ break;
}
cp_parser_require_pragma_eol (parser, pragma_tok);
+ if (code == ERROR_MARK)
+ code = OMP_ATOMIC;
+ if (memory_order == OMP_MEMORY_ORDER_UNSPECIFIED)
+ {
+ omp_requires_mask
+ = (enum omp_requires) (omp_requires_mask
+ | OMP_REQUIRES_ATOMIC_DEFAULT_MEM_ORDER_USED);
+ switch ((enum omp_memory_order)
+ (omp_requires_mask & OMP_REQUIRES_ATOMIC_DEFAULT_MEM_ORDER))
+ {
+ case OMP_MEMORY_ORDER_UNSPECIFIED:
+ case OMP_MEMORY_ORDER_RELAXED:
+ memory_order = OMP_MEMORY_ORDER_RELAXED;
+ break;
+ case OMP_MEMORY_ORDER_SEQ_CST:
+ memory_order = OMP_MEMORY_ORDER_SEQ_CST;
+ break;
+ case OMP_MEMORY_ORDER_ACQ_REL:
+ switch (code)
+ {
+ case OMP_ATOMIC_READ:
+ memory_order = OMP_MEMORY_ORDER_ACQUIRE;
+ break;
+ case NOP_EXPR: /* atomic write */
+ case OMP_ATOMIC:
+ memory_order = OMP_MEMORY_ORDER_RELEASE;
+ break;
+ default:
+ memory_order = OMP_MEMORY_ORDER_ACQ_REL;
+ break;
+ }
+ break;
+ default:
+ gcc_unreachable ();
+ }
+ }
+ else
+ switch (code)
+ {
+ case OMP_ATOMIC_READ:
+ if (memory_order == OMP_MEMORY_ORDER_ACQ_REL
+ || memory_order == OMP_MEMORY_ORDER_RELEASE)
+ {
+ error_at (loc, "%<#pragma omp atomic read%> incompatible with "
+ "%<acq_rel%> or %<release%> clauses");
+ memory_order = OMP_MEMORY_ORDER_SEQ_CST;
+ }
+ break;
+ case NOP_EXPR: /* atomic write */
+ if (memory_order == OMP_MEMORY_ORDER_ACQ_REL
+ || memory_order == OMP_MEMORY_ORDER_ACQUIRE)
+ {
+ error_at (loc, "%<#pragma omp atomic write%> incompatible with "
+ "%<acq_rel%> or %<acquire%> clauses");
+ memory_order = OMP_MEMORY_ORDER_SEQ_CST;
+ }
+ break;
+ case OMP_ATOMIC:
+ if (memory_order == OMP_MEMORY_ORDER_ACQ_REL
+ || memory_order == OMP_MEMORY_ORDER_ACQUIRE)
+ {
+ error_at (loc, "%<#pragma omp atomic update%> incompatible with "
+ "%<acq_rel%> or %<acquire%> clauses");
+ memory_order = OMP_MEMORY_ORDER_SEQ_CST;
+ }
+ break;
+ default:
+ break;
+ }
+
switch (code)
{
case OMP_ATOMIC_READ:
@@ -34849,7 +35379,9 @@ stmt_done:
cp_parser_require (parser, CPP_CLOSE_BRACE, RT_CLOSE_BRACE);
}
done:
- finish_omp_atomic (code, opcode, lhs, rhs, v, lhs1, rhs1, seq_cst);
+ clauses = finish_omp_clauses (clauses, C_ORT_OMP);
+ finish_omp_atomic (pragma_tok->location, code, opcode, lhs, rhs, v, lhs1,
+ rhs1, clauses, memory_order);
if (!structured_block)
cp_parser_consume_semicolon_at_end_of_statement (parser);
return;
@@ -34911,6 +35443,10 @@ cp_parser_omp_critical (cp_parser *parser, cp_token *pragma_tok, bool *if_p)
if (name == error_mark_node)
name = NULL;
+ if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA)
+ && cp_lexer_nth_token_is (parser->lexer, 2, CPP_NAME))
+ cp_lexer_consume_token (parser->lexer);
+
clauses = cp_parser_omp_all_clauses (parser,
OMP_CRITICAL_CLAUSE_MASK,
"#pragma omp critical", pragma_tok);
@@ -34922,26 +35458,151 @@ cp_parser_omp_critical (cp_parser *parser, cp_token *pragma_tok, bool *if_p)
return c_finish_omp_critical (input_location, stmt, name, clauses);
}
+/* OpenMP 5.0:
+ # pragma omp depobj ( depobj ) depobj-clause new-line
+
+ depobj-clause:
+ depend (dependence-type : locator)
+ destroy
+ update (dependence-type)
+
+ dependence-type:
+ in
+ out
+ inout
+ mutexinout */
+
+static void
+cp_parser_omp_depobj (cp_parser *parser, cp_token *pragma_tok)
+{
+ location_t loc = pragma_tok->location;
+ matching_parens parens;
+ if (!parens.require_open (parser))
+ {
+ cp_parser_skip_to_pragma_eol (parser, pragma_tok);
+ return;
+ }
+
+ tree depobj = cp_parser_assignment_expression (parser);
+
+ if (!parens.require_close (parser))
+ cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true,
+ /*or_comma=*/false,
+ /*consume_paren=*/true);
+
+ tree clause = NULL_TREE;
+ enum omp_clause_depend_kind kind = OMP_CLAUSE_DEPEND_SOURCE;
+ location_t c_loc = cp_lexer_peek_token (parser->lexer)->location;
+ if (cp_lexer_next_token_is (parser->lexer, CPP_NAME))
+ {
+ tree id = cp_lexer_peek_token (parser->lexer)->u.value;
+ const char *p = IDENTIFIER_POINTER (id);
+
+ cp_lexer_consume_token (parser->lexer);
+ if (!strcmp ("depend", p))
+ {
+ clause = cp_parser_omp_clause_depend (parser, NULL_TREE, c_loc);
+ if (clause)
+ clause = finish_omp_clauses (clause, C_ORT_OMP);
+ if (!clause)
+ clause = error_mark_node;
+ }
+ else if (!strcmp ("destroy", p))
+ kind = OMP_CLAUSE_DEPEND_LAST;
+ else if (!strcmp ("update", p))
+ {
+ matching_parens c_parens;
+ if (c_parens.require_open (parser))
+ {
+ location_t c2_loc
+ = cp_lexer_peek_token (parser->lexer)->location;
+ if (cp_lexer_next_token_is (parser->lexer, CPP_NAME))
+ {
+ tree id2 = cp_lexer_peek_token (parser->lexer)->u.value;
+ const char *p2 = IDENTIFIER_POINTER (id2);
+
+ cp_lexer_consume_token (parser->lexer);
+ if (!strcmp ("in", p2))
+ kind = OMP_CLAUSE_DEPEND_IN;
+ else if (!strcmp ("out", p2))
+ kind = OMP_CLAUSE_DEPEND_OUT;
+ else if (!strcmp ("inout", p2))
+ kind = OMP_CLAUSE_DEPEND_INOUT;
+ else if (!strcmp ("mutexinoutset", p2))
+ kind = OMP_CLAUSE_DEPEND_MUTEXINOUTSET;
+ }
+ if (kind == OMP_CLAUSE_DEPEND_SOURCE)
+ {
+ clause = error_mark_node;
+ error_at (c2_loc, "expected %<in%>, %<out%>, %<inout%> or "
+ "%<mutexinoutset%>");
+ }
+ if (!c_parens.require_close (parser))
+ cp_parser_skip_to_closing_parenthesis (parser,
+ /*recovering=*/true,
+ /*or_comma=*/false,
+ /*consume_paren=*/true);
+ }
+ else
+ clause = error_mark_node;
+ }
+ }
+ if (!clause && kind == OMP_CLAUSE_DEPEND_SOURCE)
+ {
+ clause = error_mark_node;
+ error_at (c_loc, "expected %<depend%>, %<destroy%> or %<update%> clause");
+ }
+ cp_parser_require_pragma_eol (parser, pragma_tok);
+
+ finish_omp_depobj (loc, depobj, kind, clause);
+}
+
+
/* OpenMP 2.5:
# pragma omp flush flush-vars[opt] new-line
flush-vars:
- ( variable-list ) */
+ ( variable-list )
+
+ OpenMP 5.0:
+ # pragma omp flush memory-order-clause new-line */
static void
cp_parser_omp_flush (cp_parser *parser, cp_token *pragma_tok)
{
+ enum memmodel mo = MEMMODEL_LAST;
+ if (cp_lexer_next_token_is (parser->lexer, CPP_NAME))
+ {
+ tree id = cp_lexer_peek_token (parser->lexer)->u.value;
+ const char *p = IDENTIFIER_POINTER (id);
+ if (!strcmp (p, "acq_rel"))
+ mo = MEMMODEL_ACQ_REL;
+ else if (!strcmp (p, "release"))
+ mo = MEMMODEL_RELEASE;
+ else if (!strcmp (p, "acquire"))
+ mo = MEMMODEL_ACQUIRE;
+ else
+ error_at (cp_lexer_peek_token (parser->lexer)->location,
+ "expected %<acq_rel%>, %<release%> or %<acquire%>");
+ cp_lexer_consume_token (parser->lexer);
+ }
if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_PAREN))
- (void) cp_parser_omp_var_list (parser, OMP_CLAUSE_ERROR, NULL);
+ {
+ if (mo != MEMMODEL_LAST)
+ error_at (cp_lexer_peek_token (parser->lexer)->location,
+ "%<flush%> list specified together with memory order "
+ "clause");
+ (void) cp_parser_omp_var_list (parser, OMP_CLAUSE_ERROR, NULL);
+ }
cp_parser_require_pragma_eol (parser, pragma_tok);
- finish_omp_flush ();
+ finish_omp_flush (mo);
}
/* Helper function, to parse omp for increment expression. */
static tree
-cp_parser_omp_for_cond (cp_parser *parser, tree decl)
+cp_parser_omp_for_cond (cp_parser *parser, tree decl, enum tree_code code)
{
tree cond = cp_parser_binary_expression (parser, false, true,
PREC_NOT_OPERATOR, NULL);
@@ -34960,7 +35621,8 @@ cp_parser_omp_for_cond (cp_parser *parser, tree decl)
case LE_EXPR:
break;
case NE_EXPR:
- /* Fall through: OpenMP disallows NE_EXPR. */
+ if (code != OACC_LOOP)
+ break;
gcc_fallthrough ();
default:
return error_mark_node;
@@ -35304,6 +35966,192 @@ cp_parser_omp_for_loop_init (cp_parser *parser,
return add_private_clause;
}
+/* Helper for cp_parser_omp_for_loop, handle one range-for loop. */
+
+void
+cp_convert_omp_range_for (tree &this_pre_body, vec<tree, va_gc> *for_block,
+ tree &decl, tree &orig_decl, tree &init,
+ tree &orig_init, tree &cond, tree &incr)
+{
+ tree begin, end, range_temp_decl = NULL_TREE;
+ tree iter_type, begin_expr, end_expr;
+
+ if (processing_template_decl)
+ {
+ if (check_for_bare_parameter_packs (init))
+ init = error_mark_node;
+ if (!type_dependent_expression_p (init)
+ /* do_auto_deduction doesn't mess with template init-lists. */
+ && !BRACE_ENCLOSED_INITIALIZER_P (init))
+ {
+ tree d = decl;
+ if (decl != error_mark_node && DECL_HAS_VALUE_EXPR_P (decl))
+ {
+ tree v = DECL_VALUE_EXPR (decl);
+ if (TREE_CODE (v) == ARRAY_REF
+ && VAR_P (TREE_OPERAND (v, 0))
+ && DECL_DECOMPOSITION_P (TREE_OPERAND (v, 0)))
+ d = TREE_OPERAND (v, 0);
+ }
+ do_range_for_auto_deduction (d, init);
+ }
+ cond = global_namespace;
+ incr = NULL_TREE;
+ orig_init = init;
+ if (this_pre_body)
+ this_pre_body = pop_stmt_list (this_pre_body);
+ return;
+ }
+
+ init = mark_lvalue_use (init);
+
+ if (decl == error_mark_node || init == error_mark_node)
+ /* If an error happened previously do nothing or else a lot of
+ unhelpful errors would be issued. */
+ begin_expr = end_expr = iter_type = error_mark_node;
+ else
+ {
+ tree range_temp;
+
+ if (VAR_P (init)
+ && array_of_runtime_bound_p (TREE_TYPE (init)))
+ /* Can't bind a reference to an array of runtime bound. */
+ range_temp = init;
+ else
+ {
+ range_temp = build_range_temp (init);
+ DECL_NAME (range_temp) = NULL_TREE;
+ pushdecl (range_temp);
+ cp_finish_decl (range_temp, init,
+ /*is_constant_init*/false, NULL_TREE,
+ LOOKUP_ONLYCONVERTING);
+ range_temp_decl = range_temp;
+ range_temp = convert_from_reference (range_temp);
+ }
+ iter_type = cp_parser_perform_range_for_lookup (range_temp,
+ &begin_expr, &end_expr);
+ }
+
+ tree end_iter_type = iter_type;
+ if (cxx_dialect >= cxx17)
+ end_iter_type = cv_unqualified (TREE_TYPE (end_expr));
+ end = build_decl (input_location, VAR_DECL, NULL_TREE, end_iter_type);
+ TREE_USED (end) = 1;
+ DECL_ARTIFICIAL (end) = 1;
+ pushdecl (end);
+ cp_finish_decl (end, end_expr,
+ /*is_constant_init*/false, NULL_TREE,
+ LOOKUP_ONLYCONVERTING);
+
+ /* The new for initialization statement. */
+ begin = build_decl (input_location, VAR_DECL, NULL_TREE, iter_type);
+ TREE_USED (begin) = 1;
+ DECL_ARTIFICIAL (begin) = 1;
+ pushdecl (begin);
+ orig_init = init;
+ if (CLASS_TYPE_P (iter_type))
+ init = NULL_TREE;
+ else
+ {
+ init = begin_expr;
+ begin_expr = NULL_TREE;
+ }
+ cp_finish_decl (begin, begin_expr,
+ /*is_constant_init*/false, NULL_TREE,
+ LOOKUP_ONLYCONVERTING);
+
+ /* The new for condition. */
+ if (CLASS_TYPE_P (iter_type))
+ cond = build2 (NE_EXPR, boolean_type_node, begin, end);
+ else
+ cond = build_x_binary_op (input_location, NE_EXPR,
+ begin, ERROR_MARK,
+ end, ERROR_MARK,
+ NULL, tf_warning_or_error);
+
+ /* The new increment expression. */
+ if (CLASS_TYPE_P (iter_type))
+ incr = build2 (PREINCREMENT_EXPR, iter_type, begin, NULL_TREE);
+ else
+ incr = finish_unary_op_expr (input_location,
+ PREINCREMENT_EXPR, begin,
+ tf_warning_or_error);
+
+ orig_decl = decl;
+ decl = begin;
+ if (for_block)
+ {
+ vec_safe_push (for_block, this_pre_body);
+ this_pre_body = NULL_TREE;
+ }
+
+ tree decomp_first_name = NULL_TREE;
+ unsigned decomp_cnt = 0;
+ if (orig_decl != error_mark_node && DECL_HAS_VALUE_EXPR_P (orig_decl))
+ {
+ tree v = DECL_VALUE_EXPR (orig_decl);
+ if (TREE_CODE (v) == ARRAY_REF
+ && VAR_P (TREE_OPERAND (v, 0))
+ && DECL_DECOMPOSITION_P (TREE_OPERAND (v, 0)))
+ {
+ tree d = orig_decl;
+ orig_decl = TREE_OPERAND (v, 0);
+ decomp_cnt = tree_to_uhwi (TREE_OPERAND (v, 1)) + 1;
+ decomp_first_name = d;
+ }
+ }
+
+ tree auto_node = type_uses_auto (TREE_TYPE (orig_decl));
+ if (auto_node)
+ {
+ tree t = build_x_indirect_ref (input_location, begin, RO_UNARY_STAR,
+ tf_none);
+ if (!error_operand_p (t))
+ TREE_TYPE (orig_decl) = do_auto_deduction (TREE_TYPE (orig_decl),
+ t, auto_node);
+ }
+
+ tree v = make_tree_vec (decomp_cnt + 3);
+ TREE_VEC_ELT (v, 0) = range_temp_decl;
+ TREE_VEC_ELT (v, 1) = end;
+ TREE_VEC_ELT (v, 2) = orig_decl;
+ for (unsigned i = 0; i < decomp_cnt; i++)
+ {
+ TREE_VEC_ELT (v, i + 3) = decomp_first_name;
+ decomp_first_name = DECL_CHAIN (decomp_first_name);
+ }
+ orig_decl = tree_cons (NULL_TREE, NULL_TREE, v);
+}
+
+/* Helper for cp_parser_omp_for_loop, finalize part of range for
+ inside of the collapsed body. */
+
+void
+cp_finish_omp_range_for (tree orig, tree begin)
+{
+ gcc_assert (TREE_CODE (orig) == TREE_LIST
+ && TREE_CODE (TREE_CHAIN (orig)) == TREE_VEC);
+ tree decl = TREE_VEC_ELT (TREE_CHAIN (orig), 2);
+ tree decomp_first_name = NULL_TREE;
+ unsigned int decomp_cnt = 0;
+
+ if (VAR_P (decl) && DECL_DECOMPOSITION_P (decl))
+ {
+ decomp_first_name = TREE_VEC_ELT (TREE_CHAIN (orig), 3);
+ decomp_cnt = TREE_VEC_LENGTH (TREE_CHAIN (orig)) - 3;
+ cp_maybe_mangle_decomp (decl, decomp_first_name, decomp_cnt);
+ }
+
+ /* The declaration is initialized with *__begin inside the loop body. */
+ cp_finish_decl (decl,
+ build_x_indirect_ref (input_location, begin, RO_UNARY_STAR,
+ tf_warning_or_error),
+ /*is_constant_init*/false, NULL_TREE,
+ LOOKUP_ONLYCONVERTING);
+ if (VAR_P (decl) && DECL_DECOMPOSITION_P (decl))
+ cp_finish_decomp (decl, decomp_first_name, decomp_cnt);
+}
+
/* Parse the restricted form of the for statement allowed by OpenMP. */
static tree
@@ -35311,7 +36159,8 @@ cp_parser_omp_for_loop (cp_parser *parser, enum tree_code code, tree clauses,
tree *cclauses, bool *if_p)
{
tree init, orig_init, cond, incr, body, decl, pre_body = NULL_TREE, ret;
- tree real_decl, initv, condv, incrv, declv;
+ tree orig_decl;
+ tree real_decl, initv, condv, incrv, declv, orig_declv;
tree this_pre_body, cl, ordered_cl = NULL_TREE;
location_t loc_first;
bool collapse_err = false;
@@ -35364,6 +36213,7 @@ cp_parser_omp_for_loop (cp_parser *parser, enum tree_code code, tree clauses,
initv = make_tree_vec (count);
condv = make_tree_vec (count);
incrv = make_tree_vec (count);
+ orig_declv = NULL_TREE;
loc_first = cp_lexer_peek_token (parser->lexer)->location;
@@ -35385,9 +36235,71 @@ cp_parser_omp_for_loop (cp_parser *parser, enum tree_code code, tree clauses,
if (!parens.require_open (parser))
return NULL;
- init = orig_init = decl = real_decl = NULL;
+ init = orig_init = decl = real_decl = orig_decl = NULL_TREE;
this_pre_body = push_stmt_list ();
+ if (code != OACC_LOOP && cxx_dialect >= cxx11)
+ {
+ /* Save tokens so that we can put them back. */
+ cp_lexer_save_tokens (parser->lexer);
+
+ /* Look for ':' that is not nested in () or {}. */
+ bool is_range_for
+ = (cp_parser_skip_to_closing_parenthesis_1 (parser,
+ /*recovering=*/false,
+ CPP_COLON,
+ /*consume_paren=*/
+ false) == -1);
+
+ /* Roll back the tokens we skipped. */
+ cp_lexer_rollback_tokens (parser->lexer);
+
+ if (is_range_for)
+ {
+ bool saved_colon_corrects_to_scope_p
+ = parser->colon_corrects_to_scope_p;
+
+ /* A colon is used in range-based for. */
+ parser->colon_corrects_to_scope_p = false;
+
+ /* Parse the declaration. */
+ cp_parser_simple_declaration (parser,
+ /*function_definition_allowed_p=*/
+ false, &decl);
+ parser->colon_corrects_to_scope_p
+ = saved_colon_corrects_to_scope_p;
+
+ cp_parser_require (parser, CPP_COLON, RT_COLON);
+
+ init = cp_parser_range_for (parser, NULL_TREE, NULL_TREE, decl,
+ false, 0, true);
+
+ cp_convert_omp_range_for (this_pre_body, for_block, decl,
+ orig_decl, init, orig_init,
+ cond, incr);
+ if (this_pre_body)
+ {
+ if (pre_body)
+ {
+ tree t = pre_body;
+ pre_body = push_stmt_list ();
+ add_stmt (t);
+ add_stmt (this_pre_body);
+ pre_body = pop_stmt_list (pre_body);
+ }
+ else
+ pre_body = this_pre_body;
+ }
+
+ if (ordered_cl)
+ error_at (OMP_CLAUSE_LOCATION (ordered_cl),
+ "%<ordered%> clause with parameter on "
+ "range-based %<for%> loop");
+
+ goto parse_close_paren;
+ }
+ }
+
add_private_clause
= cp_parser_omp_for_loop_init (parser, this_pre_body, for_block,
init, orig_init, decl, real_decl);
@@ -35464,7 +36376,8 @@ cp_parser_omp_for_loop (cp_parser *parser, enum tree_code code, tree clauses,
error_at (loc, "iteration variable %qD "
"should not be firstprivate",
decl);
- else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
+ else if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
+ || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION)
&& OMP_CLAUSE_DECL (c) == decl)
error_at (loc, "iteration variable %qD should not be reduction",
decl);
@@ -35493,7 +36406,7 @@ cp_parser_omp_for_loop (cp_parser *parser, enum tree_code code, tree clauses,
cond = NULL;
if (cp_lexer_next_token_is_not (parser->lexer, CPP_SEMICOLON))
- cond = cp_parser_omp_for_cond (parser, decl);
+ cond = cp_parser_omp_for_cond (parser, decl, code);
cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
incr = NULL;
@@ -35513,6 +36426,7 @@ cp_parser_omp_for_loop (cp_parser *parser, enum tree_code code, tree clauses,
protected_set_expr_location (incr, input_location);
}
+ parse_close_paren:
if (!parens.require_close (parser))
cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true,
/*or_comma=*/false,
@@ -35527,6 +36441,14 @@ cp_parser_omp_for_loop (cp_parser *parser, enum tree_code code, tree clauses,
orig_inits.safe_grow_cleared (i + 1);
orig_inits[i] = orig_init;
}
+ if (orig_decl)
+ {
+ if (!orig_declv)
+ orig_declv = copy_node (declv);
+ TREE_VEC_ELT (orig_declv, i) = orig_decl;
+ }
+ else if (orig_declv)
+ TREE_VEC_ELT (orig_declv, i) = decl;
if (i == count - 1)
break;
@@ -35575,15 +36497,27 @@ cp_parser_omp_for_loop (cp_parser *parser, enum tree_code code, tree clauses,
/* Note that the grammar doesn't call for a structured block here,
though the loop as a whole is a structured block. */
- body = push_stmt_list ();
+ if (orig_declv)
+ {
+ body = begin_omp_structured_block ();
+ for (i = 0; i < count; i++)
+ if (TREE_VEC_ELT (orig_declv, i) != TREE_VEC_ELT (declv, i))
+ cp_finish_omp_range_for (TREE_VEC_ELT (orig_declv, i),
+ TREE_VEC_ELT (declv, i));
+ }
+ else
+ body = push_stmt_list ();
cp_parser_statement (parser, NULL_TREE, false, if_p);
- body = pop_stmt_list (body);
+ if (orig_declv)
+ body = finish_omp_structured_block (body);
+ else
+ body = pop_stmt_list (body);
if (declv == NULL_TREE)
ret = NULL_TREE;
else
- ret = finish_omp_for (loc_first, code, declv, NULL, initv, condv, incrv,
- body, pre_body, &orig_inits, clauses);
+ ret = finish_omp_for (loc_first, code, declv, orig_declv, initv, condv,
+ incrv, body, pre_body, &orig_inits, clauses);
while (nbraces)
{
@@ -35647,7 +36581,9 @@ cp_omp_split_clauses (location_t loc, enum tree_code code,
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_PRIVATE) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_LASTPRIVATE) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_REDUCTION) \
- | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_COLLAPSE))
+ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_COLLAPSE) \
+ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IF) \
+ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NONTEMPORAL))
static tree
cp_parser_omp_simd (cp_parser *parser, cp_token *pragma_tok,
@@ -35678,13 +36614,14 @@ cp_parser_omp_simd (cp_parser *parser, cp_token *pragma_tok,
}
}
+ keep_next_level (true);
sb = begin_omp_structured_block ();
save = cp_parser_begin_omp_structured_block (parser);
ret = cp_parser_omp_for_loop (parser, OMP_SIMD, clauses, cclauses, if_p);
cp_parser_end_omp_structured_block (parser, save);
- add_stmt (finish_omp_structured_block (sb));
+ add_stmt (finish_omp_for_block (finish_omp_structured_block (sb), ret));
return ret;
}
@@ -35777,26 +36714,78 @@ cp_parser_omp_for (cp_parser *parser, cp_token *pragma_tok,
clauses = cclauses[C_OMP_CLAUSE_SPLIT_FOR];
}
+ keep_next_level (true);
sb = begin_omp_structured_block ();
save = cp_parser_begin_omp_structured_block (parser);
ret = cp_parser_omp_for_loop (parser, OMP_FOR, clauses, cclauses, if_p);
cp_parser_end_omp_structured_block (parser, save);
- add_stmt (finish_omp_structured_block (sb));
+ add_stmt (finish_omp_for_block (finish_omp_structured_block (sb), ret));
return ret;
}
+static tree cp_parser_omp_taskloop (cp_parser *, cp_token *, char *,
+ omp_clause_mask, tree *, bool *);
+
/* OpenMP 2.5:
# pragma omp master new-line
structured-block */
static tree
-cp_parser_omp_master (cp_parser *parser, cp_token *pragma_tok, bool *if_p)
+cp_parser_omp_master (cp_parser *parser, cp_token *pragma_tok,
+ char *p_name, omp_clause_mask mask, tree *cclauses,
+ bool *if_p)
{
- cp_parser_require_pragma_eol (parser, pragma_tok);
- return c_finish_omp_master (input_location,
+ tree clauses, sb, ret;
+ unsigned int save;
+ location_t loc = cp_lexer_peek_token (parser->lexer)->location;
+
+ strcat (p_name, " master");
+
+ if (cp_lexer_next_token_is (parser->lexer, CPP_NAME))
+ {
+ tree id = cp_lexer_peek_token (parser->lexer)->u.value;
+ const char *p = IDENTIFIER_POINTER (id);
+
+ if (strcmp (p, "taskloop") == 0)
+ {
+ tree cclauses_buf[C_OMP_CLAUSE_SPLIT_COUNT];
+ if (cclauses == NULL)
+ cclauses = cclauses_buf;
+
+ cp_lexer_consume_token (parser->lexer);
+ if (!flag_openmp) /* flag_openmp_simd */
+ return cp_parser_omp_taskloop (parser, pragma_tok, p_name, mask,
+ cclauses, if_p);
+ sb = begin_omp_structured_block ();
+ save = cp_parser_begin_omp_structured_block (parser);
+ ret = cp_parser_omp_taskloop (parser, pragma_tok, p_name, mask,
+ cclauses, if_p);
+ cp_parser_end_omp_structured_block (parser, save);
+ tree body = finish_omp_structured_block (sb);
+ if (ret == NULL)
+ return ret;
+ return c_finish_omp_master (loc, body);
+ }
+ }
+ if (!flag_openmp) /* flag_openmp_simd */
+ {
+ cp_parser_skip_to_pragma_eol (parser, pragma_tok);
+ return NULL_TREE;
+ }
+
+ if (cclauses)
+ {
+ clauses = cp_parser_omp_all_clauses (parser, mask, p_name, pragma_tok,
+ false);
+ cp_omp_split_clauses (loc, OMP_MASTER, mask, clauses, cclauses);
+ }
+ else
+ cp_parser_require_pragma_eol (parser, pragma_tok);
+
+ return c_finish_omp_master (loc,
cp_parser_omp_structured_block (parser, if_p));
}
@@ -36038,16 +37027,34 @@ cp_parser_omp_parallel (cp_parser *parser, cp_token *pragma_tok,
cp_parser_skip_to_pragma_eol (parser, pragma_tok);
return NULL_TREE;
}
- else if (!flag_openmp) /* flag_openmp_simd */
- {
- cp_parser_skip_to_pragma_eol (parser, pragma_tok);
- return NULL_TREE;
- }
else if (cclauses == NULL && cp_lexer_next_token_is (parser->lexer, CPP_NAME))
{
tree id = cp_lexer_peek_token (parser->lexer)->u.value;
const char *p = IDENTIFIER_POINTER (id);
- if (strcmp (p, "sections") == 0)
+ if (strcmp (p, "master") == 0)
+ {
+ tree cclauses_buf[C_OMP_CLAUSE_SPLIT_COUNT];
+ cclauses = cclauses_buf;
+
+ cp_lexer_consume_token (parser->lexer);
+ block = begin_omp_parallel ();
+ save = cp_parser_begin_omp_structured_block (parser);
+ tree ret = cp_parser_omp_master (parser, pragma_tok, p_name, mask,
+ cclauses, if_p);
+ cp_parser_end_omp_structured_block (parser, save);
+ stmt = finish_omp_parallel (cclauses[C_OMP_CLAUSE_SPLIT_PARALLEL],
+ block);
+ OMP_PARALLEL_COMBINED (stmt) = 1;
+ if (ret == NULL_TREE)
+ return ret;
+ return stmt;
+ }
+ else if (!flag_openmp) /* flag_openmp_simd */
+ {
+ cp_parser_skip_to_pragma_eol (parser, pragma_tok);
+ return NULL_TREE;
+ }
+ else if (strcmp (p, "sections") == 0)
{
tree cclauses_buf[C_OMP_CLAUSE_SPLIT_COUNT];
cclauses = cclauses_buf;
@@ -36063,6 +37070,11 @@ cp_parser_omp_parallel (cp_parser *parser, cp_token *pragma_tok,
return stmt;
}
}
+ else if (!flag_openmp) /* flag_openmp_simd */
+ {
+ cp_parser_skip_to_pragma_eol (parser, pragma_tok);
+ return NULL_TREE;
+ }
clauses = cp_parser_omp_all_clauses (parser, mask, p_name, pragma_tok,
cclauses == NULL);
@@ -36095,6 +37107,7 @@ cp_parser_omp_single (cp_parser *parser, cp_token *pragma_tok, bool *if_p)
{
tree stmt = make_node (OMP_SINGLE);
TREE_TYPE (stmt) = void_type_node;
+ SET_EXPR_LOCATION (stmt, pragma_tok->location);
OMP_SINGLE_CLAUSES (stmt)
= cp_parser_omp_all_clauses (parser, OMP_SINGLE_CLAUSE_MASK,
@@ -36118,7 +37131,8 @@ cp_parser_omp_single (cp_parser *parser, cp_token *pragma_tok, bool *if_p)
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_FINAL) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_MERGEABLE) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEPEND) \
- | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_PRIORITY))
+ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_PRIORITY) \
+ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IN_REDUCTION))
static tree
cp_parser_omp_task (cp_parser *parser, cp_token *pragma_tok, bool *if_p)
@@ -36136,13 +37150,32 @@ cp_parser_omp_task (cp_parser *parser, cp_token *pragma_tok, bool *if_p)
}
/* OpenMP 3.0:
- # pragma omp taskwait new-line */
+ # pragma omp taskwait new-line
+
+ OpenMP 5.0:
+ # pragma omp taskwait taskwait-clause[opt] new-line */
+
+#define OMP_TASKWAIT_CLAUSE_MASK \
+ (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEPEND)
static void
cp_parser_omp_taskwait (cp_parser *parser, cp_token *pragma_tok)
{
- cp_parser_require_pragma_eol (parser, pragma_tok);
- finish_omp_taskwait ();
+ tree clauses
+ = cp_parser_omp_all_clauses (parser, OMP_TASKWAIT_CLAUSE_MASK,
+ "#pragma omp taskwait", pragma_tok);
+
+ if (clauses)
+ {
+ tree stmt = make_node (OMP_TASK);
+ TREE_TYPE (stmt) = void_node;
+ OMP_TASK_CLAUSES (stmt) = clauses;
+ OMP_TASK_BODY (stmt) = NULL_TREE;
+ SET_EXPR_LOCATION (stmt, pragma_tok->location);
+ add_stmt (stmt);
+ }
+ else
+ finish_omp_taskwait ();
}
/* OpenMP 3.1:
@@ -36157,15 +37190,24 @@ cp_parser_omp_taskyield (cp_parser *parser, cp_token *pragma_tok)
/* OpenMP 4.0:
# pragma omp taskgroup new-line
- structured-block */
+ structured-block
+
+ OpenMP 5.0:
+ # pragma omp taskgroup taskgroup-clause[optseq] new-line */
+
+#define OMP_TASKGROUP_CLAUSE_MASK \
+ ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_TASK_REDUCTION))
static tree
cp_parser_omp_taskgroup (cp_parser *parser, cp_token *pragma_tok, bool *if_p)
{
- cp_parser_require_pragma_eol (parser, pragma_tok);
+ tree clauses
+ = cp_parser_omp_all_clauses (parser, OMP_TASKGROUP_CLAUSE_MASK,
+ "#pragma omp taskgroup", pragma_tok);
return c_finish_omp_taskgroup (input_location,
cp_parser_omp_structured_block (parser,
- if_p));
+ if_p),
+ clauses);
}
@@ -36338,13 +37380,14 @@ cp_parser_omp_distribute (cp_parser *parser, cp_token *pragma_tok,
clauses = cclauses[C_OMP_CLAUSE_SPLIT_DISTRIBUTE];
}
+ keep_next_level (true);
sb = begin_omp_structured_block ();
save = cp_parser_begin_omp_structured_block (parser);
ret = cp_parser_omp_for_loop (parser, OMP_DISTRIBUTE, clauses, NULL, if_p);
cp_parser_end_omp_structured_block (parser, save);
- add_stmt (finish_omp_structured_block (sb));
+ add_stmt (finish_omp_for_block (finish_omp_structured_block (sb), ret));
return ret;
}
@@ -36388,6 +37431,7 @@ cp_parser_omp_teams (cp_parser *parser, cp_token *pragma_tok,
if (!flag_openmp) /* flag_openmp_simd */
return cp_parser_omp_distribute (parser, pragma_tok, p_name, mask,
cclauses, if_p);
+ keep_next_level (true);
sb = begin_omp_structured_block ();
save = cp_parser_begin_omp_structured_block (parser);
ret = cp_parser_omp_distribute (parser, pragma_tok, p_name, mask,
@@ -36423,6 +37467,7 @@ cp_parser_omp_teams (cp_parser *parser, cp_token *pragma_tok,
tree stmt = make_node (OMP_TEAMS);
TREE_TYPE (stmt) = void_type_node;
OMP_TEAMS_CLAUSES (stmt) = clauses;
+ keep_next_level (true);
OMP_TEAMS_BODY (stmt) = cp_parser_omp_structured_block (parser, if_p);
SET_EXPR_LOCATION (stmt, loc);
@@ -36473,6 +37518,8 @@ cp_parser_omp_target_data (cp_parser *parser, cp_token *pragma_tok, bool *if_p)
*pc = OMP_CLAUSE_CHAIN (*pc);
continue;
}
+ else if (OMP_CLAUSE_CODE (*pc) == OMP_CLAUSE_USE_DEVICE_PTR)
+ map_seen = 3;
pc = &OMP_CLAUSE_CHAIN (*pc);
}
@@ -36481,7 +37528,7 @@ cp_parser_omp_target_data (cp_parser *parser, cp_token *pragma_tok, bool *if_p)
if (map_seen == 0)
error_at (pragma_tok->location,
"%<#pragma omp target data%> must contain at least "
- "one %<map%> clause");
+ "one %<map%> or %<use_device_ptr%> clause");
return NULL_TREE;
}
@@ -36739,6 +37786,10 @@ cp_parser_omp_target (cp_parser *parser, cp_token *pragma_tok,
{
tree *pc = NULL, stmt;
+ if (flag_openmp)
+ omp_requires_mask
+ = (enum omp_requires) (omp_requires_mask | OMP_REQUIRES_TARGET_USED);
+
if (cp_lexer_next_token_is (parser->lexer, CPP_NAME))
{
tree id = cp_lexer_peek_token (parser->lexer)->u.value;
@@ -38092,6 +39143,147 @@ cp_parser_omp_declare (cp_parser *parser, cp_token *pragma_tok,
return false;
}
+/* OpenMP 5.0
+ #pragma omp requires clauses[optseq] new-line */
+
+static bool
+cp_parser_omp_requires (cp_parser *parser, cp_token *pragma_tok)
+{
+ bool first = true;
+ enum omp_requires new_req = (enum omp_requires) 0;
+
+ location_t loc = pragma_tok->location;
+ while (cp_lexer_next_token_is_not (parser->lexer, CPP_PRAGMA_EOL))
+ {
+ if (!first && cp_lexer_next_token_is (parser->lexer, CPP_COMMA))
+ cp_lexer_consume_token (parser->lexer);
+
+ first = false;
+
+ if (cp_lexer_next_token_is (parser->lexer, CPP_NAME))
+ {
+ tree id = cp_lexer_peek_token (parser->lexer)->u.value;
+ const char *p = IDENTIFIER_POINTER (id);
+ location_t cloc = cp_lexer_peek_token (parser->lexer)->location;
+ enum omp_requires this_req = (enum omp_requires) 0;
+
+ if (!strcmp (p, "unified_address"))
+ this_req = OMP_REQUIRES_UNIFIED_ADDRESS;
+ else if (!strcmp (p, "unified_shared_memory"))
+ this_req = OMP_REQUIRES_UNIFIED_SHARED_MEMORY;
+ else if (!strcmp (p, "dynamic_allocators"))
+ this_req = OMP_REQUIRES_DYNAMIC_ALLOCATORS;
+ else if (!strcmp (p, "reverse_offload"))
+ this_req = OMP_REQUIRES_REVERSE_OFFLOAD;
+ else if (!strcmp (p, "atomic_default_mem_order"))
+ {
+ cp_lexer_consume_token (parser->lexer);
+
+ matching_parens parens;
+ if (parens.require_open (parser))
+ {
+ if (cp_lexer_next_token_is (parser->lexer, CPP_NAME))
+ {
+ id = cp_lexer_peek_token (parser->lexer)->u.value;
+ p = IDENTIFIER_POINTER (id);
+
+ if (!strcmp (p, "seq_cst"))
+ this_req
+ = (enum omp_requires) OMP_MEMORY_ORDER_SEQ_CST;
+ else if (!strcmp (p, "relaxed"))
+ this_req
+ = (enum omp_requires) OMP_MEMORY_ORDER_RELAXED;
+ else if (!strcmp (p, "acq_rel"))
+ this_req
+ = (enum omp_requires) OMP_MEMORY_ORDER_ACQ_REL;
+ }
+ if (this_req == 0)
+ {
+ error_at (cp_lexer_peek_token (parser->lexer)->location,
+ "expected %<seq_cst%>, %<relaxed%> or "
+ "%<acq_rel%>");
+ if (cp_lexer_nth_token_is (parser->lexer, 2,
+ CPP_CLOSE_PAREN))
+ cp_lexer_consume_token (parser->lexer);
+ }
+ else
+ cp_lexer_consume_token (parser->lexer);
+
+ if (!parens.require_close (parser))
+ cp_parser_skip_to_closing_parenthesis (parser,
+ /*recovering=*/true,
+ /*or_comma=*/false,
+ /*consume_paren=*/
+ true);
+
+ if (this_req == 0)
+ {
+ cp_parser_require_pragma_eol (parser, pragma_tok);
+ return false;
+ }
+ }
+ p = NULL;
+ }
+ else
+ {
+ error_at (cloc, "expected %<unified_address%>, "
+ "%<unified_shared_memory%>, "
+ "%<dynamic_allocators%>, "
+ "%<reverse_offload%> "
+ "or %<atomic_default_mem_order%> clause");
+ cp_parser_skip_to_pragma_eol (parser, pragma_tok);
+ return false;
+ }
+ if (p)
+ cp_lexer_consume_token (parser->lexer);
+ if (this_req)
+ {
+ if ((this_req & ~OMP_REQUIRES_ATOMIC_DEFAULT_MEM_ORDER) != 0)
+ {
+ if ((this_req & new_req) != 0)
+ error_at (cloc, "too many %qs clauses", p);
+ if (this_req != OMP_REQUIRES_DYNAMIC_ALLOCATORS
+ && (omp_requires_mask & OMP_REQUIRES_TARGET_USED) != 0)
+ error_at (cloc, "%qs clause used lexically after first "
+ "target construct or offloading API", p);
+ }
+ else if ((new_req & OMP_REQUIRES_ATOMIC_DEFAULT_MEM_ORDER) != 0)
+ {
+ error_at (cloc, "too many %qs clauses",
+ "atomic_default_mem_order");
+ this_req = (enum omp_requires) 0;
+ }
+ else if ((omp_requires_mask
+ & OMP_REQUIRES_ATOMIC_DEFAULT_MEM_ORDER) != 0)
+ {
+ error_at (cloc, "more than one %<atomic_default_mem_order%>"
+ " clause in a single compilation unit");
+ this_req
+ = (enum omp_requires)
+ (omp_requires_mask
+ & OMP_REQUIRES_ATOMIC_DEFAULT_MEM_ORDER);
+ }
+ else if ((omp_requires_mask
+ & OMP_REQUIRES_ATOMIC_DEFAULT_MEM_ORDER_USED) != 0)
+ error_at (cloc, "%<atomic_default_mem_order%> clause used "
+ "lexically after first %<atomic%> construct "
+ "without memory order clause");
+ new_req = (enum omp_requires) (new_req | this_req);
+ omp_requires_mask
+ = (enum omp_requires) (omp_requires_mask | this_req);
+ continue;
+ }
+ }
+ break;
+ }
+ cp_parser_require_pragma_eol (parser, pragma_tok);
+
+ if (new_req == 0)
+ error_at (loc, "%<pragma omp requires%> requires at least one clause");
+ return false;
+}
+
+
/* OpenMP 4.5:
#pragma omp taskloop taskloop-clause[optseq] new-line
for-loop
@@ -38113,7 +39305,9 @@ cp_parser_omp_declare (cp_parser *parser, cp_token *pragma_tok,
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_FINAL) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_MERGEABLE) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOGROUP) \
- | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_PRIORITY))
+ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_PRIORITY) \
+ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_REDUCTION) \
+ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IN_REDUCTION))
static tree
cp_parser_omp_taskloop (cp_parser *parser, cp_token *pragma_tok,
@@ -38126,6 +39320,10 @@ cp_parser_omp_taskloop (cp_parser *parser, cp_token *pragma_tok,
strcat (p_name, " taskloop");
mask |= OMP_TASKLOOP_CLAUSE_MASK;
+ /* #pragma omp parallel master taskloop{, simd} disallow in_reduction
+ clause. */
+ if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NUM_THREADS)) != 0)
+ mask &= ~(OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IN_REDUCTION);
if (cp_lexer_next_token_is (parser->lexer, CPP_NAME))
{
@@ -38173,6 +39371,7 @@ cp_parser_omp_taskloop (cp_parser *parser, cp_token *pragma_tok,
clauses = cclauses[C_OMP_CLAUSE_SPLIT_TASKLOOP];
}
+ keep_next_level (true);
sb = begin_omp_structured_block ();
save = cp_parser_begin_omp_structured_block (parser);
@@ -38180,7 +39379,7 @@ cp_parser_omp_taskloop (cp_parser *parser, cp_token *pragma_tok,
if_p);
cp_parser_end_omp_structured_block (parser, save);
- add_stmt (finish_omp_structured_block (sb));
+ add_stmt (finish_omp_for_block (finish_omp_structured_block (sb), ret));
return ret;
}
@@ -38487,7 +39686,9 @@ cp_parser_omp_construct (cp_parser *parser, cp_token *pragma_tok, bool *if_p)
if_p);
break;
case PRAGMA_OMP_MASTER:
- stmt = cp_parser_omp_master (parser, pragma_tok, if_p);
+ strcpy (p_name, "#pragma omp");
+ stmt = cp_parser_omp_master (parser, pragma_tok, p_name, mask, NULL,
+ if_p);
break;
case PRAGMA_OMP_PARALLEL:
strcpy (p_name, "#pragma omp");
@@ -38947,6 +40148,21 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p)
}
break;
+ case PRAGMA_OMP_DEPOBJ:
+ switch (context)
+ {
+ case pragma_compound:
+ cp_parser_omp_depobj (parser, pragma_tok);
+ return false;
+ case pragma_stmt:
+ error_at (pragma_tok->location, "%<#pragma %s%> may only be "
+ "used in compound statements", "omp depobj");
+ break;
+ default:
+ goto bad_stmt;
+ }
+ break;
+
case PRAGMA_OMP_FLUSH:
switch (context)
{
@@ -39114,6 +40330,9 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p)
pop_omp_privatization_clauses (stmt);
return true;
+ case PRAGMA_OMP_REQUIRES:
+ return cp_parser_omp_requires (parser, pragma_tok);
+
case PRAGMA_OMP_ORDERED:
if (context != pragma_stmt && context != pragma_compound)
goto bad_stmt;
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 80b4eec..fe330cd 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -16097,11 +16097,49 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
static tree
tsubst_omp_clause_decl (tree decl, tree args, tsubst_flags_t complain,
- tree in_decl)
+ tree in_decl, tree *iterator_cache)
{
if (decl == NULL_TREE)
return NULL_TREE;
+ /* Handle OpenMP iterators. */
+ if (TREE_CODE (decl) == TREE_LIST
+ && TREE_PURPOSE (decl)
+ && TREE_CODE (TREE_PURPOSE (decl)) == TREE_VEC)
+ {
+ tree ret;
+ if (iterator_cache[0] == TREE_PURPOSE (decl))
+ ret = iterator_cache[1];
+ else
+ {
+ tree *tp = &ret;
+ begin_scope (sk_omp, NULL);
+ for (tree it = TREE_PURPOSE (decl); it; it = TREE_CHAIN (it))
+ {
+ *tp = copy_node (it);
+ TREE_VEC_ELT (*tp, 0)
+ = tsubst_decl (TREE_VEC_ELT (it, 0), args, complain);
+ TREE_VEC_ELT (*tp, 1)
+ = tsubst_expr (TREE_VEC_ELT (it, 1), args, complain, in_decl,
+ /*integral_constant_expression_p=*/false);
+ TREE_VEC_ELT (*tp, 2)
+ = tsubst_expr (TREE_VEC_ELT (it, 2), args, complain, in_decl,
+ /*integral_constant_expression_p=*/false);
+ TREE_VEC_ELT (*tp, 3)
+ = tsubst_expr (TREE_VEC_ELT (it, 3), args, complain, in_decl,
+ /*integral_constant_expression_p=*/false);
+ TREE_CHAIN (*tp) = NULL_TREE;
+ tp = &TREE_CHAIN (*tp);
+ }
+ TREE_VEC_ELT (ret, 5) = poplevel (1, 1, 0);
+ iterator_cache[0] = TREE_PURPOSE (decl);
+ iterator_cache[1] = ret;
+ }
+ return build_tree_list (ret, tsubst_omp_clause_decl (TREE_VALUE (decl),
+ args, complain,
+ in_decl, NULL));
+ }
+
/* Handle an OpenMP array section represented as a TREE_LIST (or
OMP_CLAUSE_DEPEND_KIND). An OMP_CLAUSE_DEPEND (with a depend
kind of OMP_CLAUSE_DEPEND_SINK) can also be represented as a
@@ -16116,7 +16154,7 @@ tsubst_omp_clause_decl (tree decl, tree args, tsubst_flags_t complain,
tree length = tsubst_expr (TREE_VALUE (decl), args, complain, in_decl,
/*integral_constant_expression_p=*/false);
tree chain = tsubst_omp_clause_decl (TREE_CHAIN (decl), args, complain,
- in_decl);
+ in_decl, NULL);
if (TREE_PURPOSE (decl) == low_bound
&& TREE_VALUE (decl) == length
&& TREE_CHAIN (decl) == chain)
@@ -16144,6 +16182,7 @@ tsubst_omp_clauses (tree clauses, enum c_omp_region_type ort,
{
tree new_clauses = NULL_TREE, nc, oc;
tree linear_no_step = NULL_TREE;
+ tree iterator_cache[2] = { NULL_TREE, NULL_TREE };
for (oc = clauses; oc ; oc = OMP_CLAUSE_CHAIN (oc))
{
@@ -16173,11 +16212,12 @@ tsubst_omp_clauses (tree clauses, enum c_omp_region_type ort,
case OMP_CLAUSE_FROM:
case OMP_CLAUSE_TO:
case OMP_CLAUSE_MAP:
+ case OMP_CLAUSE_NONTEMPORAL:
case OMP_CLAUSE_USE_DEVICE_PTR:
case OMP_CLAUSE_IS_DEVICE_PTR:
OMP_CLAUSE_DECL (nc)
= tsubst_omp_clause_decl (OMP_CLAUSE_DECL (oc), args, complain,
- in_decl);
+ in_decl, iterator_cache);
break;
case OMP_CLAUSE_TILE:
case OMP_CLAUSE_IF:
@@ -16208,6 +16248,8 @@ tsubst_omp_clauses (tree clauses, enum c_omp_region_type ort,
in_decl, /*integral_constant_expression_p=*/false);
break;
case OMP_CLAUSE_REDUCTION:
+ case OMP_CLAUSE_IN_REDUCTION:
+ case OMP_CLAUSE_TASK_REDUCTION:
if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (oc))
{
tree placeholder = OMP_CLAUSE_REDUCTION_PLACEHOLDER (oc);
@@ -16225,13 +16267,13 @@ tsubst_omp_clauses (tree clauses, enum c_omp_region_type ort,
}
OMP_CLAUSE_DECL (nc)
= tsubst_omp_clause_decl (OMP_CLAUSE_DECL (oc), args, complain,
- in_decl);
+ in_decl, NULL);
break;
case OMP_CLAUSE_GANG:
case OMP_CLAUSE_ALIGNED:
OMP_CLAUSE_DECL (nc)
= tsubst_omp_clause_decl (OMP_CLAUSE_DECL (oc), args, complain,
- in_decl);
+ in_decl, NULL);
OMP_CLAUSE_OPERAND (nc, 1)
= tsubst_expr (OMP_CLAUSE_OPERAND (oc, 1), args, complain,
in_decl, /*integral_constant_expression_p=*/false);
@@ -16239,7 +16281,7 @@ tsubst_omp_clauses (tree clauses, enum c_omp_region_type ort,
case OMP_CLAUSE_LINEAR:
OMP_CLAUSE_DECL (nc)
= tsubst_omp_clause_decl (OMP_CLAUSE_DECL (oc), args, complain,
- in_decl);
+ in_decl, NULL);
if (OMP_CLAUSE_LINEAR_STEP (oc) == NULL_TREE)
{
gcc_assert (!linear_no_step);
@@ -16248,7 +16290,7 @@ tsubst_omp_clauses (tree clauses, enum c_omp_region_type ort,
else if (OMP_CLAUSE_LINEAR_VARIABLE_STRIDE (oc))
OMP_CLAUSE_LINEAR_STEP (nc)
= tsubst_omp_clause_decl (OMP_CLAUSE_LINEAR_STEP (oc), args,
- complain, in_decl);
+ complain, in_decl, NULL);
else
OMP_CLAUSE_LINEAR_STEP (nc)
= tsubst_expr (OMP_CLAUSE_LINEAR_STEP (oc), args, complain,
@@ -16289,6 +16331,8 @@ tsubst_omp_clauses (tree clauses, enum c_omp_region_type ort,
case OMP_CLAUSE_COPYPRIVATE:
case OMP_CLAUSE_LINEAR:
case OMP_CLAUSE_REDUCTION:
+ case OMP_CLAUSE_IN_REDUCTION:
+ case OMP_CLAUSE_TASK_REDUCTION:
case OMP_CLAUSE_USE_DEVICE_PTR:
case OMP_CLAUSE_IS_DEVICE_PTR:
/* tsubst_expr on SCOPE_REF results in returning
@@ -16403,10 +16447,13 @@ tsubst_copy_asm_operands (tree t, tree args, tsubst_flags_t complain,
static tree *omp_parallel_combined_clauses;
+static tree tsubst_decomp_names (tree, tree, tree, tsubst_flags_t, tree,
+ tree *, unsigned int *);
+
/* Substitute one OMP_FOR iterator. */
-static void
-tsubst_omp_for_iterator (tree t, int i, tree declv, tree orig_declv,
+static bool
+tsubst_omp_for_iterator (tree t, int i, tree declv, tree &orig_declv,
tree initv, tree condv, tree incrv, tree *clauses,
tree args, tsubst_flags_t complain, tree in_decl,
bool integral_constant_expression_p)
@@ -16414,26 +16461,56 @@ tsubst_omp_for_iterator (tree t, int i, tree declv, tree orig_declv,
#define RECUR(NODE) \
tsubst_expr ((NODE), args, complain, in_decl, \
integral_constant_expression_p)
- tree decl, init, cond, incr;
+ tree decl, init, cond = NULL_TREE, incr = NULL_TREE;
+ bool ret = false;
init = TREE_VEC_ELT (OMP_FOR_INIT (t), i);
gcc_assert (TREE_CODE (init) == MODIFY_EXPR);
- if (orig_declv && OMP_FOR_ORIG_DECLS (t))
- {
- tree o = TREE_VEC_ELT (OMP_FOR_ORIG_DECLS (t), i);
- if (TREE_CODE (o) == TREE_LIST)
- TREE_VEC_ELT (orig_declv, i)
- = tree_cons (RECUR (TREE_PURPOSE (o)),
- RECUR (TREE_VALUE (o)), NULL_TREE);
- else
- TREE_VEC_ELT (orig_declv, i) = RECUR (o);
- }
-
decl = TREE_OPERAND (init, 0);
init = TREE_OPERAND (init, 1);
tree decl_expr = NULL_TREE;
- if (init && TREE_CODE (init) == DECL_EXPR)
+ bool range_for = TREE_VEC_ELT (OMP_FOR_COND (t), i) == global_namespace;
+ if (range_for)
+ {
+ bool decomp = false;
+ if (decl != error_mark_node && DECL_HAS_VALUE_EXPR_P (decl))
+ {
+ tree v = DECL_VALUE_EXPR (decl);
+ if (TREE_CODE (v) == ARRAY_REF
+ && VAR_P (TREE_OPERAND (v, 0))
+ && DECL_DECOMPOSITION_P (TREE_OPERAND (v, 0)))
+ {
+ tree decomp_first = NULL_TREE;
+ unsigned decomp_cnt = 0;
+ tree d = tsubst_decl (TREE_OPERAND (v, 0), args, complain);
+ maybe_push_decl (d);
+ d = tsubst_decomp_names (d, TREE_OPERAND (v, 0), args, complain,
+ in_decl, &decomp_first, &decomp_cnt);
+ decomp = true;
+ if (d == error_mark_node)
+ decl = error_mark_node;
+ else
+ for (unsigned int i = 0; i < decomp_cnt; i++)
+ {
+ if (!DECL_HAS_VALUE_EXPR_P (decomp_first))
+ {
+ tree v = build_nt (ARRAY_REF, d,
+ size_int (decomp_cnt - i - 1),
+ NULL_TREE, NULL_TREE);
+ SET_DECL_VALUE_EXPR (decomp_first, v);
+ DECL_HAS_VALUE_EXPR_P (decomp_first) = 1;
+ }
+ fit_decomposition_lang_decl (decomp_first, d);
+ decomp_first = DECL_CHAIN (decomp_first);
+ }
+ }
+ }
+ decl = tsubst_decl (decl, args, complain);
+ if (!decomp)
+ maybe_push_decl (decl);
+ }
+ else if (init && TREE_CODE (init) == DECL_EXPR)
{
/* We need to jump through some hoops to handle declarations in the
init-statement, since we might need to handle auto deduction,
@@ -16480,14 +16557,44 @@ tsubst_omp_for_iterator (tree t, int i, tree declv, tree orig_declv,
}
init = RECUR (init);
+ if (orig_declv && OMP_FOR_ORIG_DECLS (t))
+ {
+ tree o = TREE_VEC_ELT (OMP_FOR_ORIG_DECLS (t), i);
+ if (TREE_CODE (o) == TREE_LIST)
+ TREE_VEC_ELT (orig_declv, i)
+ = tree_cons (RECUR (TREE_PURPOSE (o)),
+ RECUR (TREE_VALUE (o)),
+ NULL_TREE);
+ else
+ TREE_VEC_ELT (orig_declv, i) = RECUR (o);
+ }
+
+ if (range_for)
+ {
+ tree this_pre_body = NULL_TREE;
+ tree orig_init = NULL_TREE;
+ tree orig_decl = NULL_TREE;
+ cp_convert_omp_range_for (this_pre_body, NULL, decl, orig_decl, init,
+ orig_init, cond, incr);
+ if (orig_decl)
+ {
+ if (orig_declv == NULL_TREE)
+ orig_declv = copy_node (declv);
+ TREE_VEC_ELT (orig_declv, i) = orig_decl;
+ ret = true;
+ }
+ else if (orig_declv)
+ TREE_VEC_ELT (orig_declv, i) = decl;
+ }
+
tree auto_node = type_uses_auto (TREE_TYPE (decl));
- if (auto_node && init)
+ if (!range_for && auto_node && init)
TREE_TYPE (decl)
= do_auto_deduction (TREE_TYPE (decl), init, auto_node, complain);
gcc_assert (!type_dependent_expression_p (decl));
- if (!CLASS_TYPE_P (TREE_TYPE (decl)))
+ if (!CLASS_TYPE_P (TREE_TYPE (decl)) || range_for)
{
if (decl_expr)
{
@@ -16498,22 +16605,27 @@ tsubst_omp_for_iterator (tree t, int i, tree declv, tree orig_declv,
DECL_INITIAL (DECL_EXPR_DECL (decl_expr)) = init_sav;
}
- cond = RECUR (TREE_VEC_ELT (OMP_FOR_COND (t), i));
- incr = TREE_VEC_ELT (OMP_FOR_INCR (t), i);
- if (TREE_CODE (incr) == MODIFY_EXPR)
+ if (!range_for)
{
- tree lhs = RECUR (TREE_OPERAND (incr, 0));
- tree rhs = RECUR (TREE_OPERAND (incr, 1));
- incr = build_x_modify_expr (EXPR_LOCATION (incr), lhs,
- NOP_EXPR, rhs, complain);
+ cond = RECUR (TREE_VEC_ELT (OMP_FOR_COND (t), i));
+ incr = TREE_VEC_ELT (OMP_FOR_INCR (t), i);
+ if (TREE_CODE (incr) == MODIFY_EXPR)
+ {
+ tree lhs = RECUR (TREE_OPERAND (incr, 0));
+ tree rhs = RECUR (TREE_OPERAND (incr, 1));
+ incr = build_x_modify_expr (EXPR_LOCATION (incr), lhs,
+ NOP_EXPR, rhs, complain);
+ }
+ else
+ incr = RECUR (incr);
+ if (orig_declv && !OMP_FOR_ORIG_DECLS (t))
+ TREE_VEC_ELT (orig_declv, i) = decl;
}
- else
- incr = RECUR (incr);
TREE_VEC_ELT (declv, i) = decl;
TREE_VEC_ELT (initv, i) = init;
TREE_VEC_ELT (condv, i) = cond;
TREE_VEC_ELT (incrv, i) = incr;
- return;
+ return ret;
}
if (decl_expr)
@@ -16640,10 +16752,13 @@ tsubst_omp_for_iterator (tree t, int i, tree declv, tree orig_declv,
break;
}
+ if (orig_declv && !OMP_FOR_ORIG_DECLS (t))
+ TREE_VEC_ELT (orig_declv, i) = decl;
TREE_VEC_ELT (declv, i) = decl;
TREE_VEC_ELT (initv, i) = init;
TREE_VEC_ELT (condv, i) = cond;
TREE_VEC_ELT (incrv, i) = incr;
+ return false;
#undef RECUR
}
@@ -17254,6 +17369,15 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
break;
case OMP_TASK:
+ if (OMP_TASK_BODY (t) == NULL_TREE)
+ {
+ tmp = tsubst_omp_clauses (OMP_TASK_CLAUSES (t), C_ORT_OMP, args,
+ complain, in_decl);
+ t = copy_node (t);
+ OMP_TASK_CLAUSES (t) = tmp;
+ add_stmt (t);
+ break;
+ }
r = push_omp_privatization_clauses (false);
tmp = tsubst_omp_clauses (OMP_TASK_CLAUSES (t), C_ORT_OMP, args,
complain, in_decl);
@@ -17274,6 +17398,7 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
tree orig_declv = NULL_TREE;
tree incrv = NULL_TREE;
enum c_omp_region_type ort = C_ORT_OMP;
+ bool any_range_for = false;
int i;
if (TREE_CODE (t) == OACC_LOOP)
@@ -17292,6 +17417,7 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
incrv = make_tree_vec (TREE_VEC_LENGTH (OMP_FOR_INIT (t)));
}
+ keep_next_level (true);
stmt = begin_omp_structured_block ();
pre_body = push_stmt_list ();
@@ -17300,14 +17426,31 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
if (OMP_FOR_INIT (t) != NULL_TREE)
for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (t)); i++)
- tsubst_omp_for_iterator (t, i, declv, orig_declv, initv, condv,
- incrv, &clauses, args, complain, in_decl,
- integral_constant_expression_p);
+ any_range_for
+ |= tsubst_omp_for_iterator (t, i, declv, orig_declv, initv,
+ condv, incrv, &clauses, args,
+ complain, in_decl,
+ integral_constant_expression_p);
omp_parallel_combined_clauses = NULL;
- body = push_stmt_list ();
+ if (any_range_for)
+ {
+ gcc_assert (orig_declv);
+ body = begin_omp_structured_block ();
+ for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (t)); i++)
+ if (TREE_VEC_ELT (orig_declv, i) != TREE_VEC_ELT (declv, i)
+ && TREE_CODE (TREE_VEC_ELT (orig_declv, i)) == TREE_LIST
+ && TREE_CHAIN (TREE_VEC_ELT (orig_declv, i)))
+ cp_finish_omp_range_for (TREE_VEC_ELT (orig_declv, i),
+ TREE_VEC_ELT (declv, i));
+ }
+ else
+ body = push_stmt_list ();
RECUR (OMP_FOR_BODY (t));
- body = pop_stmt_list (body);
+ if (any_range_for)
+ body = finish_omp_structured_block (body);
+ else
+ body = pop_stmt_list (body);
if (OMP_FOR_INIT (t) != NULL_TREE)
t = finish_omp_for (EXPR_LOCATION (t), TREE_CODE (t), declv,
@@ -17324,7 +17467,8 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
add_stmt (t);
}
- add_stmt (finish_omp_structured_block (stmt));
+ add_stmt (finish_omp_for_block (finish_omp_structured_block (stmt),
+ t));
pop_omp_privatization_clauses (r);
}
break;
@@ -17335,13 +17479,24 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
case OMP_SINGLE:
case OMP_TEAMS:
case OMP_CRITICAL:
+ case OMP_TASKGROUP:
r = push_omp_privatization_clauses (TREE_CODE (t) == OMP_TEAMS
&& OMP_TEAMS_COMBINED (t));
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);
+ if (TREE_CODE (t) == OMP_TEAMS)
+ {
+ keep_next_level (true);
+ stmt = begin_omp_structured_block ();
+ RECUR (OMP_BODY (t));
+ stmt = finish_omp_structured_block (stmt);
+ }
+ else
+ {
+ stmt = push_stmt_list ();
+ RECUR (OMP_BODY (t));
+ stmt = pop_stmt_list (stmt);
+ }
t = copy_node (t);
OMP_BODY (t) = stmt;
@@ -17350,6 +17505,32 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
pop_omp_privatization_clauses (r);
break;
+ case OMP_DEPOBJ:
+ r = RECUR (OMP_DEPOBJ_DEPOBJ (t));
+ if (OMP_DEPOBJ_CLAUSES (t) && OMP_DEPOBJ_CLAUSES (t) != error_mark_node)
+ {
+ enum omp_clause_depend_kind kind = OMP_CLAUSE_DEPEND_SOURCE;
+ if (TREE_CODE (OMP_DEPOBJ_CLAUSES (t)) == OMP_CLAUSE)
+ {
+ tmp = tsubst_omp_clauses (OMP_DEPOBJ_CLAUSES (t), C_ORT_OMP,
+ args, complain, in_decl);
+ if (tmp == NULL_TREE)
+ tmp = error_mark_node;
+ }
+ else
+ {
+ kind = (enum omp_clause_depend_kind)
+ tree_to_uhwi (OMP_DEPOBJ_CLAUSES (t));
+ tmp = NULL_TREE;
+ }
+ finish_omp_depobj (EXPR_LOCATION (t), r, kind, tmp);
+ }
+ else
+ finish_omp_depobj (EXPR_LOCATION (t), r,
+ OMP_CLAUSE_DEPEND_SOURCE,
+ OMP_DEPOBJ_CLAUSES (t));
+ break;
+
case OACC_DATA:
case OMP_TARGET_DATA:
case OMP_TARGET:
@@ -17441,7 +17622,6 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
case OMP_SECTION:
case OMP_MASTER:
- case OMP_TASKGROUP:
stmt = push_stmt_list ();
RECUR (OMP_BODY (t));
stmt = pop_stmt_list (stmt);
@@ -17453,6 +17633,10 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
case OMP_ATOMIC:
gcc_assert (OMP_ATOMIC_DEPENDENT_P (t));
+ tmp = NULL_TREE;
+ if (TREE_CODE (TREE_OPERAND (t, 0)) == OMP_CLAUSE)
+ tmp = tsubst_omp_clauses (TREE_OPERAND (t, 0), C_ORT_OMP, args,
+ complain, in_decl);
if (TREE_CODE (TREE_OPERAND (t, 1)) != MODIFY_EXPR)
{
tree op1 = TREE_OPERAND (t, 1);
@@ -17465,9 +17649,9 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
}
lhs = RECUR (TREE_OPERAND (op1, 0));
rhs = RECUR (TREE_OPERAND (op1, 1));
- finish_omp_atomic (OMP_ATOMIC, TREE_CODE (op1), lhs, rhs,
- NULL_TREE, NULL_TREE, rhs1,
- OMP_ATOMIC_SEQ_CST (t));
+ finish_omp_atomic (EXPR_LOCATION (t), OMP_ATOMIC, TREE_CODE (op1),
+ lhs, rhs, NULL_TREE, NULL_TREE, rhs1, tmp,
+ OMP_ATOMIC_MEMORY_ORDER (t));
}
else
{
@@ -17504,8 +17688,8 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
lhs = RECUR (TREE_OPERAND (op1, 0));
rhs = RECUR (TREE_OPERAND (op1, 1));
}
- finish_omp_atomic (code, opcode, lhs, rhs, v, lhs1, rhs1,
- OMP_ATOMIC_SEQ_CST (t));
+ finish_omp_atomic (EXPR_LOCATION (t), code, opcode, lhs, rhs, v,
+ lhs1, rhs1, tmp, OMP_ATOMIC_MEMORY_ORDER (t));
}
break;
@@ -25865,6 +26049,9 @@ dependent_omp_for_p (tree declv, tree initv, tree condv, tree incrv)
if (init && type_dependent_expression_p (init))
return true;
+ if (cond == global_namespace)
+ return true;
+
if (type_dependent_expression_p (cond))
return true;
@@ -25891,6 +26078,20 @@ dependent_omp_for_p (tree declv, tree initv, tree condv, tree incrv)
if (type_dependent_expression_p (TREE_OPERAND (t, 0))
|| type_dependent_expression_p (TREE_OPERAND (t, 1)))
return true;
+
+ /* If this loop has a class iterator with != comparison
+ with increment other than i++/++i/i--/--i, make sure the
+ increment is constant. */
+ if (CLASS_TYPE_P (TREE_TYPE (decl))
+ && TREE_CODE (cond) == NE_EXPR)
+ {
+ if (TREE_OPERAND (t, 0) == decl)
+ t = TREE_OPERAND (t, 1);
+ else
+ t = TREE_OPERAND (t, 0);
+ if (TREE_CODE (t) != INTEGER_CST)
+ return true;
+ }
}
}
}
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index b54ecb0..182d360 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -44,6 +44,7 @@ along with GCC; see the file COPYING3. If not see
#include "attribs.h"
#include "gomp-constants.h"
#include "predict.h"
+#include "memmodel.h"
/* There routines provide a modular interface to perform many parsing
operations. They may therefore be used during actual parsing, or
@@ -4634,7 +4635,9 @@ handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types,
}
if (ort == C_ORT_OMP
- && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
+ && (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
+ || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
+ || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION)
&& TREE_CODE (TREE_CHAIN (t)) == FIELD_DECL)
TREE_CHAIN (t) = omp_privatize_field (TREE_CHAIN (t), false);
ret = handle_omp_array_sections_1 (c, TREE_CHAIN (t), types,
@@ -4693,7 +4696,9 @@ handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types,
if (!integer_nonzerop (length))
{
if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
- || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION)
+ || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
+ || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
+ || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION)
{
if (integer_zerop (length))
{
@@ -4759,7 +4764,9 @@ handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types,
if (tree_int_cst_equal (size, low_bound))
{
if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
- || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION)
+ || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
+ || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
+ || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION)
{
error_at (OMP_CLAUSE_LOCATION (c),
"zero length array section in %qs clause",
@@ -4778,7 +4785,9 @@ handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types,
else if (length == NULL_TREE)
{
if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
- && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_REDUCTION)
+ && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_REDUCTION
+ && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_IN_REDUCTION
+ && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_TASK_REDUCTION)
maybe_zero_len = true;
if (first_non_one == types.length ())
first_non_one++;
@@ -4814,7 +4823,9 @@ handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types,
else if (length == NULL_TREE)
{
if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
- && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_REDUCTION)
+ && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_REDUCTION
+ && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_IN_REDUCTION
+ && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_TASK_REDUCTION)
maybe_zero_len = true;
if (first_non_one == types.length ())
first_non_one++;
@@ -4886,7 +4897,13 @@ handle_omp_array_sections (tree c, enum c_omp_region_type ort)
bool maybe_zero_len = false;
unsigned int first_non_one = 0;
auto_vec<tree, 10> types;
- tree first = handle_omp_array_sections_1 (c, OMP_CLAUSE_DECL (c), types,
+ tree *tp = &OMP_CLAUSE_DECL (c);
+ if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
+ && TREE_CODE (*tp) == TREE_LIST
+ && TREE_PURPOSE (*tp)
+ && TREE_CODE (TREE_PURPOSE (*tp)) == TREE_VEC)
+ tp = &TREE_VALUE (*tp);
+ tree first = handle_omp_array_sections_1 (c, *tp, types,
maybe_zero_len, first_non_one,
ort);
if (first == error_mark_node)
@@ -4895,7 +4912,7 @@ handle_omp_array_sections (tree c, enum c_omp_region_type ort)
return false;
if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND)
{
- tree t = OMP_CLAUSE_DECL (c);
+ tree t = *tp;
tree tem = NULL_TREE;
if (processing_template_decl)
return false;
@@ -4915,7 +4932,7 @@ handle_omp_array_sections (tree c, enum c_omp_region_type ort)
}
if (tem)
first = build2 (COMPOUND_EXPR, TREE_TYPE (first), tem, first);
- OMP_CLAUSE_DECL (c) = first;
+ *tp = first;
}
else
{
@@ -4992,7 +5009,9 @@ handle_omp_array_sections (tree c, enum c_omp_region_type ort)
if (i > first_non_one
&& ((length && integer_nonzerop (length))
- || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION))
+ || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
+ || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
+ || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION))
continue;
if (length)
l = fold_convert (sizetype, length);
@@ -5020,7 +5039,9 @@ handle_omp_array_sections (tree c, enum c_omp_region_type ort)
tree eltype = TREE_TYPE (types[num - 1]);
while (TREE_CODE (eltype) == ARRAY_TYPE)
eltype = TREE_TYPE (eltype);
- if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION)
+ if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
+ || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
+ || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION)
size = size_binop (EXACT_DIV_EXPR, size,
size_in_bytes (eltype));
size = size_binop (MULT_EXPR, size, l);
@@ -5036,9 +5057,12 @@ handle_omp_array_sections (tree c, enum c_omp_region_type ort)
{
if (side_effects)
size = build2 (COMPOUND_EXPR, sizetype, side_effects, size);
- if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION)
+ if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
+ || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
+ || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION)
{
size = size_binop (MINUS_EXPR, size, size_one_node);
+ size = save_expr (size);
tree index_type = build_index_type (size);
tree eltype = TREE_TYPE (first);
while (TREE_CODE (eltype) == ARRAY_TYPE)
@@ -5576,11 +5600,13 @@ finish_omp_reduction_clause (tree c, bool *need_default_ctor, bool *need_dtor)
TYPE_SIZE_UNIT (type));
if (integer_zerop (size))
{
- error ("%qE in %<reduction%> clause is a zero size array",
- omp_clause_printable_decl (t));
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE in %<reduction%> clause is a zero size array",
+ omp_clause_printable_decl (t));
return true;
}
size = size_binop (MINUS_EXPR, size, size_one_node);
+ size = save_expr (size);
tree index_type = build_index_type (size);
tree atype = build_array_type (type, index_type);
tree ptype = build_pointer_type (type);
@@ -5624,8 +5650,9 @@ finish_omp_reduction_clause (tree c, bool *need_default_ctor, bool *need_dtor)
}
else if (TYPE_READONLY (type))
{
- error ("%qE has const type for %<reduction%>",
- omp_clause_printable_decl (t));
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE has const type for %<reduction%>",
+ omp_clause_printable_decl (t));
return true;
}
else if (!processing_template_decl)
@@ -5699,7 +5726,8 @@ finish_omp_reduction_clause (tree c, bool *need_default_ctor, bool *need_dtor)
if (TREE_ADDRESSABLE (DECL_EXPR_DECL (stmts[0])))
cxx_mark_addressable (placeholder);
if (TREE_ADDRESSABLE (DECL_EXPR_DECL (stmts[1]))
- && !TYPE_REF_P (TREE_TYPE (OMP_CLAUSE_DECL (c))))
+ && (decl_placeholder
+ || !TYPE_REF_P (TREE_TYPE (OMP_CLAUSE_DECL (c)))))
cxx_mark_addressable (decl_placeholder ? decl_placeholder
: OMP_CLAUSE_DECL (c));
tree omp_out = placeholder;
@@ -5725,7 +5753,9 @@ finish_omp_reduction_clause (tree c, bool *need_default_ctor, bool *need_dtor)
{
gcc_assert (TREE_CODE (stmts[3]) == DECL_EXPR
&& TREE_CODE (stmts[4]) == DECL_EXPR);
- if (TREE_ADDRESSABLE (DECL_EXPR_DECL (stmts[3])))
+ if (TREE_ADDRESSABLE (DECL_EXPR_DECL (stmts[3]))
+ && (decl_placeholder
+ || !TYPE_REF_P (TREE_TYPE (OMP_CLAUSE_DECL (c)))))
cxx_mark_addressable (decl_placeholder ? decl_placeholder
: OMP_CLAUSE_DECL (c));
if (TREE_ADDRESSABLE (DECL_EXPR_DECL (stmts[4])))
@@ -5786,8 +5816,9 @@ finish_omp_reduction_clause (tree c, bool *need_default_ctor, bool *need_dtor)
*need_dtor = true;
else
{
- error ("user defined reduction not found for %qE",
- omp_clause_printable_decl (t));
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "user defined reduction not found for %qE",
+ omp_clause_printable_decl (t));
return true;
}
if (TREE_CODE (OMP_CLAUSE_DECL (c)) == MEM_REF)
@@ -5868,6 +5899,155 @@ cp_finish_omp_clause_depend_sink (tree sink_clause)
return false;
}
+/* Finish OpenMP iterators ITER. Return true if they are errorneous
+ and clauses containing them should be removed. */
+
+static bool
+cp_omp_finish_iterators (tree iter)
+{
+ bool ret = false;
+ for (tree it = iter; it; it = TREE_CHAIN (it))
+ {
+ tree var = TREE_VEC_ELT (it, 0);
+ tree begin = TREE_VEC_ELT (it, 1);
+ tree end = TREE_VEC_ELT (it, 2);
+ tree step = TREE_VEC_ELT (it, 3);
+ tree orig_step;
+ tree type = TREE_TYPE (var);
+ location_t loc = DECL_SOURCE_LOCATION (var);
+ if (type == error_mark_node)
+ {
+ ret = true;
+ continue;
+ }
+ if (type_dependent_expression_p (var))
+ continue;
+ if (!INTEGRAL_TYPE_P (type) && !POINTER_TYPE_P (type))
+ {
+ error_at (loc, "iterator %qD has neither integral nor pointer type",
+ var);
+ ret = true;
+ continue;
+ }
+ else if (TYPE_READONLY (type))
+ {
+ error_at (loc, "iterator %qD has const qualified type", var);
+ ret = true;
+ continue;
+ }
+ if (type_dependent_expression_p (begin)
+ || type_dependent_expression_p (end)
+ || type_dependent_expression_p (step))
+ continue;
+ else if (error_operand_p (step))
+ {
+ ret = true;
+ continue;
+ }
+ else if (!INTEGRAL_TYPE_P (TREE_TYPE (step)))
+ {
+ error_at (EXPR_LOC_OR_LOC (step, loc),
+ "iterator step with non-integral type");
+ ret = true;
+ continue;
+ }
+
+ begin = mark_rvalue_use (begin);
+ end = mark_rvalue_use (end);
+ step = mark_rvalue_use (step);
+ begin = cp_build_c_cast (type, begin, tf_warning_or_error);
+ end = cp_build_c_cast (type, end, tf_warning_or_error);
+ orig_step = step;
+ if (!processing_template_decl)
+ step = orig_step = save_expr (step);
+ tree stype = POINTER_TYPE_P (type) ? sizetype : type;
+ step = cp_build_c_cast (stype, step, tf_warning_or_error);
+ if (POINTER_TYPE_P (type) && !processing_template_decl)
+ {
+ begin = save_expr (begin);
+ step = pointer_int_sum (loc, PLUS_EXPR, begin, step);
+ step = fold_build2_loc (loc, MINUS_EXPR, sizetype,
+ fold_convert (sizetype, step),
+ fold_convert (sizetype, begin));
+ step = fold_convert (ssizetype, step);
+ }
+ if (!processing_template_decl)
+ {
+ begin = maybe_constant_value (begin);
+ end = maybe_constant_value (end);
+ step = maybe_constant_value (step);
+ orig_step = maybe_constant_value (orig_step);
+ }
+ if (integer_zerop (step))
+ {
+ error_at (loc, "iterator %qD has zero step", var);
+ ret = true;
+ continue;
+ }
+
+ if (begin == error_mark_node
+ || end == error_mark_node
+ || step == error_mark_node
+ || orig_step == error_mark_node)
+ {
+ ret = true;
+ continue;
+ }
+
+ if (!processing_template_decl)
+ {
+ begin = fold_build_cleanup_point_expr (TREE_TYPE (begin), begin);
+ end = fold_build_cleanup_point_expr (TREE_TYPE (end), end);
+ step = fold_build_cleanup_point_expr (TREE_TYPE (step), step);
+ orig_step = fold_build_cleanup_point_expr (TREE_TYPE (orig_step),
+ orig_step);
+ }
+ hash_set<tree> pset;
+ tree it2;
+ for (it2 = TREE_CHAIN (it); it2; it2 = TREE_CHAIN (it2))
+ {
+ tree var2 = TREE_VEC_ELT (it2, 0);
+ tree begin2 = TREE_VEC_ELT (it2, 1);
+ tree end2 = TREE_VEC_ELT (it2, 2);
+ tree step2 = TREE_VEC_ELT (it2, 3);
+ location_t loc2 = DECL_SOURCE_LOCATION (var2);
+ if (cp_walk_tree (&begin2, find_omp_placeholder_r, var, &pset))
+ {
+ error_at (EXPR_LOC_OR_LOC (begin2, loc2),
+ "begin expression refers to outer iterator %qD", var);
+ break;
+ }
+ else if (cp_walk_tree (&end2, find_omp_placeholder_r, var, &pset))
+ {
+ error_at (EXPR_LOC_OR_LOC (end2, loc2),
+ "end expression refers to outer iterator %qD", var);
+ break;
+ }
+ else if (cp_walk_tree (&step2, find_omp_placeholder_r, var, &pset))
+ {
+ error_at (EXPR_LOC_OR_LOC (step2, loc2),
+ "step expression refers to outer iterator %qD", var);
+ break;
+ }
+ }
+ if (it2)
+ {
+ ret = true;
+ continue;
+ }
+ TREE_VEC_ELT (it, 1) = begin;
+ TREE_VEC_ELT (it, 2) = end;
+ if (processing_template_decl)
+ TREE_VEC_ELT (it, 3) = orig_step;
+ else
+ {
+ TREE_VEC_ELT (it, 3) = step;
+ TREE_VEC_ELT (it, 4) = orig_step;
+ }
+ }
+ return ret;
+}
+
/* For all elements of CLAUSES, validate them vs OpenMP constraints.
Remove any elements from the list that are invalid. */
@@ -5882,14 +6062,19 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
bool copyprivate_seen = false;
bool ordered_seen = false;
bool oacc_async = false;
+ tree last_iterators = NULL_TREE;
+ bool last_iterators_remove = false;
+ bool reduction_seen = false;
bitmap_obstack_initialize (NULL);
bitmap_initialize (&generic_head, &bitmap_default_obstack);
bitmap_initialize (&firstprivate_head, &bitmap_default_obstack);
bitmap_initialize (&lastprivate_head, &bitmap_default_obstack);
bitmap_initialize (&aligned_head, &bitmap_default_obstack);
+ /* If ort == C_ORT_OMP_DECLARE_SIMD used as uniform_head instead. */
bitmap_initialize (&map_head, &bitmap_default_obstack);
bitmap_initialize (&map_field_head, &bitmap_default_obstack);
+ /* If ort == C_ORT_OMP used as nontemporal_head instead. */
bitmap_initialize (&oacc_reduction_head, &bitmap_default_obstack);
if (ort & C_ORT_ACC)
@@ -5914,6 +6099,10 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
field_ok = ((ort & C_ORT_OMP_DECLARE_SIMD) == C_ORT_OMP);
goto check_dup_generic;
case OMP_CLAUSE_REDUCTION:
+ reduction_seen = true;
+ /* FALLTHRU */
+ case OMP_CLAUSE_IN_REDUCTION:
+ case OMP_CLAUSE_TASK_REDUCTION:
field_ok = ((ort & C_ORT_OMP_DECLARE_SIMD) == C_ORT_OMP);
t = OMP_CLAUSE_DECL (c);
if (TREE_CODE (t) == TREE_LIST)
@@ -5971,10 +6160,11 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
|| OMP_CLAUSE_LINEAR_KIND (c) == OMP_CLAUSE_LINEAR_UVAL)
&& !TYPE_REF_P (type))
{
- error ("linear clause with %qs modifier applied to "
- "non-reference variable with %qT type",
- OMP_CLAUSE_LINEAR_KIND (c) == OMP_CLAUSE_LINEAR_REF
- ? "ref" : "uval", TREE_TYPE (t));
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "linear clause with %qs modifier applied to "
+ "non-reference variable with %qT type",
+ OMP_CLAUSE_LINEAR_KIND (c) == OMP_CLAUSE_LINEAR_REF
+ ? "ref" : "uval", TREE_TYPE (t));
remove = true;
break;
}
@@ -5985,8 +6175,10 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
if (!INTEGRAL_TYPE_P (type)
&& !TYPE_PTR_P (type))
{
- error ("linear clause applied to non-integral non-pointer"
- " variable with %qT type", TREE_TYPE (t));
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "linear clause applied to non-integral "
+ "non-pointer variable with %qT type",
+ TREE_TYPE (t));
remove = true;
break;
}
@@ -6007,7 +6199,8 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
|| !TYPE_REF_P (TREE_TYPE (t))
|| !INTEGRAL_TYPE_P (TREE_TYPE (TREE_TYPE (t)))))
{
- error ("linear step expression must be integral");
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "linear step expression must be integral");
remove = true;
break;
}
@@ -6099,8 +6292,9 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
|| (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_LINEAR
&& OMP_CLAUSE_CODE (c) != OMP_CLAUSE_UNIFORM)))
{
- error ("%<this%> allowed in OpenMP only in %<declare simd%>"
- " clauses");
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%<this%> allowed in OpenMP only in %<declare simd%>"
+ " clauses");
remove = true;
break;
}
@@ -6110,11 +6304,13 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
if (processing_template_decl && TREE_CODE (t) != OVERLOAD)
break;
if (DECL_P (t))
- error ("%qD is not a variable in clause %qs", t,
- omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD is not a variable in clause %qs", t,
+ omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
else
- error ("%qE is not a variable in clause %qs", t,
- omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE is not a variable in clause %qs", t,
+ omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
remove = true;
}
else if (ort == C_ORT_ACC
@@ -6122,7 +6318,9 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
{
if (bitmap_bit_p (&oacc_reduction_head, DECL_UID (t)))
{
- error ("%qD appears more than once in reduction clauses", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD appears more than once in reduction clauses",
+ t);
remove = true;
}
else
@@ -6132,16 +6330,19 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
|| bitmap_bit_p (&firstprivate_head, DECL_UID (t))
|| bitmap_bit_p (&lastprivate_head, DECL_UID (t)))
{
- error ("%qD appears more than once in data clauses", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD appears more than once in data clauses", t);
remove = true;
}
else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_PRIVATE
&& bitmap_bit_p (&map_head, DECL_UID (t)))
{
if (ort == C_ORT_ACC)
- error ("%qD appears more than once in data clauses", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD appears more than once in data clauses", t);
else
- error ("%qD appears both in data and map clauses", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD appears both in data and map clauses", t);
remove = true;
}
else
@@ -6170,8 +6371,9 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
t = OMP_CLAUSE_DECL (c);
if (ort != C_ORT_ACC && t == current_class_ptr)
{
- error ("%<this%> allowed in OpenMP only in %<declare simd%>"
- " clauses");
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%<this%> allowed in OpenMP only in %<declare simd%>"
+ " clauses");
remove = true;
break;
}
@@ -6182,23 +6384,30 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
if (processing_template_decl && TREE_CODE (t) != OVERLOAD)
break;
if (DECL_P (t))
- error ("%qD is not a variable in clause %<firstprivate%>", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD is not a variable in clause %<firstprivate%>",
+ t);
else
- error ("%qE is not a variable in clause %<firstprivate%>", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE is not a variable in clause %<firstprivate%>",
+ t);
remove = true;
}
else if (bitmap_bit_p (&generic_head, DECL_UID (t))
|| bitmap_bit_p (&firstprivate_head, DECL_UID (t)))
{
- error ("%qD appears more than once in data clauses", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD appears more than once in data clauses", t);
remove = true;
}
else if (bitmap_bit_p (&map_head, DECL_UID (t)))
{
if (ort == C_ORT_ACC)
- error ("%qD appears more than once in data clauses", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD appears more than once in data clauses", t);
else
- error ("%qD appears both in data and map clauses", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD appears both in data and map clauses", t);
remove = true;
}
else
@@ -6213,8 +6422,9 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
t = OMP_CLAUSE_DECL (c);
if (t == current_class_ptr)
{
- error ("%<this%> allowed in OpenMP only in %<declare simd%>"
- " clauses");
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%<this%> allowed in OpenMP only in %<declare simd%>"
+ " clauses");
remove = true;
break;
}
@@ -6225,15 +6435,20 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
if (processing_template_decl && TREE_CODE (t) != OVERLOAD)
break;
if (DECL_P (t))
- error ("%qD is not a variable in clause %<lastprivate%>", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD is not a variable in clause %<lastprivate%>",
+ t);
else
- error ("%qE is not a variable in clause %<lastprivate%>", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE is not a variable in clause %<lastprivate%>",
+ t);
remove = true;
}
else if (bitmap_bit_p (&generic_head, DECL_UID (t))
|| bitmap_bit_p (&lastprivate_head, DECL_UID (t)))
{
- error ("%qD appears more than once in data clauses", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD appears more than once in data clauses", t);
remove = true;
}
else
@@ -6270,7 +6485,8 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
else if (!type_dependent_expression_p (t)
&& !INTEGRAL_TYPE_P (TREE_TYPE (t)))
{
- error ("%<gang%> static expression must be integral");
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%<gang%> static expression must be integral");
remove = true;
}
else
@@ -6374,30 +6590,6 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
break;
case OMP_CLAUSE_SCHEDULE:
- if (OMP_CLAUSE_SCHEDULE_KIND (c) & OMP_CLAUSE_SCHEDULE_NONMONOTONIC)
- {
- const char *p = NULL;
- switch (OMP_CLAUSE_SCHEDULE_KIND (c) & OMP_CLAUSE_SCHEDULE_MASK)
- {
- case OMP_CLAUSE_SCHEDULE_STATIC: p = "static"; break;
- case OMP_CLAUSE_SCHEDULE_DYNAMIC: break;
- case OMP_CLAUSE_SCHEDULE_GUIDED: break;
- case OMP_CLAUSE_SCHEDULE_AUTO: p = "auto"; break;
- case OMP_CLAUSE_SCHEDULE_RUNTIME: p = "runtime"; break;
- default: gcc_unreachable ();
- }
- if (p)
- {
- error_at (OMP_CLAUSE_LOCATION (c),
- "%<nonmonotonic%> modifier specified for %qs "
- "schedule kind", p);
- OMP_CLAUSE_SCHEDULE_KIND (c)
- = (enum omp_clause_schedule_kind)
- (OMP_CLAUSE_SCHEDULE_KIND (c)
- & ~OMP_CLAUSE_SCHEDULE_NONMONOTONIC);
- }
- }
-
t = OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (c);
if (t == NULL)
;
@@ -6406,7 +6598,8 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
else if (!type_dependent_expression_p (t)
&& !INTEGRAL_TYPE_P (TREE_TYPE (t)))
{
- error ("schedule chunk size expression must be integral");
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "schedule chunk size expression must be integral");
remove = true;
}
else
@@ -6436,8 +6629,9 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
else if (!type_dependent_expression_p (t)
&& !INTEGRAL_TYPE_P (TREE_TYPE (t)))
{
- error ("%qs length expression must be integral",
- omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qs length expression must be integral",
+ omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
remove = true;
}
else
@@ -6449,9 +6643,10 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
if (TREE_CODE (t) != INTEGER_CST
|| tree_int_cst_sgn (t) != 1)
{
- error ("%qs length expression must be positive constant"
- " integer expression",
- omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qs length expression must be positive "
+ "constant integer expression",
+ omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
remove = true;
}
}
@@ -6468,7 +6663,8 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
else if (!type_dependent_expression_p (t)
&& !INTEGRAL_TYPE_P (TREE_TYPE (t)))
{
- error ("%<async%> expression must be integral");
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%<async%> expression must be integral");
remove = true;
}
else
@@ -6496,7 +6692,8 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
else if (!type_dependent_expression_p (t)
&& !INTEGRAL_TYPE_P (TREE_TYPE (t)))
{
- error ("%<thread_limit%> expression must be integral");
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%<thread_limit%> expression must be integral");
remove = true;
}
else
@@ -6525,7 +6722,8 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
else if (!type_dependent_expression_p (t)
&& !INTEGRAL_TYPE_P (TREE_TYPE (t)))
{
- error ("%<device%> id must be integral");
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%<device%> id must be integral");
remove = true;
}
else
@@ -6546,14 +6744,15 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
else if (!type_dependent_expression_p (t)
&& !INTEGRAL_TYPE_P (TREE_TYPE (t)))
{
- error ("%<dist_schedule%> chunk size expression must be "
- "integral");
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%<dist_schedule%> chunk size expression must be "
+ "integral");
remove = true;
}
else
{
t = mark_rvalue_use (t);
- if (!processing_template_decl)
+ if (!processing_template_decl)
t = fold_build_cleanup_point_expr (TREE_TYPE (t), t);
OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (c) = t;
}
@@ -6563,8 +6762,9 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
t = OMP_CLAUSE_DECL (c);
if (t == current_class_ptr && ort != C_ORT_OMP_DECLARE_SIMD)
{
- error ("%<this%> allowed in OpenMP only in %<declare simd%>"
- " clauses");
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%<this%> allowed in OpenMP only in %<declare simd%>"
+ " clauses");
remove = true;
break;
}
@@ -6573,9 +6773,11 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
if (processing_template_decl && TREE_CODE (t) != OVERLOAD)
break;
if (DECL_P (t))
- error ("%qD is not a variable in %<aligned%> clause", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD is not a variable in %<aligned%> clause", t);
else
- error ("%qE is not a variable in %<aligned%> clause", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE is not a variable in %<aligned%> clause", t);
remove = true;
}
else if (!type_dependent_expression_p (t)
@@ -6593,7 +6795,9 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
}
else if (bitmap_bit_p (&aligned_head, DECL_UID (t)))
{
- error ("%qD appears more than once in %<aligned%> clauses", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD appears more than once in %<aligned%> clauses",
+ t);
remove = true;
}
else
@@ -6606,8 +6810,9 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
else if (!type_dependent_expression_p (t)
&& !INTEGRAL_TYPE_P (TREE_TYPE (t)))
{
- error ("%<aligned%> clause alignment expression must "
- "be integral");
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%<aligned%> clause alignment expression must "
+ "be integral");
remove = true;
}
else
@@ -6619,15 +6824,45 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
if (TREE_CODE (t) != INTEGER_CST
|| tree_int_cst_sgn (t) != 1)
{
- error ("%<aligned%> clause alignment expression must be "
- "positive constant integer expression");
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%<aligned%> clause alignment expression must "
+ "be positive constant integer expression");
remove = true;
}
+ else
+ t = fold_build_cleanup_point_expr (TREE_TYPE (t), t);
}
OMP_CLAUSE_ALIGNED_ALIGNMENT (c) = t;
}
break;
+ case OMP_CLAUSE_NONTEMPORAL:
+ t = OMP_CLAUSE_DECL (c);
+ if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
+ {
+ if (processing_template_decl && TREE_CODE (t) != OVERLOAD)
+ break;
+ if (DECL_P (t))
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD is not a variable in %<nontemporal%> clause",
+ t);
+ else
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE is not a variable in %<nontemporal%> clause",
+ t);
+ remove = true;
+ }
+ else if (bitmap_bit_p (&oacc_reduction_head, DECL_UID (t)))
+ {
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD appears more than once in %<nontemporal%> "
+ "clauses", t);
+ remove = true;
+ }
+ else
+ bitmap_set_bit (&oacc_reduction_head, DECL_UID (t));
+ break;
+
case OMP_CLAUSE_DEPEND:
t = OMP_CLAUSE_DECL (c);
if (t == NULL_TREE)
@@ -6642,33 +6877,108 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
remove = true;
break;
}
+ if (TREE_CODE (t) == TREE_LIST
+ && TREE_PURPOSE (t)
+ && TREE_CODE (TREE_PURPOSE (t)) == TREE_VEC)
+ {
+ if (TREE_PURPOSE (t) != last_iterators)
+ last_iterators_remove
+ = cp_omp_finish_iterators (TREE_PURPOSE (t));
+ last_iterators = TREE_PURPOSE (t);
+ t = TREE_VALUE (t);
+ if (last_iterators_remove)
+ t = error_mark_node;
+ }
+ else
+ last_iterators = NULL_TREE;
+
if (TREE_CODE (t) == TREE_LIST)
{
if (handle_omp_array_sections (c, ort))
remove = true;
+ else if (OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_DEPOBJ)
+ {
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%<depend%> clause with %<depobj%> dependence "
+ "type on array section");
+ remove = true;
+ }
break;
}
if (t == error_mark_node)
remove = true;
- else if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
+ else if (t == current_class_ptr)
+ {
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%<this%> allowed in OpenMP only in %<declare simd%>"
+ " clauses");
+ remove = true;
+ }
+ else if (processing_template_decl && TREE_CODE (t) != OVERLOAD)
+ break;
+ else if (!lvalue_p (t))
{
- if (processing_template_decl && TREE_CODE (t) != OVERLOAD)
- break;
if (DECL_P (t))
- error ("%qD is not a variable in %<depend%> clause", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD is not lvalue expression nor array section "
+ "in %<depend%> clause", t);
else
- error ("%qE is not a variable in %<depend%> clause", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE is not lvalue expression nor array section "
+ "in %<depend%> clause", t);
remove = true;
}
- else if (t == current_class_ptr)
+ else if (TREE_CODE (t) == COMPONENT_REF
+ && TREE_CODE (TREE_OPERAND (t, 1)) == FIELD_DECL
+ && DECL_BIT_FIELD (TREE_OPERAND (t, 1)))
{
- error ("%<this%> allowed in OpenMP only in %<declare simd%>"
- " clauses");
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "bit-field %qE in %qs clause", t, "depend");
remove = true;
}
- else if (!processing_template_decl
- && !cxx_mark_addressable (t))
- remove = true;
+ else if (OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_DEPOBJ)
+ {
+ if (!c_omp_depend_t_p (TYPE_REF_P (TREE_TYPE (t))
+ ? TREE_TYPE (TREE_TYPE (t))
+ : TREE_TYPE (t)))
+ {
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE does not have %<omp_depend_t%> type in "
+ "%<depend%> clause with %<depobj%> dependence "
+ "type", t);
+ remove = true;
+ }
+ }
+ else if (c_omp_depend_t_p (TYPE_REF_P (TREE_TYPE (t))
+ ? TREE_TYPE (TREE_TYPE (t))
+ : TREE_TYPE (t)))
+ {
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE should not have %<omp_depend_t%> type in "
+ "%<depend%> clause with dependence type other than "
+ "%<depobj%>", t);
+ remove = true;
+ }
+ if (!remove)
+ {
+ tree addr = cp_build_addr_expr (t, tf_warning_or_error);
+ if (addr == error_mark_node)
+ remove = true;
+ else
+ {
+ t = cp_build_indirect_ref (addr, RO_UNARY_STAR,
+ tf_warning_or_error);
+ if (t == error_mark_node)
+ remove = true;
+ else if (TREE_CODE (OMP_CLAUSE_DECL (c)) == TREE_LIST
+ && TREE_PURPOSE (OMP_CLAUSE_DECL (c))
+ && (TREE_CODE (TREE_PURPOSE (OMP_CLAUSE_DECL (c)))
+ == TREE_VEC))
+ TREE_VALUE (OMP_CLAUSE_DECL (c)) = t;
+ else
+ OMP_CLAUSE_DECL (c) = t;
+ }
+ }
break;
case OMP_CLAUSE_MAP:
@@ -6707,14 +7017,17 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
if (bitmap_bit_p (&map_head, DECL_UID (t)))
{
if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP)
- error ("%qD appears more than once in motion"
- " clauses", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD appears more than once in motion"
+ " clauses", t);
else if (ort == C_ORT_ACC)
- error ("%qD appears more than once in data"
- " clauses", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD appears more than once in data"
+ " clauses", t);
else
- error ("%qD appears more than once in map"
- " clauses", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD appears more than once in map"
+ " clauses", t);
remove = true;
}
else
@@ -6790,23 +7103,27 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
|| OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ALWAYS_POINTER))
break;
if (DECL_P (t))
- error ("%qD is not a variable in %qs clause", t,
- omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD is not a variable in %qs clause", t,
+ omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
else
- error ("%qE is not a variable in %qs clause", t,
- omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE is not a variable in %qs clause", t,
+ omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
remove = true;
}
else if (VAR_P (t) && CP_DECL_THREAD_LOCAL_P (t))
{
- error ("%qD is threadprivate variable in %qs clause", t,
- omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD is threadprivate variable in %qs clause", t,
+ omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
remove = true;
}
else if (ort != C_ORT_ACC && t == current_class_ptr)
{
- error ("%<this%> allowed in OpenMP only in %<declare simd%>"
- " clauses");
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%<this%> allowed in OpenMP only in %<declare simd%>"
+ " clauses");
remove = true;
break;
}
@@ -6837,7 +7154,8 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
&& !type_dependent_expression_p (t)
&& !INDIRECT_TYPE_P (TREE_TYPE (t)))
{
- error ("%qD is not a pointer variable", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD is not a pointer variable", t);
remove = true;
}
else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
@@ -6846,15 +7164,18 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
if (bitmap_bit_p (&generic_head, DECL_UID (t))
|| bitmap_bit_p (&firstprivate_head, DECL_UID (t)))
{
- error ("%qD appears more than once in data clauses", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD appears more than once in data clauses", t);
remove = true;
}
else if (bitmap_bit_p (&map_head, DECL_UID (t)))
{
if (ort == C_ORT_ACC)
- error ("%qD appears more than once in data clauses", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD appears more than once in data clauses", t);
else
- error ("%qD appears both in data and map clauses", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD appears both in data and map clauses", t);
remove = true;
}
else
@@ -6863,20 +7184,25 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
else if (bitmap_bit_p (&map_head, DECL_UID (t)))
{
if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP)
- error ("%qD appears more than once in motion clauses", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD appears more than once in motion clauses", t);
if (ort == C_ORT_ACC)
- error ("%qD appears more than once in data clauses", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD appears more than once in data clauses", t);
else
- error ("%qD appears more than once in map clauses", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD appears more than once in map clauses", t);
remove = true;
}
else if (bitmap_bit_p (&generic_head, DECL_UID (t))
|| bitmap_bit_p (&firstprivate_head, DECL_UID (t)))
{
if (ort == C_ORT_ACC)
- error ("%qD appears more than once in data clauses", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD appears more than once in data clauses", t);
else
- error ("%qD appears both in data and map clauses", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD appears both in data and map clauses", t);
remove = true;
}
else
@@ -6991,9 +7317,11 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
if (processing_template_decl)
break;
if (DECL_P (t))
- error ("%qD is not an argument in %<uniform%> clause", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD is not an argument in %<uniform%> clause", t);
else
- error ("%qE is not an argument in %<uniform%> clause", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE is not an argument in %<uniform%> clause", t);
remove = true;
break;
}
@@ -7008,7 +7336,8 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
else if (!type_dependent_expression_p (t)
&& !INTEGRAL_TYPE_P (TREE_TYPE (t)))
{
- error ("%<grainsize%> expression must be integral");
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%<grainsize%> expression must be integral");
remove = true;
}
else
@@ -7037,7 +7366,8 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
else if (!type_dependent_expression_p (t)
&& !INTEGRAL_TYPE_P (TREE_TYPE (t)))
{
- error ("%<priority%> expression must be integral");
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%<priority%> expression must be integral");
remove = true;
}
else
@@ -7066,7 +7396,8 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
else if (!type_dependent_expression_p (t)
&& !INTEGRAL_TYPE_P (TREE_TYPE (t)))
{
- error ("%<num_tasks%> expression must be integral");
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%<hint%> expression must be integral");
remove = true;
}
else
@@ -7076,6 +7407,13 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
{
t = maybe_constant_value (t);
t = fold_build_cleanup_point_expr (TREE_TYPE (t), t);
+ if (TREE_CODE (t) != INTEGER_CST)
+ {
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%<hint%> expression must be constant integer "
+ "expression");
+ remove = true;
+ }
}
OMP_CLAUSE_HINT_EXPR (c) = t;
}
@@ -7172,8 +7510,9 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
case OMP_CLAUSE_NOTINBRANCH:
if (branch_seen)
{
- error ("%<inbranch%> clause is incompatible with "
- "%<notinbranch%>");
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%<inbranch%> clause is incompatible with "
+ "%<notinbranch%>");
remove = true;
}
branch_seen = true;
@@ -7224,6 +7563,8 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
need_implicitly_determined = true;
break;
case OMP_CLAUSE_REDUCTION:
+ case OMP_CLAUSE_IN_REDUCTION:
+ case OMP_CLAUSE_TASK_REDUCTION:
need_implicitly_determined = true;
break;
case OMP_CLAUSE_LINEAR:
@@ -7276,6 +7617,17 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
}
pc = &OMP_CLAUSE_CHAIN (c);
continue;
+ case OMP_CLAUSE_NOGROUP:
+ if (reduction_seen)
+ {
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%<nogroup%> clause must not be used together with "
+ "%<reduction%> clause");
+ *pc = OMP_CLAUSE_CHAIN (c);
+ continue;
+ }
+ pc = &OMP_CLAUSE_CHAIN (c);
+ continue;
case OMP_CLAUSE_NOWAIT:
if (copyprivate_seen)
{
@@ -7310,6 +7662,8 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
break;
case OMP_CLAUSE_REDUCTION:
+ case OMP_CLAUSE_IN_REDUCTION:
+ case OMP_CLAUSE_TASK_REDUCTION:
if (finish_omp_reduction_clause (c, &need_default_ctor,
&need_dtor))
remove = true;
@@ -7320,7 +7674,8 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
case OMP_CLAUSE_COPYIN:
if (!VAR_P (t) || !CP_DECL_THREAD_LOCAL_P (t))
{
- error ("%qE must be %<threadprivate%> for %<copyin%>", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE must be %<threadprivate%> for %<copyin%>", t);
remove = true;
}
break;
@@ -7349,10 +7704,17 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
break;
case OMP_CLAUSE_DEFAULT_SHARED:
- /* const vars may be specified in firstprivate clause. */
- if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FIRSTPRIVATE
+ if (VAR_P (t)
+ && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FIRSTPRIVATE
+ && TREE_STATIC (t)
&& cxx_omp_const_qual_no_mutable (t))
- break;
+ {
+ tree ctx = CP_DECL_CONTEXT (t);
+ /* const qualified static data members without mutable
+ member may be specified in firstprivate clause. */
+ if (TYPE_P (ctx) && MAYBE_CLASS_TYPE_P (ctx))
+ break;
+ }
share_name = "shared";
break;
case OMP_CLAUSE_DEFAULT_PRIVATE:
@@ -7363,9 +7725,20 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
}
if (share_name)
{
- error ("%qE is predetermined %qs for %qs",
- omp_clause_printable_decl (t), share_name,
- omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE is predetermined %qs for %qs",
+ omp_clause_printable_decl (t), share_name,
+ omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
+ remove = true;
+ }
+ else if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_SHARED
+ && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_FIRSTPRIVATE
+ && cxx_omp_const_qual_no_mutable (t))
+ {
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%<const%> qualified %qE without %<mutable%> member "
+ "may appear only in %<shared%> or %<firstprivate%> "
+ "clauses", omp_clause_printable_decl (t));
remove = true;
}
}
@@ -7374,7 +7747,9 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
inner_type = type = TREE_TYPE (t);
if ((need_complete_type
|| need_copy_assignment
- || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION)
+ || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
+ || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
+ || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION)
&& TYPE_REF_P (inner_type))
inner_type = TREE_TYPE (inner_type);
while (TREE_CODE (inner_type) == ARRAY_TYPE)
@@ -7876,6 +8251,7 @@ handle_omp_for_class_iterator (int i, location_t locus, enum tree_code code,
}
incr = cp_convert (TREE_TYPE (diff), incr, tf_warning_or_error);
+ incr = cp_fully_fold (incr);
bool taskloop_iv_seen = false;
for (c = clauses; c ; c = OMP_CLAUSE_CHAIN (c))
if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LASTPRIVATE
@@ -8011,12 +8387,22 @@ handle_omp_for_class_iterator (int i, location_t locus, enum tree_code code,
= pop_stmt_list (OMP_CLAUSE_LASTPRIVATE_STMT (c));
}
+ if (TREE_CODE (TREE_VEC_ELT (orig_declv, i)) == TREE_LIST)
+ {
+ tree t = TREE_VEC_ELT (orig_declv, i);
+ gcc_assert (TREE_PURPOSE (t) == NULL_TREE
+ && TREE_VALUE (t) == NULL_TREE
+ && TREE_CODE (TREE_CHAIN (t)) == TREE_VEC);
+ TREE_PURPOSE (t) = TREE_VEC_ELT (declv, i);
+ TREE_VALUE (t) = last;
+ }
+ else
+ TREE_VEC_ELT (orig_declv, i)
+ = tree_cons (TREE_VEC_ELT (declv, i), last, NULL_TREE);
TREE_VEC_ELT (declv, i) = decl;
TREE_VEC_ELT (initv, i) = init;
TREE_VEC_ELT (condv, i) = cond;
TREE_VEC_ELT (incrv, i) = incr;
- TREE_VEC_ELT (orig_declv, i)
- = tree_cons (TREE_VEC_ELT (orig_declv, i), last, NULL_TREE);
return false;
}
@@ -8098,6 +8484,9 @@ finish_omp_for (location_t locus, enum tree_code code, tree declv,
if (init && EXPR_HAS_LOCATION (init))
elocus = EXPR_LOCATION (init);
+ if (cond == global_namespace)
+ continue;
+
if (cond == NULL)
{
error_at (elocus, "missing controlling predicate");
@@ -8120,7 +8509,8 @@ finish_omp_for (location_t locus, enum tree_code code, tree declv,
tree orig_init;
FOR_EACH_VEC_ELT (*orig_inits, i, orig_init)
if (orig_init
- && !c_omp_check_loop_iv_exprs (locus, declv,
+ && !c_omp_check_loop_iv_exprs (locus, orig_declv
+ ? orig_declv : declv,
TREE_VEC_ELT (declv, i), orig_init,
NULL_TREE, cp_walk_subtrees))
fail = true;
@@ -8253,11 +8643,12 @@ finish_omp_for (location_t locus, enum tree_code code, tree declv,
i++;
}
- if (IS_EMPTY_STMT (pre_body))
+ if (pre_body && IS_EMPTY_STMT (pre_body))
pre_body = NULL;
omp_for = c_finish_omp_for (locus, code, declv, orig_declv, initv, condv,
- incrv, body, pre_body);
+ incrv, body, pre_body,
+ !processing_template_decl);
/* Check for iterators appearing in lb, b or incr expressions. */
if (omp_for && !c_omp_check_loop_iv (omp_for, orig_declv, cp_walk_subtrees))
@@ -8369,9 +8760,55 @@ finish_omp_for (location_t locus, enum tree_code code, tree declv,
return omp_for;
}
+/* Fix up range for decls. Those decls were pushed into BIND's BIND_EXPR_VARS
+ and need to be moved into the BIND_EXPR inside of the OMP_FOR's body. */
+
+tree
+finish_omp_for_block (tree bind, tree omp_for)
+{
+ if (omp_for == NULL_TREE
+ || !OMP_FOR_ORIG_DECLS (omp_for)
+ || bind == NULL_TREE
+ || TREE_CODE (bind) != BIND_EXPR)
+ return bind;
+ tree b = NULL_TREE;
+ for (int i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (omp_for)); i++)
+ if (TREE_CODE (TREE_VEC_ELT (OMP_FOR_ORIG_DECLS (omp_for), i)) == TREE_LIST
+ && TREE_CHAIN (TREE_VEC_ELT (OMP_FOR_ORIG_DECLS (omp_for), i)))
+ {
+ tree v = TREE_CHAIN (TREE_VEC_ELT (OMP_FOR_ORIG_DECLS (omp_for), i));
+ gcc_assert (BIND_EXPR_BLOCK (bind)
+ && (BIND_EXPR_VARS (bind)
+ == BLOCK_VARS (BIND_EXPR_BLOCK (bind))));
+ for (int j = 2; j < TREE_VEC_LENGTH (v); j++)
+ for (tree *p = &BIND_EXPR_VARS (bind); *p; p = &DECL_CHAIN (*p))
+ {
+ if (*p == TREE_VEC_ELT (v, j))
+ {
+ tree var = *p;
+ *p = DECL_CHAIN (*p);
+ if (b == NULL_TREE)
+ {
+ b = make_node (BLOCK);
+ b = build3 (BIND_EXPR, void_type_node, NULL_TREE,
+ OMP_FOR_BODY (omp_for), b);
+ TREE_SIDE_EFFECTS (b) = 1;
+ OMP_FOR_BODY (omp_for) = b;
+ }
+ DECL_CHAIN (var) = BIND_EXPR_VARS (b);
+ BIND_EXPR_VARS (b) = var;
+ BLOCK_VARS (BIND_EXPR_BLOCK (b)) = var;
+ }
+ }
+ BLOCK_VARS (BIND_EXPR_BLOCK (bind)) = BIND_EXPR_VARS (bind);
+ }
+ return bind;
+}
+
void
-finish_omp_atomic (enum tree_code code, enum tree_code opcode, tree lhs,
- tree rhs, tree v, tree lhs1, tree rhs1, bool seq_cst)
+finish_omp_atomic (location_t loc, enum tree_code code, enum tree_code opcode,
+ tree lhs, tree rhs, tree v, tree lhs1, tree rhs1,
+ tree clauses, enum omp_memory_order mo)
{
tree orig_lhs;
tree orig_rhs;
@@ -8398,6 +8835,15 @@ finish_omp_atomic (enum tree_code code, enum tree_code opcode, tree lhs,
|| (v && type_dependent_expression_p (v))
|| (lhs1 && type_dependent_expression_p (lhs1))
|| (rhs1 && type_dependent_expression_p (rhs1)));
+ if (clauses)
+ {
+ gcc_assert (TREE_CODE (clauses) == OMP_CLAUSE
+ && OMP_CLAUSE_CODE (clauses) == OMP_CLAUSE_HINT
+ && OMP_CLAUSE_CHAIN (clauses) == NULL_TREE);
+ if (type_dependent_expression_p (OMP_CLAUSE_HINT_EXPR (clauses))
+ || TREE_CODE (OMP_CLAUSE_HINT_EXPR (clauses)) != INTEGER_CST)
+ dependent_p = true;
+ }
if (!dependent_p)
{
lhs = build_non_dependent_expr (lhs);
@@ -8439,8 +8885,8 @@ finish_omp_atomic (enum tree_code code, enum tree_code opcode, tree lhs,
"expressions for memory");
return;
}
- stmt = c_finish_omp_atomic (input_location, code, opcode, lhs, rhs,
- v, lhs1, rhs1, swapped, seq_cst,
+ stmt = c_finish_omp_atomic (loc, code, opcode, lhs, rhs,
+ v, lhs1, rhs1, swapped, mo,
processing_template_decl != 0);
if (stmt == error_mark_node)
return;
@@ -8449,9 +8895,8 @@ finish_omp_atomic (enum tree_code code, enum tree_code opcode, tree lhs,
{
if (code == OMP_ATOMIC_READ)
{
- stmt = build_min_nt_loc (EXPR_LOCATION (orig_lhs),
- OMP_ATOMIC_READ, orig_lhs);
- OMP_ATOMIC_SEQ_CST (stmt) = seq_cst;
+ stmt = build_min_nt_loc (loc, OMP_ATOMIC_READ, orig_lhs);
+ OMP_ATOMIC_MEMORY_ORDER (stmt) = mo;
stmt = build2 (MODIFY_EXPR, void_type_node, orig_v, stmt);
}
else
@@ -8465,14 +8910,15 @@ finish_omp_atomic (enum tree_code code, enum tree_code opcode, tree lhs,
COMPOUND_EXPR, orig_rhs1, stmt);
if (code != OMP_ATOMIC)
{
- stmt = build_min_nt_loc (EXPR_LOCATION (orig_lhs1),
- code, orig_lhs1, stmt);
- OMP_ATOMIC_SEQ_CST (stmt) = seq_cst;
+ stmt = build_min_nt_loc (loc, code, orig_lhs1, stmt);
+ OMP_ATOMIC_MEMORY_ORDER (stmt) = mo;
stmt = build2 (MODIFY_EXPR, void_type_node, orig_v, stmt);
}
}
- stmt = build2 (OMP_ATOMIC, void_type_node, integer_zero_node, stmt);
- OMP_ATOMIC_SEQ_CST (stmt) = seq_cst;
+ stmt = build2 (OMP_ATOMIC, void_type_node,
+ clauses ? clauses : integer_zero_node, stmt);
+ OMP_ATOMIC_MEMORY_ORDER (stmt) = mo;
+ SET_EXPR_LOCATION (stmt, loc);
}
finish_expr_stmt (stmt);
}
@@ -8488,10 +8934,50 @@ finish_omp_barrier (void)
}
void
-finish_omp_flush (void)
+finish_omp_depobj (location_t loc, tree depobj,
+ enum omp_clause_depend_kind kind, tree clause)
+{
+ if (!error_operand_p (depobj) && !type_dependent_expression_p (depobj))
+ {
+ if (!lvalue_p (depobj))
+ {
+ error_at (EXPR_LOC_OR_LOC (depobj, loc),
+ "%<depobj%> expression is not lvalue expression");
+ depobj = error_mark_node;
+ }
+ }
+
+ if (processing_template_decl)
+ {
+ if (clause == NULL_TREE)
+ clause = build_int_cst (integer_type_node, kind);
+ add_stmt (build_min_nt_loc (loc, OMP_DEPOBJ, depobj, clause));
+ return;
+ }
+
+ if (!error_operand_p (depobj))
+ {
+ tree addr = cp_build_addr_expr (depobj, tf_warning_or_error);
+ if (addr == error_mark_node)
+ depobj = error_mark_node;
+ else
+ depobj = cp_build_indirect_ref (addr, RO_UNARY_STAR,
+ tf_warning_or_error);
+ }
+
+ c_finish_omp_depobj (loc, depobj, kind, clause);
+}
+
+void
+finish_omp_flush (int mo)
{
tree fn = builtin_decl_explicit (BUILT_IN_SYNC_SYNCHRONIZE);
vec<tree, va_gc> *vec = make_tree_vector ();
+ if (mo != MEMMODEL_LAST)
+ {
+ fn = builtin_decl_explicit (BUILT_IN_ATOMIC_THREAD_FENCE);
+ vec->quick_push (build_int_cst (integer_type_node, mo));
+ }
tree stmt = finish_call_expr (fn, &vec, false, false, tf_warning_or_error);
release_tree_vector (vec);
finish_expr_stmt (stmt);
@@ -8540,6 +9026,11 @@ finish_omp_cancel (tree clauses)
tree ifc = omp_find_clause (clauses, OMP_CLAUSE_IF);
if (ifc != NULL_TREE)
{
+ if (OMP_CLAUSE_IF_MODIFIER (ifc) != ERROR_MARK
+ && OMP_CLAUSE_IF_MODIFIER (ifc) != VOID_CST)
+ error_at (OMP_CLAUSE_LOCATION (ifc),
+ "expected %<cancel%> %<if%> clause modifier");
+
tree type = TREE_TYPE (OMP_CLAUSE_IF_EXPR (ifc));
ifc = fold_build2_loc (OMP_CLAUSE_LOCATION (ifc), NE_EXPR,
boolean_type_node, OMP_CLAUSE_IF_EXPR (ifc),