diff options
author | Patrick Palka <ppalka@redhat.com> | 2023-10-20 10:47:07 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2023-10-20 10:47:07 -0400 |
commit | cd0e05b7ac3dee11287078acd00a19e52a738963 (patch) | |
tree | 27ec32364cd4ecdb3c847d265f3d06c203d5cd86 | |
parent | dad311874ac3b3cf4eca1c04f67cae80c953f7b8 (diff) | |
download | gcc-cd0e05b7ac3dee11287078acd00a19e52a738963.zip gcc-cd0e05b7ac3dee11287078acd00a19e52a738963.tar.gz gcc-cd0e05b7ac3dee11287078acd00a19e52a738963.tar.bz2 |
c++: remove NON_DEPENDENT_EXPR, part 2
This follow-up patch removes build_non_dependent_expr (and
make_args_non_dependent) and calls thereof, no functional change.
gcc/cp/ChangeLog:
* call.cc (build_new_method_call): Remove calls to
build_non_dependent_expr and/or make_args_non_dependent.
* coroutines.cc (finish_co_return_stmt): Likewise.
* cp-tree.h (build_non_dependent_expr): Remove.
(make_args_non_dependent): Remove.
* decl2.cc (grok_array_decl): Remove calls to
build_non_dependent_expr and/or make_args_non_dependent.
(build_offset_ref_call_from_tree): Likewise.
* init.cc (build_new): Likewise.
* pt.cc (make_args_non_dependent): Remove.
(test_build_non_dependent_expr): Remove.
(cp_pt_cc_tests): Adjust.
* semantics.cc (finish_expr_stmt): Remove calls to
build_non_dependent_expr and/or make_args_non_dependent.
(finish_for_expr): Likewise.
(finish_call_expr): Likewise.
(finish_omp_atomic): Likewise.
* typeck.cc (finish_class_member_access_expr): Likewise.
(build_x_indirect_ref): Likewise.
(build_x_binary_op): Likewise.
(build_x_array_ref): Likewise.
(build_x_vec_perm_expr): Likewise.
(build_x_shufflevector): Likewise.
(build_x_unary_op): Likewise.
(cp_build_addressof): Likewise.
(build_x_conditional_expr): Likewise.
(build_x_compound_expr): Likewise.
(build_static_cast): Likewise.
(build_x_modify_expr): Likewise.
(check_return_expr): Likewise.
* typeck2.cc (build_x_arrow): Likewise.
Reviewed-by: Jason Merrill <jason@redhat.com>
-rw-r--r-- | gcc/cp/call.cc | 7 | ||||
-rw-r--r-- | gcc/cp/coroutines.cc | 3 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 2 | ||||
-rw-r--r-- | gcc/cp/decl2.cc | 17 | ||||
-rw-r--r-- | gcc/cp/init.cc | 5 | ||||
-rw-r--r-- | gcc/cp/pt.cc | 46 | ||||
-rw-r--r-- | gcc/cp/semantics.cc | 25 | ||||
-rw-r--r-- | gcc/cp/typeck.cc | 31 | ||||
-rw-r--r-- | gcc/cp/typeck2.cc | 1 |
9 files changed, 6 insertions, 131 deletions
diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc index c1fb880..657eca9 100644 --- a/gcc/cp/call.cc +++ b/gcc/cp/call.cc @@ -11431,12 +11431,7 @@ build_new_method_call (tree instance, tree fns, vec<tree, va_gc> **args, } if (processing_template_decl) - { - orig_args = args == NULL ? NULL : make_tree_vector_copy (*args); - instance = build_non_dependent_expr (instance); - if (args != NULL) - make_args_non_dependent (*args); - } + orig_args = args == NULL ? NULL : make_tree_vector_copy (*args); /* Process the argument list. */ if (args != NULL && *args != NULL) diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index df3cc82..a5464be 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -1351,9 +1351,6 @@ finish_co_return_stmt (location_t kw, tree expr) to undo it so we can try to treat it as an rvalue below. */ expr = maybe_undo_parenthesized_ref (expr); - if (processing_template_decl) - expr = build_non_dependent_expr (expr); - if (error_operand_p (expr)) return error_mark_node; } diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index d6c6842..ff3323b 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -7491,8 +7491,6 @@ extern bool any_value_dependent_elements_p (const_tree); extern bool dependent_omp_for_p (tree, tree, tree, tree); extern tree resolve_typename_type (tree, bool); extern tree template_for_substitution (tree); -inline tree build_non_dependent_expr (tree t) { return t; } // XXX remove -extern void make_args_non_dependent (vec<tree, va_gc> *); extern bool reregister_specialization (tree, tree, tree); extern tree instantiate_non_dependent_expr (tree, tsubst_flags_t = tf_error); extern tree instantiate_non_dependent_expr_internal (tree, tsubst_flags_t); diff --git a/gcc/cp/decl2.cc b/gcc/cp/decl2.cc index 344e19e..0aa1e35 100644 --- a/gcc/cp/decl2.cc +++ b/gcc/cp/decl2.cc @@ -427,14 +427,8 @@ grok_array_decl (location_t loc, tree array_expr, tree index_exp, return build_min_nt_loc (loc, ARRAY_REF, array_expr, index_exp, NULL_TREE, NULL_TREE); } - array_expr = build_non_dependent_expr (array_expr); - if (index_exp) - index_exp = build_non_dependent_expr (index_exp); - else - { - orig_index_exp_list = make_tree_vector_copy (*index_exp_list); - make_args_non_dependent (*index_exp_list); - } + if (!index_exp) + orig_index_exp_list = make_tree_vector_copy (*index_exp_list); } type = TREE_TYPE (array_expr); @@ -5435,18 +5429,13 @@ build_offset_ref_call_from_tree (tree fn, vec<tree, va_gc> **args, orig_args = make_tree_vector_copy (*args); /* Transform the arguments and add the implicit "this" - parameter. That must be done before the FN is transformed - because we depend on the form of FN. */ - make_args_non_dependent (*args); - object = build_non_dependent_expr (object); + parameter. */ if (TREE_CODE (TREE_TYPE (fn)) == METHOD_TYPE) { if (TREE_CODE (fn) == DOTSTAR_EXPR) object = cp_build_addr_expr (object, complain); vec_safe_insert (*args, 0, object); } - /* Now that the arguments are done, transform FN. */ - fn = build_non_dependent_expr (fn); } /* A qualified name corresponding to a bound pointer-to-member is diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc index c583029..d1bae3b 100644 --- a/gcc/cp/init.cc +++ b/gcc/cp/init.cc @@ -3920,11 +3920,6 @@ build_new (location_t loc, vec<tree, va_gc> **placement, tree type, (**init)[i] = copy_node (e); } } - - make_args_non_dependent (*placement); - if (nelts) - nelts = build_non_dependent_expr (nelts); - make_args_non_dependent (*init); } if (nelts) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 85a487a..d2756c3 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -29294,24 +29294,6 @@ resolve_typename_type (tree type, bool only_current_p) return result; } -/* ARGS is a vector of expressions as arguments to a function call. - Replace the arguments with equivalent non-dependent expressions. - This modifies ARGS in place. */ - -void -make_args_non_dependent (vec<tree, va_gc> *args) -{ - unsigned int ix; - tree arg; - - FOR_EACH_VEC_SAFE_ELT (args, ix, arg) - { - tree newarg = build_non_dependent_expr (arg); - if (newarg != arg) - (*args)[ix] = newarg; - } -} - /* Returns a type which represents 'auto' or 'decltype(auto)'. We use a TEMPLATE_TYPE_PARM with a level one deeper than the actual template parms, by default. If set_canonical is true, we set TYPE_CANONICAL on it. */ @@ -31525,33 +31507,6 @@ print_template_statistics (void) namespace selftest { -/* Verify that build_non_dependent_expr () works, for various expressions, - and that location wrappers don't affect the results. */ - -static void -test_build_non_dependent_expr () -{ - location_t loc = BUILTINS_LOCATION; - - /* Verify constants, without and with location wrappers. */ - tree int_cst = build_int_cst (integer_type_node, 42); - ASSERT_EQ (int_cst, build_non_dependent_expr (int_cst)); - - tree wrapped_int_cst = maybe_wrap_with_location (int_cst, loc); - ASSERT_TRUE (location_wrapper_p (wrapped_int_cst)); - ASSERT_EQ (wrapped_int_cst, build_non_dependent_expr (wrapped_int_cst)); - - tree string_lit = build_string (4, "foo"); - TREE_TYPE (string_lit) = char_array_type_node; - string_lit = fix_string_type (string_lit); - ASSERT_EQ (string_lit, build_non_dependent_expr (string_lit)); - - tree wrapped_string_lit = maybe_wrap_with_location (string_lit, loc); - ASSERT_TRUE (location_wrapper_p (wrapped_string_lit)); - ASSERT_EQ (wrapped_string_lit, - build_non_dependent_expr (wrapped_string_lit)); -} - /* Verify that type_dependent_expression_p () works correctly, even in the presence of location wrapper nodes. */ @@ -31592,7 +31547,6 @@ test_type_dependent_expression_p () void cp_pt_cc_tests () { - test_build_non_dependent_expr (); test_type_dependent_expression_p (); } diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index 2a0cf96..5ccfa14 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -916,8 +916,7 @@ finish_expr_stmt (tree expr) expr = convert_to_void (expr, ICV_STATEMENT, tf_warning_or_error); } else if (!type_dependent_expression_p (expr)) - convert_to_void (build_non_dependent_expr (expr), ICV_STATEMENT, - tf_warning_or_error); + convert_to_void (expr, ICV_STATEMENT, tf_warning_or_error); if (check_for_bare_parameter_packs (expr)) expr = error_mark_node; @@ -1396,8 +1395,7 @@ finish_for_expr (tree expr, tree for_stmt) tf_warning_or_error); } else if (!type_dependent_expression_p (expr)) - convert_to_void (build_non_dependent_expr (expr), ICV_THIRD_IN_FOR, - tf_warning_or_error); + convert_to_void (expr, ICV_THIRD_IN_FOR, tf_warning_or_error); expr = maybe_cleanup_point_expr_void (expr); if (check_for_bare_parameter_packs (expr)) expr = error_mark_node; @@ -2819,11 +2817,6 @@ finish_call_expr (tree fn, vec<tree, va_gc> **args, bool disallow_virtual, return result; } orig_args = make_tree_vector_copy (*args); - if (!BASELINK_P (fn) - && TREE_CODE (fn) != PSEUDO_DTOR_EXPR - && TREE_TYPE (fn) != unknown_type_node) - fn = build_non_dependent_expr (fn); - make_args_non_dependent (*args); } if (TREE_CODE (fn) == COMPONENT_REF) @@ -11034,20 +11027,6 @@ finish_omp_atomic (location_t loc, enum tree_code code, enum tree_code opcode, || TREE_CODE (OMP_CLAUSE_HINT_EXPR (clauses)) != INTEGER_CST) dependent_p = true; } - if (!dependent_p) - { - lhs = build_non_dependent_expr (lhs); - if (rhs) - rhs = build_non_dependent_expr (rhs); - if (v) - v = build_non_dependent_expr (v); - if (lhs1) - lhs1 = build_non_dependent_expr (lhs1); - if (rhs1) - rhs1 = build_non_dependent_expr (rhs1); - if (r && r != void_list_node) - r = build_non_dependent_expr (r); - } } if (!dependent_p) { diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc index 2cfa3c8..f3dc80c 100644 --- a/gcc/cp/typeck.cc +++ b/gcc/cp/typeck.cc @@ -3385,7 +3385,6 @@ finish_class_member_access_expr (cp_expr object, tree name, bool template_p, return build_min_nt_loc (UNKNOWN_LOCATION, COMPONENT_REF, orig_object, orig_name, NULL_TREE); } - object = build_non_dependent_expr (object); } else if (c_dialect_objc () && identifier_p (name) @@ -3743,7 +3742,6 @@ build_x_indirect_ref (location_t loc, tree expr, ref_operator errorstring, = build_dependent_operator_type (lookups, INDIRECT_REF, false); return expr; } - expr = build_non_dependent_expr (expr); } rval = build_new_op (loc, INDIRECT_REF, LOOKUP_NORMAL, expr, @@ -4712,8 +4710,6 @@ build_x_binary_op (const op_location_t &loc, enum tree_code code, tree arg1, = build_dependent_operator_type (lookups, code, false); return expr; } - arg1 = build_non_dependent_expr (arg1); - arg2 = build_non_dependent_expr (arg2); } if (code == DOTSTAR_EXPR) @@ -4767,8 +4763,6 @@ build_x_array_ref (location_t loc, tree arg1, tree arg2, || type_dependent_expression_p (arg2)) return build_min_nt_loc (loc, ARRAY_REF, arg1, arg2, NULL_TREE, NULL_TREE); - arg1 = build_non_dependent_expr (arg1); - arg2 = build_non_dependent_expr (arg2); } expr = build_new_op (loc, ARRAY_REF, LOOKUP_NORMAL, arg1, arg2, @@ -6601,10 +6595,6 @@ build_x_vec_perm_expr (location_t loc, || type_dependent_expression_p (arg1) || type_dependent_expression_p (arg2)) return build_min_nt_loc (loc, VEC_PERM_EXPR, arg0, arg1, arg2); - arg0 = build_non_dependent_expr (arg0); - if (arg1) - arg1 = build_non_dependent_expr (arg1); - arg2 = build_non_dependent_expr (arg2); } tree exp = c_build_vec_perm_expr (loc, arg0, arg1, arg2, complain & tf_error); if (processing_template_decl && exp != error_mark_node) @@ -6632,9 +6622,6 @@ build_x_shufflevector (location_t loc, vec<tree, va_gc> *args, CALL_EXPR_IFN (exp) = IFN_SHUFFLEVECTOR; return exp; } - arg0 = build_non_dependent_expr (arg0); - arg1 = build_non_dependent_expr (arg1); - /* ??? Nothing needed for the index arguments? */ } auto_vec<tree, 16> mask; for (unsigned i = 2; i < args->length (); ++i) @@ -6804,8 +6791,6 @@ build_x_unary_op (location_t loc, enum tree_code code, cp_expr xarg, TREE_TYPE (e) = build_dependent_operator_type (lookups, code, false); return e; } - - xarg = build_non_dependent_expr (xarg); } exp = NULL_TREE; @@ -6923,8 +6908,6 @@ cp_build_addressof (location_t loc, tree arg, tsubst_flags_t complain) { if (type_dependent_expression_p (arg)) return build_min_nt_loc (loc, ADDRESSOF_EXPR, arg, NULL_TREE); - - arg = build_non_dependent_expr (arg); } tree exp = cp_build_addr_expr_strict (arg, complain); @@ -7859,10 +7842,6 @@ build_x_conditional_expr (location_t loc, tree ifexp, tree op1, tree op2, || (op1 && type_dependent_expression_p (op1)) || type_dependent_expression_p (op2)) return build_min_nt_loc (loc, COND_EXPR, ifexp, op1, op2); - ifexp = build_non_dependent_expr (ifexp); - if (op1) - op1 = build_non_dependent_expr (op1); - op2 = build_non_dependent_expr (op2); } expr = build_conditional_expr (loc, ifexp, op1, op2, complain); @@ -7983,8 +7962,6 @@ build_x_compound_expr (location_t loc, tree op1, tree op2, = build_dependent_operator_type (lookups, COMPOUND_EXPR, false); return result; } - op1 = build_non_dependent_expr (op1); - op2 = build_non_dependent_expr (op2); } result = build_new_op (loc, COMPOUND_EXPR, LOOKUP_NORMAL, op1, op2, @@ -8556,8 +8533,6 @@ build_static_cast (location_t loc, tree type, tree oexpr, protected_set_expr_location (result, loc); return result; } - else if (processing_template_decl) - expr = build_non_dependent_expr (expr); /* build_c_cast puts on a NOP_EXPR to make the result not an lvalue. Strip such NOP_EXPRs if VALUE is being used in non-lvalue context. */ @@ -9737,9 +9712,6 @@ build_x_modify_expr (location_t loc, tree lhs, enum tree_code modifycode, = build_dependent_operator_type (lookups, modifycode, true); return rval; } - - lhs = build_non_dependent_expr (lhs); - rhs = build_non_dependent_expr (rhs); } tree rval; @@ -11230,9 +11202,6 @@ check_return_expr (tree retval, bool *no_warning, bool *dangling) if (VOID_TYPE_P (functype)) return error_mark_node; - if (processing_template_decl) - retval = build_non_dependent_expr (retval); - /* Under C++11 [12.8/32 class.copy], a returned lvalue is sometimes treated as an rvalue for the purposes of overload resolution to favor move constructors over copy constructors. diff --git a/gcc/cp/typeck2.cc b/gcc/cp/typeck2.cc index 8e63fb1..309903a 100644 --- a/gcc/cp/typeck2.cc +++ b/gcc/cp/typeck2.cc @@ -2214,7 +2214,6 @@ build_x_arrow (location_t loc, tree expr, tsubst_flags_t complain) TREE_TYPE (expr) = ttype; return expr; } - expr = build_non_dependent_expr (expr); } if (MAYBE_CLASS_TYPE_P (type)) |