diff options
-rw-r--r-- | gcc/c/ChangeLog | 26 | ||||
-rw-r--r-- | gcc/c/c-parser.c | 244 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 24 | ||||
-rw-r--r-- | gcc/cp/parser.c | 229 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/Wparentheses-1.c | 39 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/cilk-plus/CK/Wparentheses-1.c | 69 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/cilk-plus/PS/Wparentheses-1.c | 41 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/goacc/Wparentheses-1.c | 174 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/gomp/Wparentheses-1.c | 338 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/gomp/Wparentheses-2.c | 452 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/gomp/Wparentheses-3.c | 338 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/gomp/Wparentheses-4.c | 452 |
13 files changed, 2228 insertions, 210 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 4b21d52..3ba3f4e 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,29 @@ +2016-04-15 Jakub Jelinek <jakub@redhat.com> + + PR c/70436 + * c-parser.c (c_parser_pragma): Add IF_P argument, pass it down + where needed. + (c_parser_external_declaration, c_parser_struct_or_union_specifier, + c_parser_parameter_declaration, c_parser_compound_statement_nostart, + c_parser_objc_class_instance_variables, c_parser_objc_methodprotolist): + Adjust c_parser_pragma callers. + (c_parser_statement_after_labels): Likewise. Adjust c_parser_cilk_for + caller. + (c_parser_omp_structured_block): Add IF_P argument, pass it down to + c_parser_statement. + (c_parser_oacc_data, c_parser_oacc_host_data, c_parser_oacc_loop, + c_parser_oacc_kernels_parallel, c_parser_omp_critical, + c_parser_omp_simd, c_parser_omp_for, c_parser_omp_master, + c_parser_omp_ordered, c_parser_omp_parallel, c_parser_omp_single, + c_parser_omp_task, c_parser_omp_taskgroup, c_parser_omp_distribute, + c_parser_omp_teams, c_parser_omp_target_data, c_parser_omp_target, + c_parser_omp_taskloop, c_parser_omp_construct, c_parser_cilk_grainsize, + c_parser_cilk_simd, c_parser_cilk_for): Add IF_P argument, pass it + down where needed. + (c_parser_omp_for_loop): Likewise. Clear IF_P if nbraces. + (c_parser_omp_sections_scope): Adjust c_parser_omp_structured_block + calls. + 2016-04-13 Marek Polacek <polacek@redhat.com> PR c/70436 diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index d37c691..1b6bacd 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -1342,12 +1342,12 @@ static vec<tree, va_gc> *c_parser_expr_list (c_parser *, bool, bool, static void c_parser_oacc_declare (c_parser *); static void c_parser_oacc_enter_exit_data (c_parser *, bool); static void c_parser_oacc_update (c_parser *); -static void c_parser_omp_construct (c_parser *); +static void c_parser_omp_construct (c_parser *, bool *); static void c_parser_omp_threadprivate (c_parser *); static void c_parser_omp_barrier (c_parser *); static void c_parser_omp_flush (c_parser *); static tree c_parser_omp_for_loop (location_t, c_parser *, enum tree_code, - tree, tree *); + tree, tree *, bool *); static void c_parser_omp_taskwait (c_parser *); static void c_parser_omp_taskyield (c_parser *); static void c_parser_omp_cancel (c_parser *); @@ -1355,11 +1355,11 @@ static void c_parser_omp_cancellation_point (c_parser *); enum pragma_context { pragma_external, pragma_struct, pragma_param, pragma_stmt, pragma_compound }; -static bool c_parser_pragma (c_parser *, enum pragma_context); -static bool c_parser_omp_target (c_parser *, enum pragma_context); +static bool c_parser_pragma (c_parser *, enum pragma_context, bool *); +static bool c_parser_omp_target (c_parser *, enum pragma_context, bool *); static void c_parser_omp_end_declare_target (c_parser *); static void c_parser_omp_declare (c_parser *, enum pragma_context); -static bool c_parser_omp_ordered (c_parser *, enum pragma_context); +static bool c_parser_omp_ordered (c_parser *, enum pragma_context, bool *); static void c_parser_oacc_routine (c_parser *parser, enum pragma_context); /* These Objective-C parser functions are only ever called when @@ -1390,12 +1390,12 @@ static bool c_parser_objc_diagnose_bad_element_prefix (c_parser *, struct c_declspecs *); /* Cilk Plus supporting routines. */ -static void c_parser_cilk_simd (c_parser *); -static void c_parser_cilk_for (c_parser *, tree); +static void c_parser_cilk_simd (c_parser *, bool *); +static void c_parser_cilk_for (c_parser *, tree, bool *); static bool c_parser_cilk_verify_simd (c_parser *, enum pragma_context); static tree c_parser_array_notation (location_t, c_parser *, tree, tree); static tree c_parser_cilk_clause_vectorlength (c_parser *, tree, bool); -static void c_parser_cilk_grainsize (c_parser *); +static void c_parser_cilk_grainsize (c_parser *, bool *); /* Parse a translation unit (C90 6.7, C99 6.9). @@ -1527,7 +1527,7 @@ c_parser_external_declaration (c_parser *parser) break; case CPP_PRAGMA: mark_valid_location_for_stdc_pragma (true); - c_parser_pragma (parser, pragma_external); + c_parser_pragma (parser, pragma_external, NULL); mark_valid_location_for_stdc_pragma (false); break; case CPP_PLUS: @@ -2927,7 +2927,7 @@ c_parser_struct_or_union_specifier (c_parser *parser) /* Accept #pragmas at struct scope. */ if (c_parser_next_token_is (parser, CPP_PRAGMA)) { - c_parser_pragma (parser, pragma_struct); + c_parser_pragma (parser, pragma_struct, NULL); continue; } /* Parse some comma-separated declarations, but not the @@ -3796,7 +3796,7 @@ c_parser_parameter_declaration (c_parser *parser, tree attrs) /* Accept #pragmas between parameter declarations. */ while (c_parser_next_token_is (parser, CPP_PRAGMA)) - c_parser_pragma (parser, pragma_param); + c_parser_pragma (parser, pragma_param, NULL); if (!c_parser_next_token_starts_declspecs (parser)) { @@ -4824,7 +4824,8 @@ c_parser_compound_statement_nostart (c_parser *parser) places that would turn into syntax errors if the directive were ignored. */ if (c_parser_pragma (parser, - last_label ? pragma_stmt : pragma_compound)) + last_label ? pragma_stmt : pragma_compound, + NULL)) last_label = false, last_stmt = true; } else if (c_parser_next_token_is (parser, CPP_EOF)) @@ -5156,7 +5157,7 @@ c_parser_statement_after_labels (c_parser *parser, bool *if_p, c_parser_skip_to_end_of_block_or_statement (parser); } else - c_parser_cilk_for (parser, integer_zero_node); + c_parser_cilk_for (parser, integer_zero_node, if_p); break; case RID_CILK_SYNC: c_parser_consume_token (parser); @@ -5276,7 +5277,7 @@ c_parser_statement_after_labels (c_parser *parser, bool *if_p, c_parser_consume_token (parser); break; case CPP_PRAGMA: - c_parser_pragma (parser, pragma_stmt); + c_parser_pragma (parser, pragma_stmt, if_p); break; default: expr_stmt: @@ -8787,7 +8788,7 @@ c_parser_objc_class_instance_variables (c_parser *parser) } else if (c_parser_next_token_is (parser, CPP_PRAGMA)) { - c_parser_pragma (parser, pragma_external); + c_parser_pragma (parser, pragma_external, NULL); continue; } @@ -9058,7 +9059,7 @@ c_parser_objc_methodprotolist (c_parser *parser) c_parser_objc_methodproto (parser); break; case CPP_PRAGMA: - c_parser_pragma (parser, pragma_external); + c_parser_pragma (parser, pragma_external, NULL); break; case CPP_EOF: return; @@ -10019,7 +10020,7 @@ c_parser_objc_at_dynamic_declaration (c_parser *parser) true if we actually parsed such a pragma. */ static bool -c_parser_pragma (c_parser *parser, enum pragma_context context) +c_parser_pragma (c_parser *parser, enum pragma_context context, bool *if_p) { unsigned int id; @@ -10126,7 +10127,7 @@ c_parser_pragma (c_parser *parser, enum pragma_context context) return false; case PRAGMA_OMP_TARGET: - return c_parser_omp_target (parser, context); + return c_parser_omp_target (parser, context, if_p); case PRAGMA_OMP_END_DECLARE_TARGET: c_parser_omp_end_declare_target (parser); @@ -10144,7 +10145,7 @@ c_parser_pragma (c_parser *parser, enum pragma_context context) return false; case PRAGMA_OMP_ORDERED: - return c_parser_omp_ordered (parser, context); + return c_parser_omp_ordered (parser, context, if_p); case PRAGMA_IVDEP: c_parser_consume_pragma (parser); @@ -10157,9 +10158,9 @@ c_parser_pragma (c_parser *parser, enum pragma_context context) return false; } if (c_parser_next_token_is_keyword (parser, RID_FOR)) - c_parser_for_statement (parser, true, NULL); + c_parser_for_statement (parser, true, if_p); else if (c_parser_next_token_is_keyword (parser, RID_WHILE)) - c_parser_while_statement (parser, true, NULL); + c_parser_while_statement (parser, true, if_p); else c_parser_do_statement (parser, true); return false; @@ -10173,7 +10174,7 @@ c_parser_pragma (c_parser *parser, enum pragma_context context) if (!c_parser_cilk_verify_simd (parser, context)) return false; c_parser_consume_pragma (parser); - c_parser_cilk_simd (parser); + c_parser_cilk_simd (parser, if_p); return false; case PRAGMA_CILK_GRAINSIZE: if (!flag_cilkplus) @@ -10190,7 +10191,7 @@ c_parser_pragma (c_parser *parser, enum pragma_context context) c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL); return false; } - c_parser_cilk_grainsize (parser); + c_parser_cilk_grainsize (parser, if_p); return false; default: @@ -10203,7 +10204,7 @@ c_parser_pragma (c_parser *parser, enum pragma_context context) c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL); return false; } - c_parser_omp_construct (parser); + c_parser_omp_construct (parser, if_p); return true; } break; @@ -13477,10 +13478,10 @@ c_parser_omp_all_clauses (c_parser *parser, omp_clause_mask mask, c_parser_statement calls add_stmt. */ static tree -c_parser_omp_structured_block (c_parser *parser) +c_parser_omp_structured_block (c_parser *parser, bool *if_p) { tree stmt = push_stmt_list (); - c_parser_statement (parser, NULL); + c_parser_statement (parser, if_p); return pop_stmt_list (stmt); } @@ -13530,7 +13531,7 @@ c_parser_oacc_cache (location_t loc, c_parser *parser) | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT_OR_CREATE) ) static tree -c_parser_oacc_data (location_t loc, c_parser *parser) +c_parser_oacc_data (location_t loc, c_parser *parser, bool *if_p) { tree stmt, clauses, block; @@ -13538,7 +13539,7 @@ c_parser_oacc_data (location_t loc, c_parser *parser) "#pragma acc data"); block = c_begin_omp_parallel (); - add_stmt (c_parser_omp_structured_block (parser)); + add_stmt (c_parser_omp_structured_block (parser, if_p)); stmt = c_finish_oacc_data (loc, clauses, block); @@ -13784,7 +13785,7 @@ c_parser_oacc_enter_exit_data (c_parser *parser, bool enter) ( (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_USE_DEVICE) ) static tree -c_parser_oacc_host_data (location_t loc, c_parser *parser) +c_parser_oacc_host_data (location_t loc, c_parser *parser, bool *if_p) { tree stmt, clauses, block; @@ -13792,7 +13793,7 @@ c_parser_oacc_host_data (location_t loc, c_parser *parser) "#pragma acc host_data"); block = c_begin_omp_parallel (); - add_stmt (c_parser_omp_structured_block (parser)); + add_stmt (c_parser_omp_structured_block (parser, if_p)); stmt = c_finish_oacc_host_data (loc, clauses, block); return stmt; } @@ -13819,7 +13820,7 @@ c_parser_oacc_host_data (location_t loc, c_parser *parser) | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_TILE) ) static tree c_parser_oacc_loop (location_t loc, c_parser *parser, char *p_name, - omp_clause_mask mask, tree *cclauses) + omp_clause_mask mask, tree *cclauses, bool *if_p) { strcat (p_name, " loop"); mask |= OACC_LOOP_CLAUSE_MASK; @@ -13836,7 +13837,8 @@ c_parser_oacc_loop (location_t loc, c_parser *parser, char *p_name, } tree block = c_begin_compound_stmt (true); - tree stmt = c_parser_omp_for_loop (loc, parser, OACC_LOOP, clauses, NULL); + tree stmt = c_parser_omp_for_loop (loc, parser, OACC_LOOP, clauses, NULL, + if_p); block = c_end_compound_stmt (loc, block, true); add_stmt (block); @@ -13895,7 +13897,8 @@ c_parser_oacc_loop (location_t loc, c_parser *parser, char *p_name, static tree c_parser_oacc_kernels_parallel (location_t loc, c_parser *parser, - enum pragma_kind p_kind, char *p_name) + enum pragma_kind p_kind, char *p_name, + bool *if_p) { omp_clause_mask mask; enum tree_code code; @@ -13925,7 +13928,7 @@ c_parser_oacc_kernels_parallel (location_t loc, c_parser *parser, tree block = c_begin_omp_parallel (); tree clauses; - c_parser_oacc_loop (loc, parser, p_name, mask, &clauses); + c_parser_oacc_loop (loc, parser, p_name, mask, &clauses, if_p); return c_finish_omp_construct (loc, code, block, clauses); } } @@ -13933,7 +13936,7 @@ c_parser_oacc_kernels_parallel (location_t loc, c_parser *parser, tree clauses = c_parser_oacc_all_clauses (parser, mask, p_name); tree block = c_begin_omp_parallel (); - add_stmt (c_parser_omp_structured_block (parser)); + add_stmt (c_parser_omp_structured_block (parser, if_p)); return c_finish_omp_construct (loc, code, block, clauses); } @@ -14576,7 +14579,7 @@ c_parser_omp_barrier (c_parser *parser) ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_HINT) ) static tree -c_parser_omp_critical (location_t loc, c_parser *parser) +c_parser_omp_critical (location_t loc, c_parser *parser, bool *if_p) { tree stmt, name = NULL_TREE, clauses = NULL_TREE; @@ -14603,7 +14606,7 @@ c_parser_omp_critical (location_t loc, c_parser *parser) c_parser_skip_to_pragma_eol (parser); } - stmt = c_parser_omp_structured_block (parser); + stmt = c_parser_omp_structured_block (parser, if_p); return c_finish_omp_critical (loc, stmt, name, clauses); } @@ -14635,7 +14638,7 @@ c_parser_omp_flush (c_parser *parser) static tree c_parser_omp_for_loop (location_t loc, c_parser *parser, enum tree_code code, - tree clauses, tree *cclauses) + tree clauses, tree *cclauses, bool *if_p) { tree decl, cond, incr, save_break, save_cont, body, init, stmt, cl; tree declv, condv, incrv, initv, ret = NULL_TREE; @@ -14865,6 +14868,9 @@ c_parser_omp_for_loop (location_t loc, c_parser *parser, enum tree_code code, nbraces += bracecount; } + if (nbraces) + if_p = NULL; + save_break = c_break_label; if (code == CILK_SIMD) c_break_label = build_int_cst (size_type_node, 2); @@ -14882,7 +14888,7 @@ c_parser_omp_for_loop (location_t loc, c_parser *parser, enum tree_code code, add_stmt (c_end_compound_stmt (here, stmt, true)); } else - add_stmt (c_parser_c99_block_statement (parser, NULL)); + add_stmt (c_parser_c99_block_statement (parser, if_p)); if (c_cont_label) { tree t = build1 (LABEL_EXPR, void_type_node, c_cont_label); @@ -15025,7 +15031,8 @@ omp_split_clauses (location_t loc, enum tree_code code, static tree c_parser_omp_simd (location_t loc, c_parser *parser, - char *p_name, omp_clause_mask mask, tree *cclauses) + char *p_name, omp_clause_mask mask, tree *cclauses, + bool *if_p) { tree block, clauses, ret; @@ -15049,7 +15056,7 @@ c_parser_omp_simd (location_t loc, c_parser *parser, } block = c_begin_compound_stmt (true); - ret = c_parser_omp_for_loop (loc, parser, OMP_SIMD, clauses, cclauses); + ret = c_parser_omp_for_loop (loc, parser, OMP_SIMD, clauses, cclauses, if_p); block = c_end_compound_stmt (loc, block, true); add_stmt (block); @@ -15080,7 +15087,8 @@ c_parser_omp_simd (location_t loc, c_parser *parser, static tree c_parser_omp_for (location_t loc, c_parser *parser, - char *p_name, omp_clause_mask mask, tree *cclauses) + char *p_name, omp_clause_mask mask, tree *cclauses, + bool *if_p) { tree block, clauses, ret; @@ -15104,9 +15112,10 @@ c_parser_omp_for (location_t loc, c_parser *parser, c_parser_consume_token (parser); if (!flag_openmp) /* flag_openmp_simd */ - return c_parser_omp_simd (loc, parser, p_name, mask, cclauses); + return c_parser_omp_simd (loc, parser, p_name, mask, cclauses, + if_p); block = c_begin_compound_stmt (true); - ret = c_parser_omp_simd (loc, parser, p_name, mask, cclauses); + ret = c_parser_omp_simd (loc, parser, p_name, mask, cclauses, if_p); block = c_end_compound_stmt (loc, block, true); if (ret == NULL_TREE) return ret; @@ -15137,7 +15146,7 @@ c_parser_omp_for (location_t loc, c_parser *parser, } block = c_begin_compound_stmt (true); - ret = c_parser_omp_for_loop (loc, parser, OMP_FOR, clauses, cclauses); + ret = c_parser_omp_for_loop (loc, parser, OMP_FOR, clauses, cclauses, if_p); block = c_end_compound_stmt (loc, block, true); add_stmt (block); @@ -15152,10 +15161,11 @@ c_parser_omp_for (location_t loc, c_parser *parser, */ static tree -c_parser_omp_master (location_t loc, c_parser *parser) +c_parser_omp_master (location_t loc, c_parser *parser, bool *if_p) { c_parser_skip_to_pragma_eol (parser); - return c_finish_omp_master (loc, c_parser_omp_structured_block (parser)); + return c_finish_omp_master (loc, c_parser_omp_structured_block (parser, + if_p)); } /* OpenMP 2.5: @@ -15176,7 +15186,8 @@ c_parser_omp_master (location_t loc, c_parser *parser) (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEPEND) static bool -c_parser_omp_ordered (c_parser *parser, enum pragma_context context) +c_parser_omp_ordered (c_parser *parser, enum pragma_context context, + bool *if_p) { location_t loc = c_parser_peek_token (parser)->location; c_parser_consume_pragma (parser); @@ -15215,7 +15226,7 @@ c_parser_omp_ordered (c_parser *parser, enum pragma_context context) tree clauses = c_parser_omp_all_clauses (parser, OMP_ORDERED_CLAUSE_MASK, "#pragma omp ordered"); c_finish_omp_ordered (loc, clauses, - c_parser_omp_structured_block (parser)); + c_parser_omp_structured_block (parser, if_p)); return true; } @@ -15249,7 +15260,7 @@ c_parser_omp_sections_scope (location_t sections_loc, c_parser *parser) if (c_parser_peek_token (parser)->pragma_kind != PRAGMA_OMP_SECTION) { - substmt = c_parser_omp_structured_block (parser); + substmt = c_parser_omp_structured_block (parser, NULL); substmt = build1 (OMP_SECTION, void_type_node, substmt); SET_EXPR_LOCATION (substmt, loc); add_stmt (substmt); @@ -15275,7 +15286,7 @@ c_parser_omp_sections_scope (location_t sections_loc, c_parser *parser) error_suppress = true; } - substmt = c_parser_omp_structured_block (parser); + substmt = c_parser_omp_structured_block (parser, NULL); substmt = build1 (OMP_SECTION, void_type_node, substmt); SET_EXPR_LOCATION (substmt, loc); add_stmt (substmt); @@ -15363,7 +15374,8 @@ c_parser_omp_sections (location_t loc, c_parser *parser, static tree c_parser_omp_parallel (location_t loc, c_parser *parser, - char *p_name, omp_clause_mask mask, tree *cclauses) + char *p_name, omp_clause_mask mask, tree *cclauses, + bool *if_p) { tree stmt, clauses, block; @@ -15382,9 +15394,9 @@ c_parser_omp_parallel (location_t loc, c_parser *parser, c_parser_consume_token (parser); if (!flag_openmp) /* flag_openmp_simd */ - return c_parser_omp_for (loc, parser, p_name, mask, cclauses); + return c_parser_omp_for (loc, parser, p_name, mask, cclauses, if_p); block = c_begin_omp_parallel (); - tree ret = c_parser_omp_for (loc, parser, p_name, mask, cclauses); + tree ret = c_parser_omp_for (loc, parser, p_name, mask, cclauses, if_p); stmt = c_finish_omp_parallel (loc, cclauses[C_OMP_CLAUSE_SPLIT_PARALLEL], block); @@ -15436,7 +15448,7 @@ c_parser_omp_parallel (location_t loc, c_parser *parser, } block = c_begin_omp_parallel (); - c_parser_statement (parser, NULL); + c_parser_statement (parser, if_p); stmt = c_finish_omp_parallel (loc, clauses, block); return stmt; @@ -15456,7 +15468,7 @@ c_parser_omp_parallel (location_t loc, c_parser *parser, | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT)) static tree -c_parser_omp_single (location_t loc, c_parser *parser) +c_parser_omp_single (location_t loc, c_parser *parser, bool *if_p) { tree stmt = make_node (OMP_SINGLE); SET_EXPR_LOCATION (stmt, loc); @@ -15465,7 +15477,7 @@ c_parser_omp_single (location_t loc, c_parser *parser) OMP_SINGLE_CLAUSES (stmt) = c_parser_omp_all_clauses (parser, OMP_SINGLE_CLAUSE_MASK, "#pragma omp single"); - OMP_SINGLE_BODY (stmt) = c_parser_omp_structured_block (parser); + OMP_SINGLE_BODY (stmt) = c_parser_omp_structured_block (parser, if_p); return add_stmt (stmt); } @@ -15489,7 +15501,7 @@ c_parser_omp_single (location_t loc, c_parser *parser) | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_PRIORITY)) static tree -c_parser_omp_task (location_t loc, c_parser *parser) +c_parser_omp_task (location_t loc, c_parser *parser, bool *if_p) { tree clauses, block; @@ -15497,7 +15509,7 @@ c_parser_omp_task (location_t loc, c_parser *parser) "#pragma omp task"); block = c_begin_omp_task (); - c_parser_statement (parser, NULL); + c_parser_statement (parser, if_p); return c_finish_omp_task (loc, clauses, block); } @@ -15534,11 +15546,12 @@ c_parser_omp_taskyield (c_parser *parser) */ static tree -c_parser_omp_taskgroup (c_parser *parser) +c_parser_omp_taskgroup (c_parser *parser, bool *if_p) { location_t loc = c_parser_peek_token (parser)->location; c_parser_skip_to_pragma_eol (parser); - return c_finish_omp_taskgroup (loc, c_parser_omp_structured_block (parser)); + return c_finish_omp_taskgroup (loc, c_parser_omp_structured_block (parser, + if_p)); } /* OpenMP 4.0: @@ -15622,7 +15635,8 @@ c_parser_omp_cancellation_point (c_parser *parser) static tree c_parser_omp_distribute (location_t loc, c_parser *parser, - char *p_name, omp_clause_mask mask, tree *cclauses) + char *p_name, omp_clause_mask mask, tree *cclauses, + bool *if_p) { tree clauses, block, ret; @@ -15648,16 +15662,19 @@ c_parser_omp_distribute (location_t loc, c_parser *parser, if (!flag_openmp) /* flag_openmp_simd */ { if (simd) - return c_parser_omp_simd (loc, parser, p_name, mask, cclauses); + return c_parser_omp_simd (loc, parser, p_name, mask, cclauses, + if_p); else return c_parser_omp_parallel (loc, parser, p_name, mask, - cclauses); + cclauses, if_p); } block = c_begin_compound_stmt (true); if (simd) - ret = c_parser_omp_simd (loc, parser, p_name, mask, cclauses); + ret = c_parser_omp_simd (loc, parser, p_name, mask, cclauses, + if_p); else - ret = c_parser_omp_parallel (loc, parser, p_name, mask, cclauses); + ret = c_parser_omp_parallel (loc, parser, p_name, mask, cclauses, + if_p); block = c_end_compound_stmt (loc, block, true); if (ret == NULL) return ret; @@ -15684,7 +15701,8 @@ c_parser_omp_distribute (location_t loc, c_parser *parser, } block = c_begin_compound_stmt (true); - ret = c_parser_omp_for_loop (loc, parser, OMP_DISTRIBUTE, clauses, NULL); + ret = c_parser_omp_for_loop (loc, parser, OMP_DISTRIBUTE, clauses, NULL, + if_p); block = c_end_compound_stmt (loc, block, true); add_stmt (block); @@ -15706,7 +15724,8 @@ c_parser_omp_distribute (location_t loc, c_parser *parser, static tree c_parser_omp_teams (location_t loc, c_parser *parser, - char *p_name, omp_clause_mask mask, tree *cclauses) + char *p_name, omp_clause_mask mask, tree *cclauses, + bool *if_p) { tree clauses, block, ret; @@ -15724,9 +15743,11 @@ c_parser_omp_teams (location_t loc, c_parser *parser, c_parser_consume_token (parser); if (!flag_openmp) /* flag_openmp_simd */ - return c_parser_omp_distribute (loc, parser, p_name, mask, cclauses); + return c_parser_omp_distribute (loc, parser, p_name, mask, + cclauses, if_p); block = c_begin_compound_stmt (true); - ret = c_parser_omp_distribute (loc, parser, p_name, mask, cclauses); + ret = c_parser_omp_distribute (loc, parser, p_name, mask, cclauses, + if_p); block = c_end_compound_stmt (loc, block, true); if (ret == NULL) return ret; @@ -15755,7 +15776,7 @@ c_parser_omp_teams (location_t loc, c_parser *parser, tree stmt = make_node (OMP_TEAMS); TREE_TYPE (stmt) = void_type_node; OMP_TEAMS_CLAUSES (stmt) = clauses; - OMP_TEAMS_BODY (stmt) = c_parser_omp_structured_block (parser); + OMP_TEAMS_BODY (stmt) = c_parser_omp_structured_block (parser, if_p); return add_stmt (stmt); } @@ -15771,7 +15792,7 @@ c_parser_omp_teams (location_t loc, c_parser *parser, | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_USE_DEVICE_PTR)) static tree -c_parser_omp_target_data (location_t loc, c_parser *parser) +c_parser_omp_target_data (location_t loc, c_parser *parser, bool *if_p) { tree clauses = c_parser_omp_all_clauses (parser, OMP_TARGET_DATA_CLAUSE_MASK, @@ -15820,7 +15841,7 @@ c_parser_omp_target_data (location_t loc, c_parser *parser) OMP_TARGET_DATA_CLAUSES (stmt) = clauses; keep_next_level (); tree block = c_begin_compound_stmt (true); - add_stmt (c_parser_omp_structured_block (parser)); + add_stmt (c_parser_omp_structured_block (parser, if_p)); OMP_TARGET_DATA_BODY (stmt) = c_end_compound_stmt (loc, block, true); SET_EXPR_LOCATION (stmt, loc); @@ -16060,7 +16081,7 @@ c_parser_omp_target_exit_data (location_t loc, c_parser *parser, | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IS_DEVICE_PTR)) static bool -c_parser_omp_target (c_parser *parser, enum pragma_context context) +c_parser_omp_target (c_parser *parser, enum pragma_context context, bool *if_p) { location_t loc = c_parser_peek_token (parser)->location; c_parser_consume_pragma (parser); @@ -16100,17 +16121,17 @@ c_parser_omp_target (c_parser *parser, enum pragma_context context) case OMP_TEAMS: stmt = c_parser_omp_teams (loc, parser, p_name, OMP_TARGET_CLAUSE_MASK, - cclauses); + cclauses, if_p); break; case OMP_PARALLEL: stmt = c_parser_omp_parallel (loc, parser, p_name, OMP_TARGET_CLAUSE_MASK, - cclauses); + cclauses, if_p); break; case OMP_SIMD: stmt = c_parser_omp_simd (loc, parser, p_name, OMP_TARGET_CLAUSE_MASK, - cclauses); + cclauses, if_p); break; default: gcc_unreachable (); @@ -16123,15 +16144,18 @@ c_parser_omp_target (c_parser *parser, enum pragma_context context) { case OMP_TEAMS: ret = c_parser_omp_teams (loc, parser, p_name, - OMP_TARGET_CLAUSE_MASK, cclauses); + OMP_TARGET_CLAUSE_MASK, cclauses, + if_p); break; case OMP_PARALLEL: ret = c_parser_omp_parallel (loc, parser, p_name, - OMP_TARGET_CLAUSE_MASK, cclauses); + OMP_TARGET_CLAUSE_MASK, cclauses, + if_p); break; case OMP_SIMD: ret = c_parser_omp_simd (loc, parser, p_name, - OMP_TARGET_CLAUSE_MASK, cclauses); + OMP_TARGET_CLAUSE_MASK, cclauses, + if_p); break; default: gcc_unreachable (); @@ -16182,7 +16206,7 @@ c_parser_omp_target (c_parser *parser, enum pragma_context context) else if (strcmp (p, "data") == 0) { c_parser_consume_token (parser); - c_parser_omp_target_data (loc, parser); + c_parser_omp_target_data (loc, parser, if_p); return true; } else if (strcmp (p, "enter") == 0) @@ -16213,7 +16237,7 @@ c_parser_omp_target (c_parser *parser, enum pragma_context context) pc = &OMP_TARGET_CLAUSES (stmt); keep_next_level (); block = c_begin_compound_stmt (true); - add_stmt (c_parser_omp_structured_block (parser)); + add_stmt (c_parser_omp_structured_block (parser, if_p)); OMP_TARGET_BODY (stmt) = c_end_compound_stmt (loc, block, true); SET_EXPR_LOCATION (stmt, loc); @@ -17022,7 +17046,8 @@ c_parser_omp_declare (c_parser *parser, enum pragma_context context) static tree c_parser_omp_taskloop (location_t loc, c_parser *parser, - char *p_name, omp_clause_mask mask, tree *cclauses) + char *p_name, omp_clause_mask mask, tree *cclauses, + bool *if_p) { tree clauses, block, ret; @@ -17041,9 +17066,10 @@ c_parser_omp_taskloop (location_t loc, c_parser *parser, mask &= ~(OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_REDUCTION); c_parser_consume_token (parser); if (!flag_openmp) /* flag_openmp_simd */ - return c_parser_omp_simd (loc, parser, p_name, mask, cclauses); + return c_parser_omp_simd (loc, parser, p_name, mask, cclauses, + if_p); block = c_begin_compound_stmt (true); - ret = c_parser_omp_simd (loc, parser, p_name, mask, cclauses); + ret = c_parser_omp_simd (loc, parser, p_name, mask, cclauses, if_p); block = c_end_compound_stmt (loc, block, true); if (ret == NULL) return ret; @@ -17070,7 +17096,7 @@ c_parser_omp_taskloop (location_t loc, c_parser *parser, } block = c_begin_compound_stmt (true); - ret = c_parser_omp_for_loop (loc, parser, OMP_TASKLOOP, clauses, NULL); + ret = c_parser_omp_for_loop (loc, parser, OMP_TASKLOOP, clauses, NULL, if_p); block = c_end_compound_stmt (loc, block, true); add_stmt (block); @@ -17080,7 +17106,7 @@ c_parser_omp_taskloop (location_t loc, c_parser *parser, /* Main entry point to parsing most OpenMP pragmas. */ static void -c_parser_omp_construct (c_parser *parser) +c_parser_omp_construct (c_parser *parser, bool *if_p) { enum pragma_kind p_kind; location_t loc; @@ -17102,19 +17128,20 @@ c_parser_omp_construct (c_parser *parser) stmt = c_parser_oacc_cache (loc, parser); break; case PRAGMA_OACC_DATA: - stmt = c_parser_oacc_data (loc, parser); + stmt = c_parser_oacc_data (loc, parser, if_p); break; case PRAGMA_OACC_HOST_DATA: - stmt = c_parser_oacc_host_data (loc, parser); + stmt = c_parser_oacc_host_data (loc, parser, if_p); break; case PRAGMA_OACC_KERNELS: case PRAGMA_OACC_PARALLEL: strcpy (p_name, "#pragma acc"); - stmt = c_parser_oacc_kernels_parallel (loc, parser, p_kind, p_name); + stmt = c_parser_oacc_kernels_parallel (loc, parser, p_kind, p_name, + if_p); break; case PRAGMA_OACC_LOOP: strcpy (p_name, "#pragma acc"); - stmt = c_parser_oacc_loop (loc, parser, p_name, mask, NULL); + stmt = c_parser_oacc_loop (loc, parser, p_name, mask, NULL, if_p); break; case PRAGMA_OACC_WAIT: strcpy (p_name, "#pragma wait"); @@ -17124,22 +17151,22 @@ c_parser_omp_construct (c_parser *parser) c_parser_omp_atomic (loc, parser); return; case PRAGMA_OMP_CRITICAL: - stmt = c_parser_omp_critical (loc, parser); + stmt = c_parser_omp_critical (loc, parser, if_p); break; case PRAGMA_OMP_DISTRIBUTE: strcpy (p_name, "#pragma omp"); - stmt = c_parser_omp_distribute (loc, parser, p_name, mask, NULL); + stmt = c_parser_omp_distribute (loc, parser, p_name, mask, NULL, if_p); break; case PRAGMA_OMP_FOR: strcpy (p_name, "#pragma omp"); - stmt = c_parser_omp_for (loc, parser, p_name, mask, NULL); + stmt = c_parser_omp_for (loc, parser, p_name, mask, NULL, if_p); break; case PRAGMA_OMP_MASTER: - stmt = c_parser_omp_master (loc, parser); + stmt = c_parser_omp_master (loc, parser, if_p); break; case PRAGMA_OMP_PARALLEL: strcpy (p_name, "#pragma omp"); - stmt = c_parser_omp_parallel (loc, parser, p_name, mask, NULL); + stmt = c_parser_omp_parallel (loc, parser, p_name, mask, NULL, if_p); break; case PRAGMA_OMP_SECTIONS: strcpy (p_name, "#pragma omp"); @@ -17147,24 +17174,24 @@ c_parser_omp_construct (c_parser *parser) break; case PRAGMA_OMP_SIMD: strcpy (p_name, "#pragma omp"); - stmt = c_parser_omp_simd (loc, parser, p_name, mask, NULL); + stmt = c_parser_omp_simd (loc, parser, p_name, mask, NULL, if_p); break; case PRAGMA_OMP_SINGLE: - stmt = c_parser_omp_single (loc, parser); + stmt = c_parser_omp_single (loc, parser, if_p); break; case PRAGMA_OMP_TASK: - stmt = c_parser_omp_task (loc, parser); + stmt = c_parser_omp_task (loc, parser, if_p); break; case PRAGMA_OMP_TASKGROUP: - stmt = c_parser_omp_taskgroup (parser); + stmt = c_parser_omp_taskgroup (parser, if_p); break; case PRAGMA_OMP_TASKLOOP: strcpy (p_name, "#pragma omp"); - stmt = c_parser_omp_taskloop (loc, parser, p_name, mask, NULL); + stmt = c_parser_omp_taskloop (loc, parser, p_name, mask, NULL, if_p); break; case PRAGMA_OMP_TEAMS: strcpy (p_name, "#pragma omp"); - stmt = c_parser_omp_teams (loc, parser, p_name, mask, NULL); + stmt = c_parser_omp_teams (loc, parser, p_name, mask, NULL, if_p); break; default: gcc_unreachable (); @@ -17491,7 +17518,7 @@ c_parser_cilk_all_clauses (c_parser *parser) */ static void -c_parser_cilk_grainsize (c_parser *parser) +c_parser_cilk_grainsize (c_parser *parser, bool *if_p) { extern tree convert_to_integer (tree, tree); @@ -17516,7 +17543,7 @@ c_parser_cilk_grainsize (c_parser *parser) { if (grain == NULL_TREE || grain == error_mark_node) grain = integer_zero_node; - c_parser_cilk_for (parser, grain); + c_parser_cilk_for (parser, grain, if_p); } else warning (0, "%<#pragma cilk grainsize%> is not followed by " @@ -17529,12 +17556,12 @@ c_parser_cilk_grainsize (c_parser *parser) /* Main entry point for parsing Cilk Plus <#pragma simd> for loops. */ static void -c_parser_cilk_simd (c_parser *parser) +c_parser_cilk_simd (c_parser *parser, bool *if_p) { tree clauses = c_parser_cilk_all_clauses (parser); tree block = c_begin_compound_stmt (true); location_t loc = c_parser_peek_token (parser)->location; - c_parser_omp_for_loop (loc, parser, CILK_SIMD, clauses, NULL); + c_parser_omp_for_loop (loc, parser, CILK_SIMD, clauses, NULL, if_p); block = c_end_compound_stmt (loc, block, true); add_stmt (block); } @@ -17559,7 +17586,7 @@ c_get_temp_regvar (tree type, tree init) GRAIN is the grain value passed in through pragma or 0. */ static void -c_parser_cilk_for (c_parser *parser, tree grain) +c_parser_cilk_for (c_parser *parser, tree grain, bool *if_p) { tree clauses = build_omp_clause (EXPR_LOCATION (grain), OMP_CLAUSE_SCHEDULE); OMP_CLAUSE_SCHEDULE_KIND (clauses) = OMP_CLAUSE_SCHEDULE_CILKFOR; @@ -17569,7 +17596,8 @@ c_parser_cilk_for (c_parser *parser, tree grain) tree block = c_begin_compound_stmt (true); tree sb = push_stmt_list (); location_t loc = c_parser_peek_token (parser)->location; - tree omp_for = c_parser_omp_for_loop (loc, parser, CILK_FOR, clauses, NULL); + tree omp_for = c_parser_omp_for_loop (loc, parser, CILK_FOR, clauses, NULL, + if_p); sb = pop_stmt_list (sb); if (omp_for) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2c51810..d89b73b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,27 @@ +2016-04-15 Jakub Jelinek <jakub@redhat.com> + + PR c/70436 + * parser.c (cp_parser_pragma): Add IF_P argument, pass it down + where needed. + (cp_parser_declaration_seq_opt, cp_parser_member_specification_opt, + cp_parser_objc_interstitial_code, cp_parser_omp_declare_simd, + cp_parser_oacc_routine): Adjust cp_parser_pragma callers. + (cp_parser_statement): Likewise. Adjust cp_parser_cilk_for caller. + (cp_parser_omp_structured_block): Add IF_P argument, pass it down to + cp_parser_statement. + (cp_parser_oacc_data, cp_parser_oacc_host_data, cp_parser_oacc_loop, + cp_parser_oacc_kernels_parallel, cp_parser_omp_critical, + cp_parser_omp_simd, cp_parser_omp_for, cp_parser_omp_master, + cp_parser_omp_ordered, cp_parser_omp_parallel, cp_parser_omp_single, + cp_parser_omp_task, cp_parser_omp_taskgroup, cp_parser_omp_distribute, + cp_parser_omp_teams, cp_parser_omp_target_data, cp_parser_omp_target, + cp_parser_omp_taskloop, cp_parser_omp_construct, + cp_parser_cilk_grainsize, cp_parser_cilk_simd, cp_parser_cilk_for): + Add IF_P argument, pass it down where needed. + (cp_parser_omp_for_loop): Likewise. Clear IF_P if nbraces. + (cp_parser_omp_sections_scope): Adjust cp_parser_omp_structured_block + calls. + 2016-04-14 Jason Merrill <jason@redhat.com> PR c++/70494 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index cba2d65..5486129 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -249,9 +249,9 @@ static tree cp_literal_operator_id (const char *); static void cp_parser_cilk_simd - (cp_parser *, cp_token *); + (cp_parser *, cp_token *, bool *); static tree cp_parser_cilk_for - (cp_parser *, tree); + (cp_parser *, tree, bool *); static bool cp_parser_omp_declare_reduction_exprs (tree, cp_parser *); static tree cp_parser_cilk_simd_vectorlength @@ -2434,7 +2434,7 @@ enum pragma_context { pragma_compound }; static bool cp_parser_pragma - (cp_parser *, enum pragma_context); + (cp_parser *, enum pragma_context, bool *); /* Objective-C++ Productions */ @@ -10404,7 +10404,7 @@ cp_parser_statement (cp_parser* parser, tree in_statement_expr, statement = error_mark_node; } else - statement = cp_parser_cilk_for (parser, integer_zero_node); + statement = cp_parser_cilk_for (parser, integer_zero_node, if_p); break; case RID_BREAK: @@ -10496,8 +10496,8 @@ cp_parser_statement (cp_parser* parser, tree in_statement_expr, return so that we can check for a close brace. Otherwise we require a real statement and must go back and read one. */ if (in_compound) - cp_parser_pragma (parser, pragma_compound); - else if (!cp_parser_pragma (parser, pragma_stmt)) + cp_parser_pragma (parser, pragma_compound, if_p); + else if (!cp_parser_pragma (parser, pragma_stmt, if_p)) goto restart; return; } @@ -12016,7 +12016,7 @@ cp_parser_declaration_seq_opt (cp_parser* parser) A nested declaration cannot, so this is done here and not in cp_parser_declaration. (A #pragma at block scope is handled in cp_parser_statement.) */ - cp_parser_pragma (parser, pragma_external); + cp_parser_pragma (parser, pragma_external, NULL); continue; } @@ -22145,7 +22145,7 @@ cp_parser_member_specification_opt (cp_parser* parser) /* Accept #pragmas at class scope. */ if (token->type == CPP_PRAGMA) { - cp_parser_pragma (parser, pragma_member); + cp_parser_pragma (parser, pragma_member, NULL); break; } @@ -28481,7 +28481,7 @@ cp_parser_objc_interstitial_code (cp_parser* parser) cp_parser_linkage_specification (parser); /* Handle #pragma, if any. */ else if (token->type == CPP_PRAGMA) - cp_parser_pragma (parser, pragma_objc_icode); + cp_parser_pragma (parser, pragma_objc_icode, NULL); /* Allow stray semicolons. */ else if (token->type == CPP_SEMICOLON) cp_lexer_consume_token (parser->lexer); @@ -32609,12 +32609,12 @@ cp_parser_end_omp_structured_block (cp_parser *parser, unsigned save) } static tree -cp_parser_omp_structured_block (cp_parser *parser) +cp_parser_omp_structured_block (cp_parser *parser, bool *if_p) { tree stmt = begin_omp_structured_block (); unsigned int save = cp_parser_begin_omp_structured_block (parser); - cp_parser_statement (parser, NULL_TREE, false, NULL); + cp_parser_statement (parser, NULL_TREE, false, if_p); cp_parser_end_omp_structured_block (parser, save); return finish_omp_structured_block (stmt); @@ -33074,7 +33074,7 @@ cp_parser_omp_barrier (cp_parser *parser, cp_token *pragma_tok) ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_HINT) ) static tree -cp_parser_omp_critical (cp_parser *parser, cp_token *pragma_tok) +cp_parser_omp_critical (cp_parser *parser, cp_token *pragma_tok, bool *if_p) { tree stmt, name = NULL_TREE, clauses = NULL_TREE; @@ -33099,7 +33099,7 @@ cp_parser_omp_critical (cp_parser *parser, cp_token *pragma_tok) else cp_parser_require_pragma_eol (parser, pragma_tok); - stmt = cp_parser_omp_structured_block (parser); + stmt = cp_parser_omp_structured_block (parser, if_p); return c_finish_omp_critical (input_location, stmt, name, clauses); } @@ -33475,7 +33475,7 @@ cp_parser_omp_for_loop_init (cp_parser *parser, static tree cp_parser_omp_for_loop (cp_parser *parser, enum tree_code code, tree clauses, - tree *cclauses) + 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; @@ -33734,6 +33734,9 @@ cp_parser_omp_for_loop (cp_parser *parser, enum tree_code code, tree clauses, } } + if (nbraces) + if_p = NULL; + /* Note that we saved the original contents of this flag when we entered the structured block, and so we don't need to re-save it here. */ if (code == CILK_SIMD || code == CILK_FOR) @@ -33744,7 +33747,7 @@ 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 (); - cp_parser_statement (parser, NULL_TREE, false, NULL); + cp_parser_statement (parser, NULL_TREE, false, if_p); body = pop_stmt_list (body); if (declv == NULL_TREE) @@ -33813,7 +33816,8 @@ cp_omp_split_clauses (location_t loc, enum tree_code code, static tree cp_parser_omp_simd (cp_parser *parser, cp_token *pragma_tok, - char *p_name, omp_clause_mask mask, tree *cclauses) + char *p_name, omp_clause_mask mask, tree *cclauses, + bool *if_p) { tree clauses, sb, ret; unsigned int save; @@ -33842,7 +33846,7 @@ cp_parser_omp_simd (cp_parser *parser, cp_token *pragma_tok, sb = begin_omp_structured_block (); save = cp_parser_begin_omp_structured_block (parser); - ret = cp_parser_omp_for_loop (parser, OMP_SIMD, clauses, cclauses); + 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)); @@ -33871,7 +33875,8 @@ cp_parser_omp_simd (cp_parser *parser, cp_token *pragma_tok, static tree cp_parser_omp_for (cp_parser *parser, cp_token *pragma_tok, - char *p_name, omp_clause_mask mask, tree *cclauses) + char *p_name, omp_clause_mask mask, tree *cclauses, + bool *if_p) { tree clauses, sb, ret; unsigned int save; @@ -33899,11 +33904,11 @@ cp_parser_omp_for (cp_parser *parser, cp_token *pragma_tok, cp_lexer_consume_token (parser->lexer); if (!flag_openmp) /* flag_openmp_simd */ return cp_parser_omp_simd (parser, pragma_tok, p_name, mask, - cclauses); + cclauses, if_p); sb = begin_omp_structured_block (); save = cp_parser_begin_omp_structured_block (parser); ret = cp_parser_omp_simd (parser, pragma_tok, p_name, mask, - cclauses); + cclauses, if_p); cp_parser_end_omp_structured_block (parser, save); tree body = finish_omp_structured_block (sb); if (ret == NULL) @@ -33938,7 +33943,7 @@ cp_parser_omp_for (cp_parser *parser, cp_token *pragma_tok, sb = begin_omp_structured_block (); save = cp_parser_begin_omp_structured_block (parser); - ret = cp_parser_omp_for_loop (parser, OMP_FOR, clauses, cclauses); + 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)); @@ -33951,11 +33956,11 @@ cp_parser_omp_for (cp_parser *parser, cp_token *pragma_tok, structured-block */ static tree -cp_parser_omp_master (cp_parser *parser, cp_token *pragma_tok) +cp_parser_omp_master (cp_parser *parser, cp_token *pragma_tok, bool *if_p) { cp_parser_require_pragma_eol (parser, pragma_tok); return c_finish_omp_master (input_location, - cp_parser_omp_structured_block (parser)); + cp_parser_omp_structured_block (parser, if_p)); } /* OpenMP 2.5: @@ -33975,7 +33980,7 @@ cp_parser_omp_master (cp_parser *parser, cp_token *pragma_tok) static bool cp_parser_omp_ordered (cp_parser *parser, cp_token *pragma_tok, - enum pragma_context context) + enum pragma_context context, bool *if_p) { location_t loc = pragma_tok->location; @@ -34014,7 +34019,7 @@ cp_parser_omp_ordered (cp_parser *parser, cp_token *pragma_tok, = cp_parser_omp_all_clauses (parser, OMP_ORDERED_CLAUSE_MASK, "#pragma omp ordered", pragma_tok); c_finish_omp_ordered (loc, clauses, - cp_parser_omp_structured_block (parser)); + cp_parser_omp_structured_block (parser, if_p)); return true; } @@ -34042,7 +34047,7 @@ cp_parser_omp_sections_scope (cp_parser *parser) if (cp_parser_pragma_kind (cp_lexer_peek_token (parser->lexer)) != PRAGMA_OMP_SECTION) { - substmt = cp_parser_omp_structured_block (parser); + substmt = cp_parser_omp_structured_block (parser, NULL); substmt = build1 (OMP_SECTION, void_type_node, substmt); add_stmt (substmt); } @@ -34067,7 +34072,7 @@ cp_parser_omp_sections_scope (cp_parser *parser) error_suppress = true; } - substmt = cp_parser_omp_structured_block (parser); + substmt = cp_parser_omp_structured_block (parser, NULL); substmt = build1 (OMP_SECTION, void_type_node, substmt); add_stmt (substmt); } @@ -34146,7 +34151,8 @@ cp_parser_omp_sections (cp_parser *parser, cp_token *pragma_tok, static tree cp_parser_omp_parallel (cp_parser *parser, cp_token *pragma_tok, - char *p_name, omp_clause_mask mask, tree *cclauses) + char *p_name, omp_clause_mask mask, tree *cclauses, + bool *if_p) { tree stmt, clauses, block; unsigned int save; @@ -34167,10 +34173,12 @@ cp_parser_omp_parallel (cp_parser *parser, cp_token *pragma_tok, cp_lexer_consume_token (parser->lexer); if (!flag_openmp) /* flag_openmp_simd */ - return cp_parser_omp_for (parser, pragma_tok, p_name, mask, cclauses); + return cp_parser_omp_for (parser, pragma_tok, p_name, mask, cclauses, + if_p); block = begin_omp_parallel (); save = cp_parser_begin_omp_structured_block (parser); - tree ret = cp_parser_omp_for (parser, pragma_tok, p_name, mask, cclauses); + tree ret = cp_parser_omp_for (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); @@ -34224,7 +34232,7 @@ cp_parser_omp_parallel (cp_parser *parser, cp_token *pragma_tok, block = begin_omp_parallel (); save = cp_parser_begin_omp_structured_block (parser); - cp_parser_statement (parser, NULL_TREE, false, NULL); + cp_parser_statement (parser, NULL_TREE, false, if_p); cp_parser_end_omp_structured_block (parser, save); stmt = finish_omp_parallel (clauses, block); return stmt; @@ -34241,7 +34249,7 @@ cp_parser_omp_parallel (cp_parser *parser, cp_token *pragma_tok, | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT)) static tree -cp_parser_omp_single (cp_parser *parser, cp_token *pragma_tok) +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; @@ -34249,7 +34257,7 @@ cp_parser_omp_single (cp_parser *parser, cp_token *pragma_tok) OMP_SINGLE_CLAUSES (stmt) = cp_parser_omp_all_clauses (parser, OMP_SINGLE_CLAUSE_MASK, "#pragma omp single", pragma_tok); - OMP_SINGLE_BODY (stmt) = cp_parser_omp_structured_block (parser); + OMP_SINGLE_BODY (stmt) = cp_parser_omp_structured_block (parser, if_p); return add_stmt (stmt); } @@ -34271,7 +34279,7 @@ cp_parser_omp_single (cp_parser *parser, cp_token *pragma_tok) | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_PRIORITY)) static tree -cp_parser_omp_task (cp_parser *parser, cp_token *pragma_tok) +cp_parser_omp_task (cp_parser *parser, cp_token *pragma_tok, bool *if_p) { tree clauses, block; unsigned int save; @@ -34280,7 +34288,7 @@ cp_parser_omp_task (cp_parser *parser, cp_token *pragma_tok) "#pragma omp task", pragma_tok); block = begin_omp_task (); save = cp_parser_begin_omp_structured_block (parser); - cp_parser_statement (parser, NULL_TREE, false, NULL); + cp_parser_statement (parser, NULL_TREE, false, if_p); cp_parser_end_omp_structured_block (parser, save); return finish_omp_task (clauses, block); } @@ -34310,11 +34318,12 @@ cp_parser_omp_taskyield (cp_parser *parser, cp_token *pragma_tok) structured-block */ static tree -cp_parser_omp_taskgroup (cp_parser *parser, cp_token *pragma_tok) +cp_parser_omp_taskgroup (cp_parser *parser, cp_token *pragma_tok, bool *if_p) { cp_parser_require_pragma_eol (parser, pragma_tok); return c_finish_omp_taskgroup (input_location, - cp_parser_omp_structured_block (parser)); + cp_parser_omp_structured_block (parser, + if_p)); } @@ -34403,7 +34412,8 @@ cp_parser_omp_cancellation_point (cp_parser *parser, cp_token *pragma_tok) static tree cp_parser_omp_distribute (cp_parser *parser, cp_token *pragma_tok, - char *p_name, omp_clause_mask mask, tree *cclauses) + char *p_name, omp_clause_mask mask, tree *cclauses, + bool *if_p) { tree clauses, sb, ret; unsigned int save; @@ -34433,19 +34443,19 @@ cp_parser_omp_distribute (cp_parser *parser, cp_token *pragma_tok, { if (simd) return cp_parser_omp_simd (parser, pragma_tok, p_name, mask, - cclauses); + cclauses, if_p); else return cp_parser_omp_parallel (parser, pragma_tok, p_name, mask, - cclauses); + cclauses, if_p); } sb = begin_omp_structured_block (); save = cp_parser_begin_omp_structured_block (parser); if (simd) ret = cp_parser_omp_simd (parser, pragma_tok, p_name, mask, - cclauses); + cclauses, if_p); else ret = cp_parser_omp_parallel (parser, pragma_tok, p_name, mask, - cclauses); + cclauses, if_p); cp_parser_end_omp_structured_block (parser, save); tree body = finish_omp_structured_block (sb); if (ret == NULL) @@ -34476,7 +34486,7 @@ cp_parser_omp_distribute (cp_parser *parser, cp_token *pragma_tok, sb = begin_omp_structured_block (); save = cp_parser_begin_omp_structured_block (parser); - ret = cp_parser_omp_for_loop (parser, OMP_DISTRIBUTE, clauses, NULL); + 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)); @@ -34499,7 +34509,8 @@ cp_parser_omp_distribute (cp_parser *parser, cp_token *pragma_tok, static tree cp_parser_omp_teams (cp_parser *parser, cp_token *pragma_tok, - char *p_name, omp_clause_mask mask, tree *cclauses) + char *p_name, omp_clause_mask mask, tree *cclauses, + bool *if_p) { tree clauses, sb, ret; unsigned int save; @@ -34521,11 +34532,11 @@ cp_parser_omp_teams (cp_parser *parser, cp_token *pragma_tok, cp_lexer_consume_token (parser->lexer); if (!flag_openmp) /* flag_openmp_simd */ return cp_parser_omp_distribute (parser, pragma_tok, p_name, mask, - cclauses); + cclauses, if_p); sb = begin_omp_structured_block (); save = cp_parser_begin_omp_structured_block (parser); ret = cp_parser_omp_distribute (parser, pragma_tok, p_name, mask, - cclauses); + cclauses, if_p); cp_parser_end_omp_structured_block (parser, save); tree body = finish_omp_structured_block (sb); if (ret == NULL) @@ -34556,7 +34567,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; - OMP_TEAMS_BODY (stmt) = cp_parser_omp_structured_block (parser); + OMP_TEAMS_BODY (stmt) = cp_parser_omp_structured_block (parser, if_p); return add_stmt (stmt); } @@ -34572,7 +34583,7 @@ cp_parser_omp_teams (cp_parser *parser, cp_token *pragma_tok, | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_USE_DEVICE_PTR)) static tree -cp_parser_omp_target_data (cp_parser *parser, cp_token *pragma_tok) +cp_parser_omp_target_data (cp_parser *parser, cp_token *pragma_tok, bool *if_p) { tree clauses = cp_parser_omp_all_clauses (parser, OMP_TARGET_DATA_CLAUSE_MASK, @@ -34622,7 +34633,7 @@ cp_parser_omp_target_data (cp_parser *parser, cp_token *pragma_tok) OMP_TARGET_DATA_CLAUSES (stmt) = clauses; keep_next_level (true); - OMP_TARGET_DATA_BODY (stmt) = cp_parser_omp_structured_block (parser); + OMP_TARGET_DATA_BODY (stmt) = cp_parser_omp_structured_block (parser, if_p); SET_EXPR_LOCATION (stmt, pragma_tok->location); return add_stmt (stmt); @@ -34867,7 +34878,7 @@ cp_parser_omp_target_update (cp_parser *parser, cp_token *pragma_tok, static bool cp_parser_omp_target (cp_parser *parser, cp_token *pragma_tok, - enum pragma_context context) + enum pragma_context context, bool *if_p) { tree *pc = NULL, stmt; @@ -34906,17 +34917,17 @@ cp_parser_omp_target (cp_parser *parser, cp_token *pragma_tok, case OMP_TEAMS: stmt = cp_parser_omp_teams (parser, pragma_tok, p_name, OMP_TARGET_CLAUSE_MASK, - cclauses); + cclauses, if_p); break; case OMP_PARALLEL: stmt = cp_parser_omp_parallel (parser, pragma_tok, p_name, OMP_TARGET_CLAUSE_MASK, - cclauses); + cclauses, if_p); break; case OMP_SIMD: stmt = cp_parser_omp_simd (parser, pragma_tok, p_name, OMP_TARGET_CLAUSE_MASK, - cclauses); + cclauses, if_p); break; default: gcc_unreachable (); @@ -34930,15 +34941,18 @@ cp_parser_omp_target (cp_parser *parser, cp_token *pragma_tok, { case OMP_TEAMS: ret = cp_parser_omp_teams (parser, pragma_tok, p_name, - OMP_TARGET_CLAUSE_MASK, cclauses); + OMP_TARGET_CLAUSE_MASK, cclauses, + if_p); break; case OMP_PARALLEL: ret = cp_parser_omp_parallel (parser, pragma_tok, p_name, - OMP_TARGET_CLAUSE_MASK, cclauses); + OMP_TARGET_CLAUSE_MASK, cclauses, + if_p); break; case OMP_SIMD: ret = cp_parser_omp_simd (parser, pragma_tok, p_name, - OMP_TARGET_CLAUSE_MASK, cclauses); + OMP_TARGET_CLAUSE_MASK, cclauses, + if_p); break; default: gcc_unreachable (); @@ -34991,7 +35005,7 @@ cp_parser_omp_target (cp_parser *parser, cp_token *pragma_tok, else if (strcmp (p, "data") == 0) { cp_lexer_consume_token (parser->lexer); - cp_parser_omp_target_data (parser, pragma_tok); + cp_parser_omp_target_data (parser, pragma_tok, if_p); return true; } else if (strcmp (p, "enter") == 0) @@ -35021,7 +35035,7 @@ cp_parser_omp_target (cp_parser *parser, cp_token *pragma_tok, "#pragma omp target", pragma_tok); pc = &OMP_TARGET_CLAUSES (stmt); keep_next_level (true); - OMP_TARGET_BODY (stmt) = cp_parser_omp_structured_block (parser); + OMP_TARGET_BODY (stmt) = cp_parser_omp_structured_block (parser, if_p); SET_EXPR_LOCATION (stmt, pragma_tok->location); add_stmt (stmt); @@ -35097,7 +35111,7 @@ cp_parser_oacc_cache (cp_parser *parser, cp_token *pragma_tok) | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT_OR_CREATE)) static tree -cp_parser_oacc_data (cp_parser *parser, cp_token *pragma_tok) +cp_parser_oacc_data (cp_parser *parser, cp_token *pragma_tok, bool *if_p) { tree stmt, clauses, block; unsigned int save; @@ -35107,7 +35121,7 @@ cp_parser_oacc_data (cp_parser *parser, cp_token *pragma_tok) block = begin_omp_parallel (); save = cp_parser_begin_omp_structured_block (parser); - cp_parser_statement (parser, NULL_TREE, false, NULL); + cp_parser_statement (parser, NULL_TREE, false, if_p); cp_parser_end_omp_structured_block (parser, save); stmt = finish_oacc_data (clauses, block); return stmt; @@ -35121,7 +35135,7 @@ cp_parser_oacc_data (cp_parser *parser, cp_token *pragma_tok) ( (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_USE_DEVICE) ) static tree -cp_parser_oacc_host_data (cp_parser *parser, cp_token *pragma_tok) +cp_parser_oacc_host_data (cp_parser *parser, cp_token *pragma_tok, bool *if_p) { tree stmt, clauses, block; unsigned int save; @@ -35131,7 +35145,7 @@ cp_parser_oacc_host_data (cp_parser *parser, cp_token *pragma_tok) block = begin_omp_parallel (); save = cp_parser_begin_omp_structured_block (parser); - cp_parser_statement (parser, NULL_TREE, false, NULL); + cp_parser_statement (parser, NULL_TREE, false, if_p); cp_parser_end_omp_structured_block (parser, save); stmt = finish_oacc_host_data (clauses, block); return stmt; @@ -35380,7 +35394,7 @@ cp_parser_oacc_enter_exit_data (cp_parser *parser, cp_token *pragma_tok, static tree cp_parser_oacc_loop (cp_parser *parser, cp_token *pragma_tok, char *p_name, - omp_clause_mask mask, tree *cclauses) + omp_clause_mask mask, tree *cclauses, bool *if_p) { strcat (p_name, " loop"); mask |= OACC_LOOP_CLAUSE_MASK; @@ -35398,7 +35412,7 @@ cp_parser_oacc_loop (cp_parser *parser, cp_token *pragma_tok, char *p_name, tree block = begin_omp_structured_block (); int save = cp_parser_begin_omp_structured_block (parser); - tree stmt = cp_parser_omp_for_loop (parser, OACC_LOOP, clauses, NULL); + tree stmt = cp_parser_omp_for_loop (parser, OACC_LOOP, clauses, NULL, if_p); cp_parser_end_omp_structured_block (parser, save); add_stmt (finish_omp_structured_block (block)); @@ -35455,7 +35469,7 @@ cp_parser_oacc_loop (cp_parser *parser, cp_token *pragma_tok, char *p_name, static tree cp_parser_oacc_kernels_parallel (cp_parser *parser, cp_token *pragma_tok, - char *p_name) + char *p_name, bool *if_p) { omp_clause_mask mask; enum tree_code code; @@ -35486,7 +35500,8 @@ cp_parser_oacc_kernels_parallel (cp_parser *parser, cp_token *pragma_tok, tree block = begin_omp_parallel (); tree clauses; - cp_parser_oacc_loop (parser, pragma_tok, p_name, mask, &clauses); + cp_parser_oacc_loop (parser, pragma_tok, p_name, mask, &clauses, + if_p); return finish_omp_construct (code, block, clauses); } } @@ -35495,7 +35510,7 @@ cp_parser_oacc_kernels_parallel (cp_parser *parser, cp_token *pragma_tok, tree block = begin_omp_parallel (); unsigned int save = cp_parser_begin_omp_structured_block (parser); - cp_parser_statement (parser, NULL_TREE, false, NULL); + cp_parser_statement (parser, NULL_TREE, false, if_p); cp_parser_end_omp_structured_block (parser, save); return finish_omp_construct (code, block, clauses); } @@ -35599,7 +35614,7 @@ cp_parser_omp_declare_simd (cp_parser *parser, cp_token *pragma_tok, if (first_p) { while (cp_lexer_next_token_is (parser->lexer, CPP_PRAGMA)) - cp_parser_pragma (parser, context); + cp_parser_pragma (parser, context, NULL); switch (context) { case pragma_external: @@ -36322,7 +36337,8 @@ cp_parser_omp_declare (cp_parser *parser, cp_token *pragma_tok, static tree cp_parser_omp_taskloop (cp_parser *parser, cp_token *pragma_tok, - char *p_name, omp_clause_mask mask, tree *cclauses) + char *p_name, omp_clause_mask mask, tree *cclauses, + bool *if_p) { tree clauses, sb, ret; unsigned int save; @@ -36345,11 +36361,11 @@ cp_parser_omp_taskloop (cp_parser *parser, cp_token *pragma_tok, cp_lexer_consume_token (parser->lexer); if (!flag_openmp) /* flag_openmp_simd */ return cp_parser_omp_simd (parser, pragma_tok, p_name, mask, - cclauses); + cclauses, if_p); sb = begin_omp_structured_block (); save = cp_parser_begin_omp_structured_block (parser); ret = cp_parser_omp_simd (parser, pragma_tok, p_name, mask, - cclauses); + cclauses, if_p); cp_parser_end_omp_structured_block (parser, save); tree body = finish_omp_structured_block (sb); if (ret == NULL) @@ -36380,7 +36396,8 @@ cp_parser_omp_taskloop (cp_parser *parser, cp_token *pragma_tok, sb = begin_omp_structured_block (); save = cp_parser_begin_omp_structured_block (parser); - ret = cp_parser_omp_for_loop (parser, OMP_TASKLOOP, clauses, cclauses); + ret = cp_parser_omp_for_loop (parser, OMP_TASKLOOP, clauses, cclauses, + if_p); cp_parser_end_omp_structured_block (parser, save); add_stmt (finish_omp_structured_block (sb)); @@ -36543,7 +36560,7 @@ cp_parser_oacc_routine (cp_parser *parser, cp_token *pragma_tok, parser->oacc_routine->clauses = c_head; while (cp_lexer_next_token_is (parser->lexer, CPP_PRAGMA)) - cp_parser_pragma (parser, context); + cp_parser_pragma (parser, context, NULL); if (first_p) { @@ -36670,7 +36687,7 @@ cp_finalize_oacc_routine (cp_parser *parser, tree fndecl, bool is_defn) /* Main entry point to OpenMP statement pragmas. */ static void -cp_parser_omp_construct (cp_parser *parser, cp_token *pragma_tok) +cp_parser_omp_construct (cp_parser *parser, cp_token *pragma_tok, bool *if_p) { tree stmt; char p_name[sizeof "#pragma omp teams distribute parallel for simd"]; @@ -36685,7 +36702,7 @@ cp_parser_omp_construct (cp_parser *parser, cp_token *pragma_tok) stmt = cp_parser_oacc_cache (parser, pragma_tok); break; case PRAGMA_OACC_DATA: - stmt = cp_parser_oacc_data (parser, pragma_tok); + stmt = cp_parser_oacc_data (parser, pragma_tok, if_p); break; case PRAGMA_OACC_ENTER_DATA: stmt = cp_parser_oacc_enter_exit_data (parser, pragma_tok, true); @@ -36694,16 +36711,18 @@ cp_parser_omp_construct (cp_parser *parser, cp_token *pragma_tok) stmt = cp_parser_oacc_enter_exit_data (parser, pragma_tok, false); break; case PRAGMA_OACC_HOST_DATA: - stmt = cp_parser_oacc_host_data (parser, pragma_tok); + stmt = cp_parser_oacc_host_data (parser, pragma_tok, if_p); break; case PRAGMA_OACC_KERNELS: case PRAGMA_OACC_PARALLEL: strcpy (p_name, "#pragma acc"); - stmt = cp_parser_oacc_kernels_parallel (parser, pragma_tok, p_name); + stmt = cp_parser_oacc_kernels_parallel (parser, pragma_tok, p_name, + if_p); break; case PRAGMA_OACC_LOOP: strcpy (p_name, "#pragma acc"); - stmt = cp_parser_oacc_loop (parser, pragma_tok, p_name, mask, NULL); + stmt = cp_parser_oacc_loop (parser, pragma_tok, p_name, mask, NULL, + if_p); break; case PRAGMA_OACC_UPDATE: stmt = cp_parser_oacc_update (parser, pragma_tok); @@ -36715,22 +36734,25 @@ cp_parser_omp_construct (cp_parser *parser, cp_token *pragma_tok) cp_parser_omp_atomic (parser, pragma_tok); return; case PRAGMA_OMP_CRITICAL: - stmt = cp_parser_omp_critical (parser, pragma_tok); + stmt = cp_parser_omp_critical (parser, pragma_tok, if_p); break; case PRAGMA_OMP_DISTRIBUTE: strcpy (p_name, "#pragma omp"); - stmt = cp_parser_omp_distribute (parser, pragma_tok, p_name, mask, NULL); + stmt = cp_parser_omp_distribute (parser, pragma_tok, p_name, mask, NULL, + if_p); break; case PRAGMA_OMP_FOR: strcpy (p_name, "#pragma omp"); - stmt = cp_parser_omp_for (parser, pragma_tok, p_name, mask, NULL); + stmt = cp_parser_omp_for (parser, pragma_tok, p_name, mask, NULL, + if_p); break; case PRAGMA_OMP_MASTER: - stmt = cp_parser_omp_master (parser, pragma_tok); + stmt = cp_parser_omp_master (parser, pragma_tok, if_p); break; case PRAGMA_OMP_PARALLEL: strcpy (p_name, "#pragma omp"); - stmt = cp_parser_omp_parallel (parser, pragma_tok, p_name, mask, NULL); + stmt = cp_parser_omp_parallel (parser, pragma_tok, p_name, mask, NULL, + if_p); break; case PRAGMA_OMP_SECTIONS: strcpy (p_name, "#pragma omp"); @@ -36738,24 +36760,27 @@ cp_parser_omp_construct (cp_parser *parser, cp_token *pragma_tok) break; case PRAGMA_OMP_SIMD: strcpy (p_name, "#pragma omp"); - stmt = cp_parser_omp_simd (parser, pragma_tok, p_name, mask, NULL); + stmt = cp_parser_omp_simd (parser, pragma_tok, p_name, mask, NULL, + if_p); break; case PRAGMA_OMP_SINGLE: - stmt = cp_parser_omp_single (parser, pragma_tok); + stmt = cp_parser_omp_single (parser, pragma_tok, if_p); break; case PRAGMA_OMP_TASK: - stmt = cp_parser_omp_task (parser, pragma_tok); + stmt = cp_parser_omp_task (parser, pragma_tok, if_p); break; case PRAGMA_OMP_TASKGROUP: - stmt = cp_parser_omp_taskgroup (parser, pragma_tok); + stmt = cp_parser_omp_taskgroup (parser, pragma_tok, if_p); break; case PRAGMA_OMP_TASKLOOP: strcpy (p_name, "#pragma omp"); - stmt = cp_parser_omp_taskloop (parser, pragma_tok, p_name, mask, NULL); + stmt = cp_parser_omp_taskloop (parser, pragma_tok, p_name, mask, NULL, + if_p); break; case PRAGMA_OMP_TEAMS: strcpy (p_name, "#pragma omp"); - stmt = cp_parser_omp_teams (parser, pragma_tok, p_name, mask, NULL); + stmt = cp_parser_omp_teams (parser, pragma_tok, p_name, mask, NULL, + if_p); break; default: gcc_unreachable (); @@ -37110,7 +37135,7 @@ cp_parser_initial_pragma (cp_token *first_token) #pragma cilk grainsize = <VALUE>. */ static void -cp_parser_cilk_grainsize (cp_parser *parser, cp_token *pragma_tok) +cp_parser_cilk_grainsize (cp_parser *parser, cp_token *pragma_tok, bool *if_p) { if (cp_parser_require (parser, CPP_EQ, RT_EQ)) { @@ -37125,7 +37150,7 @@ cp_parser_cilk_grainsize (cp_parser *parser, cp_token *pragma_tok) /* Make sure the next token is _Cilk_for, it is invalid otherwise. */ if (cp_lexer_next_token_is_keyword (parser->lexer, RID_CILK_FOR)) - cp_parser_cilk_for (parser, exp); + cp_parser_cilk_for (parser, exp, if_p); else warning_at (cp_lexer_peek_token (parser->lexer)->location, 0, "%<#pragma cilk grainsize%> is not followed by " @@ -37139,7 +37164,7 @@ cp_parser_cilk_grainsize (cp_parser *parser, cp_token *pragma_tok) regular lexer. */ static bool -cp_parser_pragma (cp_parser *parser, enum pragma_context context) +cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p) { cp_token *pragma_tok; unsigned int id; @@ -37297,19 +37322,19 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context) if (context != pragma_stmt && context != pragma_compound) goto bad_stmt; stmt = push_omp_privatization_clauses (false); - cp_parser_omp_construct (parser, pragma_tok); + cp_parser_omp_construct (parser, pragma_tok, if_p); pop_omp_privatization_clauses (stmt); return true; case PRAGMA_OMP_ORDERED: stmt = push_omp_privatization_clauses (false); - ret = cp_parser_omp_ordered (parser, pragma_tok, context); + ret = cp_parser_omp_ordered (parser, pragma_tok, context, if_p); pop_omp_privatization_clauses (stmt); return ret; case PRAGMA_OMP_TARGET: stmt = push_omp_privatization_clauses (false); - ret = cp_parser_omp_target (parser, pragma_tok, context); + ret = cp_parser_omp_target (parser, pragma_tok, context, if_p); pop_omp_privatization_clauses (stmt); return ret; @@ -37341,7 +37366,7 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context) cp_parser_error (parser, "for, while or do statement expected"); return false; } - cp_parser_iteration_statement (parser, NULL, true); + cp_parser_iteration_statement (parser, if_p, true); return true; } @@ -37353,7 +37378,7 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context) break; } stmt = push_omp_privatization_clauses (false); - cp_parser_cilk_simd (parser, pragma_tok); + cp_parser_cilk_simd (parser, pragma_tok, if_p); pop_omp_privatization_clauses (stmt); return true; @@ -37368,7 +37393,7 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context) /* Ignore the pragma if Cilk Plus is not enabled. */ if (flag_cilkplus) { - cp_parser_cilk_grainsize (parser, pragma_tok); + cp_parser_cilk_grainsize (parser, pragma_tok, if_p); return true; } else @@ -37695,7 +37720,7 @@ cp_parser_cilk_simd_all_clauses (cp_parser *parser, cp_token *pragma_token) /* Main entry-point for parsing Cilk Plus <#pragma simd> for loops. */ static void -cp_parser_cilk_simd (cp_parser *parser, cp_token *pragma_token) +cp_parser_cilk_simd (cp_parser *parser, cp_token *pragma_token, bool *if_p) { tree clauses = cp_parser_cilk_simd_all_clauses (parser, pragma_token); @@ -37711,7 +37736,7 @@ cp_parser_cilk_simd (cp_parser *parser, cp_token *pragma_token) tree sb = begin_omp_structured_block (); int save = cp_parser_begin_omp_structured_block (parser); - tree ret = cp_parser_omp_for_loop (parser, CILK_SIMD, clauses, NULL); + tree ret = cp_parser_omp_for_loop (parser, CILK_SIMD, clauses, NULL, if_p); if (ret) cpp_validate_cilk_plus_loop (OMP_FOR_BODY (ret)); cp_parser_end_omp_structured_block (parser, save); @@ -37723,7 +37748,7 @@ cp_parser_cilk_simd (cp_parser *parser, cp_token *pragma_token) when errors happen and CILK_FOR tree on success. */ static tree -cp_parser_cilk_for (cp_parser *parser, tree grain) +cp_parser_cilk_for (cp_parser *parser, tree grain, bool *if_p) { if (cp_lexer_next_token_is_not_keyword (parser->lexer, RID_CILK_FOR)) gcc_unreachable (); @@ -37736,7 +37761,7 @@ cp_parser_cilk_for (cp_parser *parser, tree grain) OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clauses) = grain; clauses = finish_omp_clauses (clauses, false); - tree ret = cp_parser_omp_for_loop (parser, CILK_FOR, clauses, NULL); + tree ret = cp_parser_omp_for_loop (parser, CILK_FOR, clauses, NULL, if_p); if (ret) cpp_validate_cilk_plus_loop (ret); else diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a62f7ec..4409f7f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,15 @@ +2016-04-15 Jakub Jelinek <jakub@redhat.com> + + PR c/70436 + * c-c++-common/Wparentheses-1.c: New test. + * c-c++-common/gomp/Wparentheses-1.c: New test. + * c-c++-common/gomp/Wparentheses-2.c: New test. + * c-c++-common/gomp/Wparentheses-3.c: New test. + * c-c++-common/gomp/Wparentheses-4.c: New test. + * c-c++-common/cilk-plus/PS/Wparentheses-1.c: New test. + * c-c++-common/cilk-plus/CK/Wparentheses-1.c: New test. + * c-c++-common/goacc/Wparentheses-1.c: New test. + 2016-04-15 Kirill Yukhin <kirill.yukhin@intel.com> PR target/70662 diff --git a/gcc/testsuite/c-c++-common/Wparentheses-1.c b/gcc/testsuite/c-c++-common/Wparentheses-1.c new file mode 100644 index 0000000..ed50608 --- /dev/null +++ b/gcc/testsuite/c-c++-common/Wparentheses-1.c @@ -0,0 +1,39 @@ +/* PR c/70436 */ +/* { dg-do compile } */ +/* { dg-options "-Wparentheses" } */ + +int a, b, c[101], d[101], e[101], f[101]; + +void +f1 (void) +{ + int i; + + if (a) /* { dg-warning "ambiguous" } */ + #pragma GCC ivdep + for (i = 0; i < 100; i++) + if (b) + c[i] = d[i] + e[i]; + else + f[i] = d[i] * e[i]; + + if (a) + #pragma GCC ivdep + for (i = 0; i < 100; i++) + { + if (b) + c[i] = d[i] + e[i]; + else + f[i] = d[i] * e[i]; + } + + if (a) + #pragma GCC ivdep + for (i = 0; i < 100; i++) + { + if (b) + c[i] = d[i] + e[i]; + } + else + f[i] = d[i] * e[i]; +} diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/Wparentheses-1.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/Wparentheses-1.c new file mode 100644 index 0000000..f07b49a --- /dev/null +++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/Wparentheses-1.c @@ -0,0 +1,69 @@ +/* PR c/70436 */ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus -Wparentheses" } */ +/* { dg-additional-options "-std=gnu99" { target c } } */ + +int a, b, c; +void bar (void); +void baz (void); + +void +f1 (void) +{ + if (a) /* { dg-warning "ambiguous" } */ + _Cilk_for (int i = 0; i < 10; i++) + if (b) + bar (); + else + baz (); + + if (a) + _Cilk_for (int i = 0; i < 10; i++) + { + if (b) + bar (); + else + baz (); + } + + if (a) + _Cilk_for (int i = 0; i < 10; i++) + { + if (b) + bar (); + } + else + baz (); +} + +void +f2 (void) +{ + if (a) /* { dg-warning "ambiguous" } */ + #pragma cilk grainsize = 2 + _Cilk_for (int i = 0; i < 10; i++) + if (b) + bar (); + else + baz (); + + if (a) + #pragma cilk grainsize = 2 + _Cilk_for (int i = 0; i < 10; i++) + { + if (b) + bar (); + else + baz (); + } + + if (a) + #pragma cilk grainsize = 2 + _Cilk_for (int i = 0; i < 10; i++) + { + if (b) + bar (); + } + else + baz (); +} diff --git a/gcc/testsuite/c-c++-common/cilk-plus/PS/Wparentheses-1.c b/gcc/testsuite/c-c++-common/cilk-plus/PS/Wparentheses-1.c new file mode 100644 index 0000000..d391d7b --- /dev/null +++ b/gcc/testsuite/c-c++-common/cilk-plus/PS/Wparentheses-1.c @@ -0,0 +1,41 @@ +/* PR c/70436 */ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus -Wparentheses" } */ + +int a, b, c; +void bar (void); +void baz (void); + +void +f1 (void) +{ + int i; + + if (a) /* { dg-warning "ambiguous" } */ + #pragma simd + for (i = 0; i < 10; i++) + if (b) + bar (); + else + baz (); + + if (a) + #pragma simd + for (i = 0; i < 10; i++) + { + if (b) + bar (); + else + baz (); + } + + if (a) + #pragma simd + for (i = 0; i < 10; i++) + { + if (b) + bar (); + } + else + baz (); +} diff --git a/gcc/testsuite/c-c++-common/goacc/Wparentheses-1.c b/gcc/testsuite/c-c++-common/goacc/Wparentheses-1.c new file mode 100644 index 0000000..08265b6 --- /dev/null +++ b/gcc/testsuite/c-c++-common/goacc/Wparentheses-1.c @@ -0,0 +1,174 @@ +/* PR c/70436 */ +/* { dg-additional-options "-Wparentheses" } */ + +int a, b, c; +void bar (void); +void baz (void); +#pragma acc routine +void bar2 (void); +#pragma acc routine +void baz2 (void); + +void +f1 (void) +{ + int i, d[10] = { 0 }; + + if (a) /* { dg-warning "ambiguous" } */ + #pragma acc data copyin (d[0:10]) + if (b) + bar (); + else + baz (); + + #pragma acc data copyin (d[0:10]) + if (a) /* { dg-warning "ambiguous" } */ + #pragma acc host_data use_device (d) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma acc kernels + if (b) + bar2 (); + else + baz2 (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma acc kernels + for (i = 0; i < 10; i++) + if (b) + bar2 (); + else + baz2 (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma acc parallel + if (b) + bar2 (); + else + baz2 (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma acc parallel loop + for (i = 0; i < 10; i++) + if (b) + bar2 (); + else + baz2 (); + + (void) d[0]; + + if (a) + #pragma acc data copyin (d[0:10]) + { + if (b) + bar (); + else + baz (); + } + + if (a) + #pragma acc data copyin (d[0:10]) + { + if (b) + bar (); + } + else + baz (); + + #pragma acc data copyin (d[0:10]) + if (a) + #pragma acc host_data use_device (d) + { + if (b) + bar (); + else + baz (); + } + + #pragma acc data copyin (d[0:10]) + if (a) + #pragma acc host_data use_device (d) + { + if (b) + bar (); + } + else + baz (); + + if (a) + #pragma acc kernels + { + if (b) + bar2 (); + else + baz2 (); + } + + if (a) + #pragma acc kernels + for (i = 0; i < 10; i++) + { + if (b) + bar2 (); + else + baz2 (); + } + + if (a) + #pragma acc parallel + { + if (b) + bar2 (); + else + baz2 (); + } + + if (a) + #pragma acc parallel loop + for (i = 0; i < 10; i++) + { + if (b) + bar2 (); + else + baz2 (); + } + + if (a) + { + #pragma acc parallel loop + for (i = 0; i < 10; i++) + if (b) + bar2 (); + else + baz2 (); + } +} + +#pragma acc routine vector +void +f2 (int *a, int b, int c) +{ + int i; + + if (b) /* { dg-warning "ambiguous" } */ + #pragma acc loop vector + for (i = 0; i < 10; i++) + if (c) + a[i] = a[i] + 1; + else + a[i] = a[i] + 2; + + if (b) + #pragma acc loop vector + for (i = 0; i < 10; i++) + { + if (c) + a[i] = a[i] + 1; + else + a[i] = a[i] + 2; + } +} diff --git a/gcc/testsuite/c-c++-common/gomp/Wparentheses-1.c b/gcc/testsuite/c-c++-common/gomp/Wparentheses-1.c new file mode 100644 index 0000000..4420d67 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/Wparentheses-1.c @@ -0,0 +1,338 @@ +/* PR c/70436 */ +/* { dg-additional-options "-Wparentheses" } */ + +int a, b, c; +void bar (void); +void baz (void); + +void +f1 (void) +{ + int i, j; + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp for + for (i = 0; i < 10; i++) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + while (1) + #pragma omp for + for (i = 0; i < 10; i++) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + for (i = 0; i < 10; i++) + #pragma omp for + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + + if (a) + #pragma omp for + for (i = 0; i < 10; i++) + if (b) /* { dg-warning "ambiguous" } */ + #pragma omp parallel for + for (j = 0; j < 10; j++) + if (c) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp taskloop + for (i = 0; i < 10; i++) + if (b) + #pragma omp parallel for + for (j = 0; j < 10; j++) + if (c) + bar (); + else + baz (); + else + bar (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp taskloop simd + for (i = 0; i < 10; i++) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp for collapse(2) + for (i = 0; i < 10; i++) + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp critical + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + for (i = 0; i < 10; i++) + #pragma omp simd + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp for simd schedule(runtime) + for (i = 0; i < 10; i++) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp master + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp parallel + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + for (i = 0; i < 10; i++) + #pragma omp parallel for + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + for (i = 0; i < 10; i++) + #pragma omp parallel for simd + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp single + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp task + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp taskgroup + if (b) + bar (); + else + baz (); + + if (a) + #pragma omp for + for (i = 0; i < 10; i++) + { + if (b) + bar (); + else + baz (); + } + + if (a) + { + #pragma omp taskloop + for (i = 0; i < 10; ++i) + if (b) + bar (); + } + else baz (); + + if (a) + #pragma omp for collapse(2) + for (i = 0; i < 10; i++) + { + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + } + + if (a) + #pragma omp critical + { + if (b) + bar (); + else + baz (); + } + + if (a) + for (i = 0; i < 10; i++) + #pragma omp simd + for (j = 0; j < 10; j++) + { + if (b) + bar (); + } + else + baz (); + + if (a) + #pragma omp for simd schedule(dynamic, 5) + for (i = 0; i < 10; i++) + { + if (b) + bar (); + else + baz (); + } + + if (a) + #pragma omp master + { + if (b) + bar (); + else + baz (); + } + + if (a) + #pragma omp parallel + { + if (b) + bar (); + else + baz (); + } + + if (a) + { + #pragma omp parallel + if (b) + bar (); + else + baz (); + } + + if (a) + for (i = 0; i < 10; i++) + #pragma omp parallel for + for (j = 0; j < 10; j++) + { + if (b) + bar (); + } + else + baz (); + + if (a) + for (i = 0; i < 10; i++) + #pragma omp parallel for simd + for (j = 0; j < 10; j++) + { + if (b) + bar (); + } + else + baz (); + + if (a) + #pragma omp single + { + if (b) + bar (); + } + else + baz (); + + if (a) + #pragma omp task + { + if (b) + bar (); + } + else + baz (); + + if (a) + #pragma omp taskgroup + { + if (b) + bar (); + else + baz (); + } + + if (a) + #pragma omp taskloop simd + for (i = 0; i < 10; i++) + { + if (b) + bar (); + else + baz (); + } +} + +void +f2 (int d, int e, int f) +{ + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp ordered + if (b) + bar (); + else + baz (); + + if (d) /* { dg-warning "ambiguous" } */ + #pragma omp ordered threads + if (b) + bar (); + else + baz (); + + if (e) + #pragma omp ordered + { + if (b) + bar (); + else + baz (); + } + + if (f) + #pragma omp ordered threads + { + if (b) + bar (); + else + baz (); + } +} diff --git a/gcc/testsuite/c-c++-common/gomp/Wparentheses-2.c b/gcc/testsuite/c-c++-common/gomp/Wparentheses-2.c new file mode 100644 index 0000000..4341b22 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/Wparentheses-2.c @@ -0,0 +1,452 @@ +/* PR c/70436 */ +/* { dg-additional-options "-Wparentheses" } */ + +int a, b, c; +void bar (void); +void baz (void); +void f1 (void); +#pragma omp declare target to (bar, baz, f1, a, b, c) + +void +f1 (void) +{ + int i, j; + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp distribute + for (i = 0; i < 10; i++) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + for (i = 0; i < 10; i++) + #pragma omp distribute simd + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + + if (a) + #pragma omp distribute parallel for + for (i = 0; i < 10; i++) + if (b) /* { dg-warning "ambiguous" } */ + #pragma omp parallel for + for (j = 0; j < 10; j++) + if (c) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp distribute parallel for simd collapse(2) + for (i = 0; i < 10; i++) + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + + if (a) + #pragma omp distribute + for (i = 0; i < 10; i++) + { + if (b) + bar (); + else + baz (); + } + + if (a) + { + #pragma omp distribute simd + for (i = 0; i < 10; ++i) + if (b) + bar (); + } + else baz (); + + if (a) + #pragma omp distribute parallel for collapse(2) + for (i = 0; i < 10; i++) + { + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + } + + if (a) + for (i = 0; i < 10; i++) + #pragma omp distribute parallel for simd + for (j = 0; j < 10; j++) + { + if (b) + bar (); + } + else + baz (); +} + +void +f2 (void) +{ + int i, j; + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp target teams distribute + for (i = 0; i < 10; i++) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + for (i = 0; i < 10; i++) + #pragma omp target teams distribute simd + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + + if (a) + #pragma omp target teams distribute parallel for + for (i = 0; i < 10; i++) + if (b) /* { dg-warning "ambiguous" } */ + #pragma omp parallel for + for (j = 0; j < 10; j++) + if (c) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp target teams distribute parallel for simd collapse(2) + for (i = 0; i < 10; i++) + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp target teams + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp target + #pragma omp parallel + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp target + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp target parallel + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp target simd + for (i = 0; i < 10; i++) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp target simd collapse(2) + for (i = 0; i < 10; i++) + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + + if (a) + #pragma omp target teams distribute + for (i = 0; i < 10; i++) + { + if (b) + bar (); + else + baz (); + } + + if (a) + { + #pragma omp target teams distribute simd + for (i = 0; i < 10; ++i) + if (b) + bar (); + } + else baz (); + + if (a) + #pragma omp target teams distribute parallel for collapse(2) + for (i = 0; i < 10; i++) + { + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + } + + if (a) + for (i = 0; i < 10; i++) + #pragma omp target teams distribute parallel for simd + for (j = 0; j < 10; j++) + { + if (b) + bar (); + } + else + baz (); + + if (a) + #pragma omp target teams + { + if (b) + bar (); + } + else + baz (); + + if (a) + #pragma omp target + #pragma omp parallel + { + if (b) + bar (); + else + baz (); + } + + if (a) + #pragma omp target + { + if (b) + bar (); + } + else + baz (); + + if (a) + #pragma omp target parallel + { + if (b) + bar (); + } + else + baz (); + + if (a) + #pragma omp target simd + for (i = 0; i < 10; i++) + { + if (b) + bar (); + else + baz (); + } + + if (a) + #pragma omp target simd + for (i = 0; i < 10; i++) + { + if (b) + bar (); + } + else + baz (); + + if (a) + #pragma omp target simd collapse(2) + for (i = 0; i < 10; i++) + { { + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + } } + + if (a) + #pragma omp target simd collapse(2) + for (i = 0; i < 10; i++) + { { + for (j = 0; j < 10; j++) + if (b) + bar (); + } + } + else + baz (); +} + +void +f3 (void) +{ + int i, j; + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp target + #pragma omp teams distribute + for (i = 0; i < 10; i++) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + for (i = 0; i < 10; i++) + #pragma omp target + #pragma omp teams distribute simd + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + + if (a) + #pragma omp target + #pragma omp teams distribute parallel for + for (i = 0; i < 10; i++) + if (b) /* { dg-warning "ambiguous" } */ + #pragma omp parallel for + for (j = 0; j < 10; j++) + if (c) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp target + #pragma omp teams distribute parallel for simd collapse(2) + for (i = 0; i < 10; i++) + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp target + #pragma omp teams + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp target + #pragma omp teams + #pragma omp parallel + if (b) + bar (); + else + baz (); + + if (a) + #pragma omp target + #pragma omp teams distribute + for (i = 0; i < 10; i++) + { + if (b) + bar (); + else + baz (); + } + + if (a) + { + #pragma omp target + #pragma omp teams distribute simd + for (i = 0; i < 10; ++i) + if (b) + bar (); + } + else baz (); + + if (a) + #pragma omp target + #pragma omp teams distribute parallel for collapse(2) + for (i = 0; i < 10; i++) + { + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + } + + if (a) + for (i = 0; i < 10; i++) + #pragma omp target + #pragma omp teams distribute parallel for simd + for (j = 0; j < 10; j++) + { + if (b) + bar (); + } + else + baz (); + + if (a) + #pragma omp target + #pragma omp teams + { + if (b) + bar (); + } + else + baz (); + + if (a) + #pragma omp target + #pragma omp teams + #pragma omp parallel + { + if (b) + bar (); + else + baz (); + } +} + +void +f4 (void) +{ + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp target data map (tofrom: b) + if (b) + bar (); + else + baz (); + + if (a) + #pragma omp target data map (tofrom: b) + { + if (b) + bar (); + else + baz (); + } +} diff --git a/gcc/testsuite/c-c++-common/gomp/Wparentheses-3.c b/gcc/testsuite/c-c++-common/gomp/Wparentheses-3.c new file mode 100644 index 0000000..1688d10 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/Wparentheses-3.c @@ -0,0 +1,338 @@ +/* PR c/70436 */ +/* { dg-additional-options "-Wparentheses -fno-openmp" } */ + +int a, b, c; +void bar (void); +void baz (void); + +void +f1 (void) +{ + int i, j; + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp for + for (i = 0; i < 10; i++) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + while (1) + #pragma omp for + for (i = 0; i < 10; i++) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + for (i = 0; i < 10; i++) + #pragma omp for + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + + if (a) + #pragma omp for + for (i = 0; i < 10; i++) + if (b) /* { dg-warning "ambiguous" } */ + #pragma omp parallel for + for (j = 0; j < 10; j++) + if (c) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp taskloop + for (i = 0; i < 10; i++) + if (b) + #pragma omp parallel for + for (j = 0; j < 10; j++) + if (c) + bar (); + else + baz (); + else + bar (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp taskloop simd + for (i = 0; i < 10; i++) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp for collapse(2) + for (i = 0; i < 10; i++) + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp critical + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + for (i = 0; i < 10; i++) + #pragma omp simd + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp for simd schedule(runtime) + for (i = 0; i < 10; i++) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp master + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp parallel + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + for (i = 0; i < 10; i++) + #pragma omp parallel for + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + for (i = 0; i < 10; i++) + #pragma omp parallel for simd + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp single + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp task + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp taskgroup + if (b) + bar (); + else + baz (); + + if (a) + #pragma omp for + for (i = 0; i < 10; i++) + { + if (b) + bar (); + else + baz (); + } + + if (a) + { + #pragma omp taskloop + for (i = 0; i < 10; ++i) + if (b) + bar (); + } + else baz (); + + if (a) + #pragma omp for collapse(2) + for (i = 0; i < 10; i++) + { + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + } + + if (a) + #pragma omp critical + { + if (b) + bar (); + else + baz (); + } + + if (a) + for (i = 0; i < 10; i++) + #pragma omp simd + for (j = 0; j < 10; j++) + { + if (b) + bar (); + } + else + baz (); + + if (a) + #pragma omp for simd schedule(dynamic, 5) + for (i = 0; i < 10; i++) + { + if (b) + bar (); + else + baz (); + } + + if (a) + #pragma omp master + { + if (b) + bar (); + else + baz (); + } + + if (a) + #pragma omp parallel + { + if (b) + bar (); + else + baz (); + } + + if (a) + { + #pragma omp parallel + if (b) + bar (); + else + baz (); + } + + if (a) + for (i = 0; i < 10; i++) + #pragma omp parallel for + for (j = 0; j < 10; j++) + { + if (b) + bar (); + } + else + baz (); + + if (a) + for (i = 0; i < 10; i++) + #pragma omp parallel for simd + for (j = 0; j < 10; j++) + { + if (b) + bar (); + } + else + baz (); + + if (a) + #pragma omp single + { + if (b) + bar (); + } + else + baz (); + + if (a) + #pragma omp task + { + if (b) + bar (); + } + else + baz (); + + if (a) + #pragma omp taskgroup + { + if (b) + bar (); + else + baz (); + } + + if (a) + #pragma omp taskloop simd + for (i = 0; i < 10; i++) + { + if (b) + bar (); + else + baz (); + } +} + +void +f2 (int d, int e, int f) +{ + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp ordered + if (b) + bar (); + else + baz (); + + if (d) /* { dg-warning "ambiguous" } */ + #pragma omp ordered threads + if (b) + bar (); + else + baz (); + + if (e) + #pragma omp ordered + { + if (b) + bar (); + else + baz (); + } + + if (f) + #pragma omp ordered threads + { + if (b) + bar (); + else + baz (); + } +} diff --git a/gcc/testsuite/c-c++-common/gomp/Wparentheses-4.c b/gcc/testsuite/c-c++-common/gomp/Wparentheses-4.c new file mode 100644 index 0000000..d44cdcd --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/Wparentheses-4.c @@ -0,0 +1,452 @@ +/* PR c/70436 */ +/* { dg-additional-options "-Wparentheses -fno-openmp" } */ + +int a, b, c; +void bar (void); +void baz (void); +void f1 (void); +#pragma omp declare target to (bar, baz, f1, a, b, c) + +void +f1 (void) +{ + int i, j; + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp distribute + for (i = 0; i < 10; i++) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + for (i = 0; i < 10; i++) + #pragma omp distribute simd + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + + if (a) + #pragma omp distribute parallel for + for (i = 0; i < 10; i++) + if (b) /* { dg-warning "ambiguous" } */ + #pragma omp parallel for + for (j = 0; j < 10; j++) + if (c) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp distribute parallel for simd collapse(2) + for (i = 0; i < 10; i++) + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + + if (a) + #pragma omp distribute + for (i = 0; i < 10; i++) + { + if (b) + bar (); + else + baz (); + } + + if (a) + { + #pragma omp distribute simd + for (i = 0; i < 10; ++i) + if (b) + bar (); + } + else baz (); + + if (a) + #pragma omp distribute parallel for collapse(2) + for (i = 0; i < 10; i++) + { + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + } + + if (a) + for (i = 0; i < 10; i++) + #pragma omp distribute parallel for simd + for (j = 0; j < 10; j++) + { + if (b) + bar (); + } + else + baz (); +} + +void +f2 (void) +{ + int i, j; + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp target teams distribute + for (i = 0; i < 10; i++) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + for (i = 0; i < 10; i++) + #pragma omp target teams distribute simd + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + + if (a) + #pragma omp target teams distribute parallel for + for (i = 0; i < 10; i++) + if (b) /* { dg-warning "ambiguous" } */ + #pragma omp parallel for + for (j = 0; j < 10; j++) + if (c) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp target teams distribute parallel for simd collapse(2) + for (i = 0; i < 10; i++) + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp target teams + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp target + #pragma omp parallel + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp target + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp target parallel + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp target simd + for (i = 0; i < 10; i++) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp target simd collapse(2) + for (i = 0; i < 10; i++) + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + + if (a) + #pragma omp target teams distribute + for (i = 0; i < 10; i++) + { + if (b) + bar (); + else + baz (); + } + + if (a) + { + #pragma omp target teams distribute simd + for (i = 0; i < 10; ++i) + if (b) + bar (); + } + else baz (); + + if (a) + #pragma omp target teams distribute parallel for collapse(2) + for (i = 0; i < 10; i++) + { + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + } + + if (a) + for (i = 0; i < 10; i++) + #pragma omp target teams distribute parallel for simd + for (j = 0; j < 10; j++) + { + if (b) + bar (); + } + else + baz (); + + if (a) + #pragma omp target teams + { + if (b) + bar (); + } + else + baz (); + + if (a) + #pragma omp target + #pragma omp parallel + { + if (b) + bar (); + else + baz (); + } + + if (a) + #pragma omp target + { + if (b) + bar (); + } + else + baz (); + + if (a) + #pragma omp target parallel + { + if (b) + bar (); + } + else + baz (); + + if (a) + #pragma omp target simd + for (i = 0; i < 10; i++) + { + if (b) + bar (); + else + baz (); + } + + if (a) + #pragma omp target simd + for (i = 0; i < 10; i++) + { + if (b) + bar (); + } + else + baz (); + + if (a) + #pragma omp target simd collapse(2) + for (i = 0; i < 10; i++) + { { + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + } } + + if (a) + #pragma omp target simd collapse(2) + for (i = 0; i < 10; i++) + { { + for (j = 0; j < 10; j++) + if (b) + bar (); + } + } + else + baz (); +} + +void +f3 (void) +{ + int i, j; + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp target + #pragma omp teams distribute + for (i = 0; i < 10; i++) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + for (i = 0; i < 10; i++) + #pragma omp target + #pragma omp teams distribute simd + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + + if (a) + #pragma omp target + #pragma omp teams distribute parallel for + for (i = 0; i < 10; i++) + if (b) /* { dg-warning "ambiguous" } */ + #pragma omp parallel for + for (j = 0; j < 10; j++) + if (c) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp target + #pragma omp teams distribute parallel for simd collapse(2) + for (i = 0; i < 10; i++) + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp target + #pragma omp teams + if (b) + bar (); + else + baz (); + + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp target + #pragma omp teams + #pragma omp parallel + if (b) + bar (); + else + baz (); + + if (a) + #pragma omp target + #pragma omp teams distribute + for (i = 0; i < 10; i++) + { + if (b) + bar (); + else + baz (); + } + + if (a) + { + #pragma omp target + #pragma omp teams distribute simd + for (i = 0; i < 10; ++i) + if (b) + bar (); + } + else baz (); + + if (a) + #pragma omp target + #pragma omp teams distribute parallel for collapse(2) + for (i = 0; i < 10; i++) + { + for (j = 0; j < 10; j++) + if (b) + bar (); + else + baz (); + } + + if (a) + for (i = 0; i < 10; i++) + #pragma omp target + #pragma omp teams distribute parallel for simd + for (j = 0; j < 10; j++) + { + if (b) + bar (); + } + else + baz (); + + if (a) + #pragma omp target + #pragma omp teams + { + if (b) + bar (); + } + else + baz (); + + if (a) + #pragma omp target + #pragma omp teams + #pragma omp parallel + { + if (b) + bar (); + else + baz (); + } +} + +void +f4 (void) +{ + if (a) /* { dg-warning "ambiguous" } */ + #pragma omp target data map (tofrom: b) + if (b) + bar (); + else + baz (); + + if (a) + #pragma omp target data map (tofrom: b) + { + if (b) + bar (); + else + baz (); + } +} |