diff options
author | Martin Liska <mliska@suse.cz> | 2022-03-06 16:28:20 +0100 |
---|---|---|
committer | Martin Liska <mliska@suse.cz> | 2022-03-06 16:28:20 +0100 |
commit | 1a576b7ac609d4225a3833e3a9c84a9439d0e45e (patch) | |
tree | 7172f94eacd2615a13f0579119f3cd5f42fdcd8e /gcc/c | |
parent | f015156d6662c3ce367c5834eb109a0a77b56f39 (diff) | |
parent | 98cd717fca9f21625b9c79c9231c2e909d1d93a3 (diff) | |
download | gcc-1a576b7ac609d4225a3833e3a9c84a9439d0e45e.zip gcc-1a576b7ac609d4225a3833e3a9c84a9439d0e45e.tar.gz gcc-1a576b7ac609d4225a3833e3a9c84a9439d0e45e.tar.bz2 |
Merge branch 'master' into devel/sphinx
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/ChangeLog | 40 | ||||
-rw-r--r-- | gcc/c/c-fold.cc | 1 | ||||
-rw-r--r-- | gcc/c/c-parser.cc | 36 | ||||
-rw-r--r-- | gcc/c/c-typeck.cc | 36 | ||||
-rw-r--r-- | gcc/c/gimple-parser.cc | 46 |
5 files changed, 141 insertions, 18 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 012800a..b177355 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,43 @@ +2022-02-23 Richard Biener <rguenther@suse.de> + + * gimple-parser.cc (c_parser_parse_gimple_body): Diagnose + SSA names without definition. + (c_parser_gimple_declaration): Handle pointer typed SSA names. + +2022-02-17 Jakub Jelinek <jakub@redhat.com> + + PR c/104532 + * c-parser.cc (c_parser_omp_variable_list): For CPP_DEREF, use + convert_lvalue_to_rvalue and build_indirect_ref instead of + build_simple_mem_ref. + +2022-02-11 Richard Biener <rguenther@suse.de> + + * gimple-parser.cc (c_parser_gimple_statement): Properly parse + VEC_COND_EXPRs. + +2022-02-10 Marcel Vollweiler <marcel@codesourcery.com> + + * c-parser.cc (c_parser_omp_clause_name): Parse 'has_device_addr' + clause. + (c_parser_omp_variable_list): Handle array sections. + (c_parser_omp_clause_has_device_addr): Added. + (c_parser_omp_all_clauses): Added PRAGMA_OMP_CLAUSE_HAS_DEVICE_ADDR + case. + (c_parser_omp_target_exit_data): Added HAS_DEVICE_ADDR to + OMP_CLAUSE_MASK. + * c-typeck.cc (handle_omp_array_sections): Handle clause restrictions. + (c_finish_omp_clauses): Handle array sections. + +2022-02-09 Jakub Jelinek <jakub@redhat.com> + + PR c/104427 + * c-parser.cc (c_parser_postfix_expression) + <case RID_BUILTIN_ASSOC_BARRIER>: Use parser_build_unary_op + instead of build1_loc to build PAREN_EXPR. + * c-typeck.cc (build_unary_op): Handle PAREN_EXPR. + * c-fold.cc (c_fully_fold_internal): Likewise. + 2022-01-17 Martin Liska <mliska@suse.cz> * Make-lang.in: Rename .c names to .cc. diff --git a/gcc/c/c-fold.cc b/gcc/c/c-fold.cc index fc593753..76ea25b 100644 --- a/gcc/c/c-fold.cc +++ b/gcc/c/c-fold.cc @@ -465,6 +465,7 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands, case BIT_NOT_EXPR: case TRUTH_NOT_EXPR: case CONJ_EXPR: + case PAREN_EXPR: unary: /* Unary operations. */ orig_op0 = op0 = TREE_OPERAND (expr, 0); diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index e9086c5..84deac0 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -10128,8 +10128,7 @@ c_parser_postfix_expression (c_parser *parser) mark_exp_read (e1.value); location_t end_loc = c_parser_peek_token (parser)->get_finish (); parens.skip_until_found_close (parser); - expr.value = build1_loc (loc, PAREN_EXPR, TREE_TYPE (e1.value), - e1.value); + expr = parser_build_unary_op (loc, PAREN_EXPR, e1); set_c_expr_source_range (&expr, start_loc, end_loc); } break; @@ -12772,7 +12771,9 @@ c_parser_omp_clause_name (c_parser *parser) result = PRAGMA_OMP_CLAUSE_GRAINSIZE; break; case 'h': - if (!strcmp ("hint", p)) + if (!strcmp ("has_device_addr", p)) + result = PRAGMA_OMP_CLAUSE_HAS_DEVICE_ADDR; + else if (!strcmp ("hint", p)) result = PRAGMA_OMP_CLAUSE_HINT; else if (!strcmp ("host", p)) result = PRAGMA_OACC_CLAUSE_HOST; @@ -13144,7 +13145,16 @@ c_parser_omp_variable_list (c_parser *parser, { location_t op_loc = c_parser_peek_token (parser)->location; if (c_parser_next_token_is (parser, CPP_DEREF)) - t = build_simple_mem_ref (t); + { + c_expr t_expr; + t_expr.value = t; + t_expr.original_code = ERROR_MARK; + t_expr.original_type = NULL; + set_c_expr_source_range (&t_expr, op_loc, op_loc); + t_expr = convert_lvalue_to_rvalue (op_loc, t_expr, + true, false); + t = build_indirect_ref (op_loc, t_expr.value, RO_ARROW); + } c_parser_consume_token (parser); if (!c_parser_next_token_is (parser, CPP_NAME)) { @@ -13165,6 +13175,7 @@ c_parser_omp_variable_list (c_parser *parser, case OMP_CLAUSE_REDUCTION: case OMP_CLAUSE_IN_REDUCTION: case OMP_CLAUSE_TASK_REDUCTION: + case OMP_CLAUSE_HAS_DEVICE_ADDR: array_section_p = false; dims.truncate (0); while (c_parser_next_token_is (parser, CPP_OPEN_SQUARE)) @@ -14325,6 +14336,16 @@ c_parser_omp_clause_use_device_addr (c_parser *parser, tree list) list); } +/* OpenMP 5.1: + has_device_addr ( variable-list ) */ + +static tree +c_parser_omp_clause_has_device_addr (c_parser *parser, tree list) +{ + return c_parser_omp_var_list_parens (parser, OMP_CLAUSE_HAS_DEVICE_ADDR, + list); +} + /* OpenMP 4.5: is_device_ptr ( variable-list ) */ @@ -17053,6 +17074,10 @@ c_parser_omp_all_clauses (c_parser *parser, omp_clause_mask mask, clauses = c_parser_omp_clause_use_device_addr (parser, clauses); c_name = "use_device_addr"; break; + case PRAGMA_OMP_CLAUSE_HAS_DEVICE_ADDR: + clauses = c_parser_omp_clause_has_device_addr (parser, clauses); + c_name = "has_device_addr"; + break; case PRAGMA_OMP_CLAUSE_IS_DEVICE_PTR: clauses = c_parser_omp_clause_is_device_ptr (parser, clauses); c_name = "is_device_ptr"; @@ -21035,7 +21060,8 @@ c_parser_omp_target_exit_data (location_t loc, c_parser *parser, | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEFAULTMAP) \ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IN_REDUCTION) \ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_THREAD_LIMIT) \ - | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IS_DEVICE_PTR)) + | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IS_DEVICE_PTR)\ + | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_HAS_DEVICE_ADDR)) static bool c_parser_omp_target (c_parser *parser, enum pragma_context context, bool *if_p) diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index b06f078..3075c88 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -4921,6 +4921,10 @@ build_unary_op (location_t location, enum tree_code code, tree xarg, ret = val; goto return_build_unary_op; + case PAREN_EXPR: + ret = build1 (code, TREE_TYPE (arg), arg); + goto return_build_unary_op; + default: gcc_unreachable (); } @@ -13800,6 +13804,8 @@ handle_omp_array_sections (tree c, enum c_omp_region_type ort) } first = c_fully_fold (first, false, NULL); OMP_CLAUSE_DECL (c) = first; + if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_HAS_DEVICE_ADDR) + return false; if (size) size = c_fully_fold (size, false, NULL); OMP_CLAUSE_SIZE (c) = size; @@ -14105,7 +14111,7 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) { bitmap_head generic_head, firstprivate_head, lastprivate_head; bitmap_head aligned_head, map_head, map_field_head, map_firstprivate_head; - bitmap_head oacc_reduction_head; + bitmap_head oacc_reduction_head, is_on_device_head; tree c, t, type, *pc; tree simdlen = NULL_TREE, safelen = NULL_TREE; bool branch_seen = false; @@ -14141,6 +14147,7 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) /* If ort == C_ORT_OMP used as nontemporal_head or use_device_xxx_head instead and for ort == C_ORT_OMP_TARGET used as in_reduction_head. */ bitmap_initialize (&oacc_reduction_head, &bitmap_default_obstack); + bitmap_initialize (&is_on_device_head, &bitmap_default_obstack); if (ort & C_ORT_ACC) for (c = clauses; c; c = OMP_CLAUSE_CHAIN (c)) @@ -14569,7 +14576,9 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) "%qE appears more than once in data clauses", t); remove = true; } - else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_PRIVATE + else if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_PRIVATE + || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_HAS_DEVICE_ADDR + || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IS_DEVICE_PTR) && bitmap_bit_p (&map_head, DECL_UID (t))) { if (ort == C_ORT_ACC) @@ -15183,7 +15192,8 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) "%qD appears more than once in data clauses", t); remove = true; } - else if (bitmap_bit_p (&firstprivate_head, DECL_UID (t))) + else if (bitmap_bit_p (&firstprivate_head, DECL_UID (t)) + || bitmap_bit_p (&is_on_device_head, DECL_UID (t))) { if (ort == C_ORT_ACC) error_at (OMP_CLAUSE_LOCATION (c), @@ -15268,6 +15278,8 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) case OMP_CLAUSE_IS_DEVICE_PTR: case OMP_CLAUSE_USE_DEVICE_PTR: t = OMP_CLAUSE_DECL (c); + if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IS_DEVICE_PTR) + bitmap_set_bit (&is_on_device_head, DECL_UID (t)); if (TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE) { if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_PTR @@ -15288,6 +15300,24 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) } goto check_dup_generic; + case OMP_CLAUSE_HAS_DEVICE_ADDR: + t = OMP_CLAUSE_DECL (c); + if (TREE_CODE (t) == TREE_LIST) + { + if (handle_omp_array_sections (c, ort)) + remove = true; + else + { + t = OMP_CLAUSE_DECL (c); + while (TREE_CODE (t) == ARRAY_REF) + t = TREE_OPERAND (t, 0); + } + } + bitmap_set_bit (&is_on_device_head, DECL_UID (t)); + if (VAR_P (t) || TREE_CODE (t) == PARM_DECL) + c_mark_addressable (t); + goto check_dup_generic_t; + case OMP_CLAUSE_USE_DEVICE_ADDR: t = OMP_CLAUSE_DECL (c); if (VAR_P (t) || TREE_CODE (t) == PARM_DECL) diff --git a/gcc/c/gimple-parser.cc b/gcc/c/gimple-parser.cc index 51ddd86..d1afd42 100644 --- a/gcc/c/gimple-parser.cc +++ b/gcc/c/gimple-parser.cc @@ -330,13 +330,17 @@ c_parser_parse_gimple_body (c_parser *cparser, char *gimple_pass, } gsi_remove (&gsi, true); } - /* Fill SSA name gaps, putting them on the freelist. */ + /* Fill SSA name gaps, putting them on the freelist and diagnose + SSA names without definition. */ for (unsigned i = 1; i < num_ssa_names; ++i) if (!ssa_name (i)) { tree name = make_ssa_name_fn (cfun, integer_type_node, NULL, i); release_ssa_name_fn (cfun, name); } + else if (!SSA_NAME_DEF_STMT (ssa_name (i))) + error ("SSA name %qE with version %d has no definition", + ssa_name (i), i); /* No explicit virtual operands (yet). */ bitmap_obstack_initialize (NULL); update_ssa (TODO_update_ssa_only_virtuals); @@ -860,9 +864,10 @@ c_parser_gimple_statement (gimple_parser &parser, gimple_seq *seq) if (lhs.value != error_mark_node && rhs.value != error_mark_node) { - /* If we parsed a comparison and the next token is a '?' then - parse a conditional expression. */ - if (COMPARISON_CLASS_P (rhs.value) + /* If we parsed a comparison or an identifier and the next token + is a '?' then parse a conditional expression. */ + if ((COMPARISON_CLASS_P (rhs.value) + || SSA_VAR_P (rhs.value)) && c_parser_next_token_is (parser, CPP_QUERY)) { struct c_expr trueval, falseval; @@ -874,7 +879,10 @@ c_parser_gimple_statement (gimple_parser &parser, gimple_seq *seq) if (trueval.value == error_mark_node || falseval.value == error_mark_node) return; - rhs.value = build3_loc (loc, COND_EXPR, TREE_TYPE (trueval.value), + rhs.value = build3_loc (loc, + VECTOR_TYPE_P (TREE_TYPE (rhs.value)) + ? VEC_COND_EXPR : COND_EXPR, + TREE_TYPE (trueval.value), rhs.value, trueval.value, falseval.value); } if (get_gimple_rhs_class (TREE_CODE (rhs.value)) == GIMPLE_INVALID_RHS) @@ -2057,16 +2065,34 @@ c_parser_gimple_declaration (gimple_parser &parser) /* Handle SSA name decls specially, they do not go into the identifier table but we simply build the SSA name for later lookup. */ unsigned version, ver_offset; - if (declarator->kind == cdk_id - && is_gimple_reg_type (specs->type) - && c_parser_parse_ssa_name_id (declarator->u.id.id, + /* Handle SSA pointer declarations in a very simplistic ways, we + probably would like to call grokdeclarator in a special mode to + just build the type of the decl - start_decl already pushes + the identifier to the bindings for lookup, something we do not + want. */ + struct c_declarator *id_declarator = declarator; + while (id_declarator->kind == cdk_pointer) + id_declarator = id_declarator->declarator; + if (id_declarator->kind == cdk_id + && (declarator->kind == cdk_pointer + || is_gimple_reg_type (specs->type)) + && c_parser_parse_ssa_name_id (id_declarator->u.id.id, &version, &ver_offset) /* The following restricts it to unnamed anonymous SSA names which fails parsing of named ones in dumps (we could decide to not dump their name for -gimple). */ && ver_offset == 0) - c_parser_parse_ssa_name (parser, declarator->u.id.id, specs->type, - version, ver_offset); + { + struct c_declarator *p = declarator; + tree type = specs->type; + while (p->kind == cdk_pointer) + { + type = build_pointer_type (type); + p = p->declarator; + } + c_parser_parse_ssa_name (parser, id_declarator->u.id.id, type, + version, ver_offset); + } else { tree postfix_attrs = NULL_TREE; |