diff options
author | Martin Liska <mliska@suse.cz> | 2022-09-26 21:05:44 +0200 |
---|---|---|
committer | Martin Liska <mliska@suse.cz> | 2022-09-26 21:05:44 +0200 |
commit | 3c527a35fa428b727807c81f1225a5e0025446c1 (patch) | |
tree | 787e21d7bf8a1d85ac7b9ccee784909e85ebf61b /gcc/c | |
parent | c9c59aa19c0b7159636763294b7b0c87c696d675 (diff) | |
parent | 7701ea4a70a5a5c0fd977da90a30ffc4f3f87617 (diff) | |
download | gcc-3c527a35fa428b727807c81f1225a5e0025446c1.zip gcc-3c527a35fa428b727807c81f1225a5e0025446c1.tar.gz gcc-3c527a35fa428b727807c81f1225a5e0025446c1.tar.bz2 |
Merge branch 'master' into devel/sphinx
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/ChangeLog | 26 | ||||
-rw-r--r-- | gcc/c/c-parser.cc | 12 | ||||
-rw-r--r-- | gcc/c/c-tree.h | 3 | ||||
-rw-r--r-- | gcc/c/c-typeck.cc | 23 | ||||
-rw-r--r-- | gcc/c/gimple-parser.cc | 5 |
5 files changed, 62 insertions, 7 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index b7fe1a4..4b852b8 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,29 @@ +2022-09-24 Jakub Jelinek <jakub@redhat.com> + + PR c/106981 + * c-typeck.cc (c_tree_equal): Only strip NON_LVALUE_EXPRs at the + start. For CONSTANT_CLASS_P or CASE_CONVERT: return false if t1 and + t2 have different types. + +2022-09-22 David Malcolm <dmalcolm@redhat.com> + + PR c/106830 + * c-parser.cc (c_parser_initelt): Initialize m_decimal. + (c_parser_cast_expression): Likewise. + (c_parser_alignof_expression): Likewise. + (c_parser_postfix_expression_after_paren_type): Likewise. + (c_parser_postfix_expression_after_primary): Likewise. + (c_parser_expression): Likewise. + (c_parser_omp_variable_list): Likewise. + (c_parser_transaction_expression): Likewise. + * c-tree.h (c_expr::set_error): Likewise. + * c-typeck.cc (c_expr_sizeof_expr): Likewise. + (parser_build_unary_op): Likewise. + (parser_build_binary_op): Likewise. + (digest_init): Likewise. + (pop_init_level): Likewise. + * gimple-parser.cc (c_parser_gimple_call_internal): Likewise. + 2022-09-19 Marek Polacek <polacek@redhat.com> PR c/106947 diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index d134448..bce79d3 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -5464,6 +5464,7 @@ c_parser_initelt (c_parser *parser, struct obstack * braced_init_obstack) = objc_build_message_expr (rec, args); mexpr.original_code = ERROR_MARK; mexpr.original_type = NULL; + mexpr.m_decimal = 0; /* Now parse and process the remainder of the initializer, starting with this message expression as a primary-expression. */ @@ -8146,6 +8147,7 @@ c_parser_cast_expression (c_parser *parser, struct c_expr *after) set_c_expr_source_range (&ret, cast_loc, expr.get_finish ()); ret.original_code = ERROR_MARK; ret.original_type = NULL; + ret.m_decimal = 0; return ret; } else @@ -8464,6 +8466,7 @@ c_parser_alignof_expression (c_parser *parser) ret.original_code = ERROR_MARK; ret.original_type = NULL; set_c_expr_source_range (&ret, start_loc, end_loc); + ret.m_decimal = 0; return ret; } else @@ -8483,6 +8486,7 @@ c_parser_alignof_expression (c_parser *parser) ret.original_code = ERROR_MARK; ret.original_type = NULL; set_c_expr_source_range (&ret, start_loc, end_loc); + ret.m_decimal = 0; return ret; } } @@ -10383,6 +10387,7 @@ c_parser_postfix_expression_after_paren_type (c_parser *parser, expr.value = build_compound_literal (start_loc, type, init.value, non_const, alignas_align); set_c_expr_source_range (&expr, init.src_range); + expr.m_decimal = 0; expr.original_code = ERROR_MARK; expr.original_type = NULL; if (type != error_mark_node @@ -10597,6 +10602,7 @@ c_parser_postfix_expression_after_primary (c_parser *parser, set_c_expr_source_range (&expr, start, finish); expr.original_code = ERROR_MARK; expr.original_type = NULL; + expr.m_decimal = 0; break; case CPP_OPEN_PAREN: /* Function call. */ @@ -10645,6 +10651,7 @@ c_parser_postfix_expression_after_primary (c_parser *parser, = c_build_function_call_vec (expr_loc, arg_loc, expr.value, exprlist, origtypes); set_c_expr_source_range (&expr, start, finish); + expr.m_decimal = 0; expr.original_code = ERROR_MARK; if (TREE_CODE (expr.value) == INTEGER_CST @@ -10695,6 +10702,7 @@ c_parser_postfix_expression_after_primary (c_parser *parser, else expr.original_type = DECL_BIT_FIELD_TYPE (field); } + expr.m_decimal = 0; break; case CPP_DEREF: /* Structure element reference. */ @@ -10736,6 +10744,7 @@ c_parser_postfix_expression_after_primary (c_parser *parser, else expr.original_type = DECL_BIT_FIELD_TYPE (field); } + expr.m_decimal = 0; break; case CPP_PLUS_PLUS: /* Postincrement. */ @@ -10806,6 +10815,7 @@ c_parser_expression (c_parser *parser) expr.value = build_compound_expr (loc, expr.value, next.value); expr.original_code = COMPOUND_EXPR; expr.original_type = next.original_type; + expr.m_decimal = 0; } return expr; } @@ -13256,6 +13266,7 @@ c_parser_omp_variable_list (c_parser *parser, t_expr.original_code = ERROR_MARK; t_expr.original_type = NULL; set_c_expr_source_range (&t_expr, op_loc, op_loc); + t_expr.m_decimal = 0; t_expr = convert_lvalue_to_rvalue (op_loc, t_expr, true, false); t = build_indirect_ref (op_loc, t_expr.value, RO_ARROW); @@ -23566,6 +23577,7 @@ c_parser_transaction_expression (c_parser *parser, enum rid keyword) TRANSACTION_EXPR_RELAXED (ret.value) = 1; SET_EXPR_LOCATION (ret.value, loc); ret.original_code = TRANSACTION_EXPR; + ret.m_decimal = 0; if (!parens.require_close (parser)) { c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL); diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h index b4231a1..46a3e8e 100644 --- a/gcc/c/c-tree.h +++ b/gcc/c/c-tree.h @@ -164,12 +164,13 @@ struct c_expr } /* Set the value to error_mark_node whilst ensuring that src_range - is initialized. */ + and m_decimal are initialized. */ void set_error () { value = error_mark_node; src_range.m_start = UNKNOWN_LOCATION; src_range.m_finish = UNKNOWN_LOCATION; + m_decimal = 0; } }; diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index 33d1e84..ac242b5 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -2994,6 +2994,7 @@ c_expr_sizeof_expr (location_t loc, struct c_expr expr) ret.value = error_mark_node; ret.original_code = ERROR_MARK; ret.original_type = NULL; + ret.m_decimal = 0; pop_maybe_used (false); } else @@ -3017,6 +3018,7 @@ c_expr_sizeof_expr (location_t loc, struct c_expr expr) c_last_sizeof_loc = loc; ret.original_code = SIZEOF_EXPR; ret.original_type = NULL; + ret.m_decimal = 0; if (C_TYPE_VARIABLE_SIZE (TREE_TYPE (folded_expr))) { /* sizeof is evaluated when given a vla (C99 6.5.3.4p2). */ @@ -3047,6 +3049,7 @@ c_expr_sizeof_type (location_t loc, struct c_type_name *t) c_last_sizeof_loc = loc; ret.original_code = SIZEOF_EXPR; ret.original_type = NULL; + ret.m_decimal = 0; if (type == error_mark_node) { ret.value = error_mark_node; @@ -3782,6 +3785,7 @@ parser_build_unary_op (location_t loc, enum tree_code code, struct c_expr arg) result.original_code = code; result.original_type = NULL; + result.m_decimal = 0; if (reject_gcc_builtin (arg.value)) { @@ -3844,6 +3848,7 @@ parser_build_binary_op (location_t location, enum tree_code code, arg1.value, arg2.value, true); result.original_code = code; result.original_type = NULL; + result.m_decimal = 0; if (TREE_CODE (result.value) == ERROR_MARK) { @@ -8072,6 +8077,7 @@ digest_init (location_t init_loc, tree type, tree init, tree origtype, expr.value = inside_init; expr.original_code = (strict_string ? STRING_CST : ERROR_MARK); expr.original_type = NULL; + expr.m_decimal = 0; maybe_warn_string_init (init_loc, type, expr); if (TYPE_DOMAIN (type) && !TYPE_MAX_VALUE (TYPE_DOMAIN (type))) @@ -8936,6 +8942,7 @@ pop_init_level (location_t loc, int implicit, ret.value = NULL_TREE; ret.original_code = ERROR_MARK; ret.original_type = NULL; + ret.m_decimal = 0; if (implicit == 0) { @@ -16044,14 +16051,10 @@ c_tree_equal (tree t1, tree t2) if (!t1 || !t2) return false; - for (code1 = TREE_CODE (t1); - CONVERT_EXPR_CODE_P (code1) - || code1 == NON_LVALUE_EXPR; + for (code1 = TREE_CODE (t1); code1 == NON_LVALUE_EXPR; code1 = TREE_CODE (t1)) t1 = TREE_OPERAND (t1, 0); - for (code2 = TREE_CODE (t2); - CONVERT_EXPR_CODE_P (code2) - || code2 == NON_LVALUE_EXPR; + for (code2 = TREE_CODE (t2); code2 == NON_LVALUE_EXPR; code2 = TREE_CODE (t2)) t2 = TREE_OPERAND (t2, 0); @@ -16062,6 +16065,9 @@ c_tree_equal (tree t1, tree t2) if (code1 != code2) return false; + if (CONSTANT_CLASS_P (t1) && !comptypes (TREE_TYPE (t1), TREE_TYPE (t2))) + return false; + switch (code1) { case INTEGER_CST: @@ -16181,6 +16187,11 @@ c_tree_equal (tree t1, tree t2) return true; } + CASE_CONVERT: + if (!comptypes (TREE_TYPE (t1), TREE_TYPE (t2))) + return false; + break; + default: break; } diff --git a/gcc/c/gimple-parser.cc b/gcc/c/gimple-parser.cc index b909eac..5a2da2c 100644 --- a/gcc/c/gimple-parser.cc +++ b/gcc/c/gimple-parser.cc @@ -1332,6 +1332,7 @@ c_parser_gimple_call_internal (gimple_parser &parser) exprlist.address ()); expr.original_code = ERROR_MARK; expr.original_type = NULL; + expr.m_decimal = 0; } } return expr; @@ -1751,6 +1752,7 @@ c_parser_gimple_postfix_expression_after_primary (gimple_parser &parser, finish = c_parser_tokens_buf (parser, 0)->location; expr.value = build_array_ref (op_loc, expr.value, idx); set_c_expr_source_range (&expr, start, finish); + expr.m_decimal = 0; expr.original_code = ERROR_MARK; expr.original_type = NULL; @@ -1774,6 +1776,7 @@ c_parser_gimple_postfix_expression_after_primary (gimple_parser &parser, expr.value = build_call_array_loc (expr_loc, TREE_TYPE (TREE_TYPE (expr.value)), expr.value, exprlist.length (), exprlist.address ()); + expr.m_decimal = 0; expr.original_code = ERROR_MARK; expr.original_type = NULL; break; @@ -1802,6 +1805,7 @@ c_parser_gimple_postfix_expression_after_primary (gimple_parser &parser, expr.value = build_component_ref (op_loc, expr.value, ident, comp_loc, UNKNOWN_LOCATION); set_c_expr_source_range (&expr, start, finish); + expr.m_decimal = 0; expr.original_code = ERROR_MARK; if (TREE_CODE (expr.value) != COMPONENT_REF) expr.original_type = NULL; @@ -1851,6 +1855,7 @@ c_parser_gimple_postfix_expression_after_primary (gimple_parser &parser, ident, comp_loc, expr.get_location ()); set_c_expr_source_range (&expr, start, finish); + expr.m_decimal = 0; expr.original_code = ERROR_MARK; if (TREE_CODE (expr.value) != COMPONENT_REF) expr.original_type = NULL; |