From: Jason Merrill <jason@redhat.com>
To: Patrick Palka <ppalka@redhat.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 2/2] c++: remove NON_DEPENDENT_EXPR, part 2
Date: Thu, 19 Oct 2023 17:46:11 -0400 [thread overview]
Message-ID: <2269f2f4-96d6-4ea5-887d-770157963a04@redhat.com> (raw)
In-Reply-To: <20230925204302.1277285-2-ppalka@redhat.com>
On 9/25/23 16:43, Patrick Palka wrote:
> This much more mechanical patch removes build_non_dependent_expr
> (and make_args_non_dependent) and adjusts callers accordingly,
> no functional change.
These two patches are OK either separately or squashed, whichever you
prefer.
> 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):
> (build_x_compound_expr): Likewise.
> (build_static_cast): Likewise.
> (build_x_modify_expr): Likewise.
> (check_return_expr): Likewise.
> * typeck2.cc (build_x_arrow): Likewise.
> ---
> gcc/cp/call.cc | 7 +------
> gcc/cp/coroutines.cc | 3 ---
> gcc/cp/cp-tree.h | 2 --
> gcc/cp/decl2.cc | 17 +++-------------
> gcc/cp/init.cc | 5 -----
> gcc/cp/pt.cc | 46 --------------------------------------------
> gcc/cp/semantics.cc | 25 ++----------------------
> gcc/cp/typeck.cc | 31 -----------------------------
> 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 e8dafbd8ba6..15079ddf6dc 100644
> --- a/gcc/cp/call.cc
> +++ b/gcc/cp/call.cc
> @@ -11430,12 +11430,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 df3cc820797..a5464becf7f 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 66b9a9c4b9a..8b9a7d58462 100644
> --- a/gcc/cp/cp-tree.h
> +++ b/gcc/cp/cp-tree.h
> @@ -7488,8 +7488,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 344e19ec98b..0aa1e355972 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 c5830297b93..d1bae3b155f 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 e565c0538b7..382db4dd01d 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. */
> @@ -31523,33 +31505,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. */
>
> @@ -31590,7 +31545,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 80ef1364e33..1d478f0781f 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 2cfa3c8a935..f3dc80c40cf 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 cd1ea045720..5ac8d3d08e9 100644
> --- a/gcc/cp/typeck2.cc
> +++ b/gcc/cp/typeck2.cc
> @@ -2218,7 +2218,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))
next prev parent reply other threads:[~2023-10-19 21:46 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-25 20:43 [PATCH 1/2] c++: remove NON_DEPENDENT_EXPR, part 1 Patrick Palka
2023-09-25 20:43 ` [PATCH 2/2] c++: remove NON_DEPENDENT_EXPR, part 2 Patrick Palka
2023-10-02 19:37 ` [PATCH] c++: merge tsubst_copy into tsubst_copy_and_build Patrick Palka
2023-10-03 12:41 ` Patrick Palka
2023-10-03 21:57 ` Jason Merrill
2023-10-04 16:08 ` Patrick Palka
2023-10-04 19:23 ` [PATCH 2/1] c++: rename tsubst_copy_and_build and tsubst_expr Patrick Palka
2023-10-19 21:43 ` Jason Merrill
2023-10-19 21:43 ` [PATCH] c++: merge tsubst_copy into tsubst_copy_and_build Jason Merrill
2023-10-19 21:46 ` Jason Merrill [this message]
2023-10-20 15:57 ` [PATCH 2/2] c++: remove NON_DEPENDENT_EXPR, part 2 Andrew Pinski
2023-09-26 23:18 ` [PATCH 1/2] c++: remove NON_DEPENDENT_EXPR, part 1 Jason Merrill
2023-09-27 11:54 ` Patrick Palka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2269f2f4-96d6-4ea5-887d-770157963a04@redhat.com \
--to=jason@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=ppalka@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).