From patchwork Mon Sep 25 20:43:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 144571 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp1472308vqu; Mon, 25 Sep 2023 13:44:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGSWPyiLIfQbmQv3y/gnRn1U1GMz8fbR1YXuE5fEnBQTnWqwCgUegB+wPoy10F7hjg4Cq3O X-Received: by 2002:a17:906:9c2:b0:9ae:5492:640 with SMTP id r2-20020a17090609c200b009ae54920640mr6169235eje.32.1695674668818; Mon, 25 Sep 2023 13:44:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695674668; cv=none; d=google.com; s=arc-20160816; b=tT3wzl6qsEAcn2R5ZQeUWDKvxygAeUI6OCdTf1VvTLhXWFWvbmVcYJkmDIvUcs3HFt gMVlD2WrzaFkLAcYYNgE8gbNKBmVLr3Ev/waj9t5wVe1oC9fnVE2QYn+twoGHlZpjFrR Nvd8qp5aEm5rNRD+sLi3MMlDZ+p6wAIk3T/v4dn8498ObYWsEJ9ota0W+ePFVPSuQTr+ 1GC6/ebB7VHSwX7Yjgek8gGPheL1Df9HAmqStenSc/SvOeYZfwoc4SeNjjeooDY9FprN 4bRiw6bKa0NLAhphQpkYgzKmiq49T7/PL7eM8uNmt+drgrZgkd7Pn1rLTQNAfLD2uoHa bAQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dmarc-filter:delivered-to; bh=ZOoKIaG8VXYuT10vvZblWBqQfe/YVchUUWEcYj5CKAQ=; fh=1Hi9m88IqcWZGtfSxUrMGG+GBgL26N02X1SANXM6iTs=; b=RXbW/TeuJZv7kwx3T1zi5kiLDEKresfy+Ji6eA8UB1yqTXHnw4d3Kb1itwitjDsx3m 6eqwIphG/4Zxd9Dy2z2AWVPCDGI3tQgpUeY29UV501gr1+kDx8pUs41yL8Bt9yCnJ5Z5 25vvA2g8NIiHDXxcru9lZW17f4w/GieQIUN9QAlCMDzKqlnzXArwR9YyS35gxHNUyNbc lsRw3KW8dq8vY2fqCs3Bt1DFDbS/3pv8us6MhzbW3hvpeezHcvZVRElnYdPNw2LHxiSJ bBo3avPmAU5eESasAGUg0hqrQQ+qyBrmupICuA1yLb9Hxr+jL0slnReP5Wi5AmBbNX7a /1Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IGJOkB0Z; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id u27-20020a170906409b00b009a168ab6ee8si9761550ejj.724.2023.09.25.13.44.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 13:44:28 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IGJOkB0Z; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AFD243861814 for ; Mon, 25 Sep 2023 20:43:53 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 2100E3856092 for ; Mon, 25 Sep 2023 20:43:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2100E3856092 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695674598; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZOoKIaG8VXYuT10vvZblWBqQfe/YVchUUWEcYj5CKAQ=; b=IGJOkB0ZiLuRFLhrZ6VJApx/HrRNij45UKKF8UDVulK00pEtwqAK5j283sV50M7Ax8w4r6 RSmpWISZD5RhheDr6Pecc6XxHreOJEqM1aEr5mUkHaDGV0VamtiMrmQedLcLQao/83HkxF JbeM6rvdZy4R+61jc5VUXCIu7liJ0fk= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-28-UdN1dYV1OjKitMsfAiZd1w-1; Mon, 25 Sep 2023 16:43:08 -0400 X-MC-Unique: UdN1dYV1OjKitMsfAiZd1w-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-4180bc4227bso45317191cf.1 for ; Mon, 25 Sep 2023 13:43:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695674587; x=1696279387; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ZOoKIaG8VXYuT10vvZblWBqQfe/YVchUUWEcYj5CKAQ=; b=jlgm6aFvpBNkppCz1hZCq90/7wUNgiZNd181NyDMWMFwXdaiYfNvGIhV2kTKJLvE82 wHNJ+7NT9SuzWDFVRwGaXgRaqVGOroWJNK90/vMRWMX/WK/oGP+zi2eROOvG9lWCZMVu RFwtAj5J4rzbCuUiI+E14iU5EIpMTlWCGVPcoZxCA/qCthm/7ys+KmSLPlginp1csrtQ zbkBueMsGaQZqt15RZcI4svzzk943GFRNIkgPdMWcprGTdtymvm5SzBLzzEH3G08d1lx CEmIdS7i29K/ke6p21YYg7QcjM3ACw/PIt1HhCTzW3eE4I7dGHB0+MQTu3+4ziwYWjnJ IOSw== X-Gm-Message-State: AOJu0Yy0IYGo8+xNz5mk3mTxqtiUzPGAV9TLI+KMa6cz18LBF2ZP6cgX aZ/8ROROpyEIoU4NDxR01xiiAGs2Fx9C8AVUB5dlndgp/EIYG0YJ+Zuc8DkcN1iNyQmC0eu5MNl 7ZQQXYsbAZwOyU/TPTPqae1OKrMGRbJYERfAwgDQ66kVKQ6Vji9Jd+icnCpSfCaNW4DPfisASbT 8= X-Received: by 2002:ac8:5f12:0:b0:412:2c24:f497 with SMTP id x18-20020ac85f12000000b004122c24f497mr695836qta.26.1695674587229; Mon, 25 Sep 2023 13:43:07 -0700 (PDT) X-Received: by 2002:ac8:5f12:0:b0:412:2c24:f497 with SMTP id x18-20020ac85f12000000b004122c24f497mr695817qta.26.1695674586688; Mon, 25 Sep 2023 13:43:06 -0700 (PDT) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id u18-20020a05622a14d200b004108fe9697asm4012691qtx.61.2023.09.25.13.43.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 13:43:06 -0700 (PDT) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH 1/2] c++: remove NON_DEPENDENT_EXPR, part 1 Date: Mon, 25 Sep 2023 16:43:01 -0400 Message-ID: <20230925204302.1277285-1-ppalka@redhat.com> X-Mailer: git-send-email 2.42.0.270.gbcb6cae296 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778043761556675035 X-GMAIL-MSGID: 1778043761556675035 Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk? -- >8 -- This tree code dates all the way back to r69130[1] which implemented typing of non-dependent expressions. Its motivation was never clear (to me at least) since the documentation for it in e.g. cp-tree.def doesn't seem accurate anymore. build_non_dependent_expr has since gained a bunch of edge cases about whether (or how) to wrap certain templated trees, making it hard to reason about in general. So this patch removes this tree code, and temporarily turns build_non_dependent_expr into the identity function. The subsequent patch will remove build_non_dependent_expr and adjust its callers appropriately. We now need to gracefully handle templated (sub)trees in a couple of places, places which previously didn't see templated trees since they didn't look through NON_DEPENDENT_EXPR. [1]: https://gcc.gnu.org/pipermail/gcc-patches/2003-July/109355.html gcc/c-family/ChangeLog: * c-warn.cc (check_address_or_pointer_of_packed_member): Handle templated CALL_EXPR naming a local extern function. gcc/cp/ChangeLog: * class.cc (instantiate_type): Remove NON_DEPENDENT_EXPR handling. * constexpr.cc (cxx_eval_constant_expression): Likewise. (potential_constant_expression_1): Likewise. * coroutines.cc (coro_validate_builtin_call): Don't expect ALIGNOF_EXPR to be wrapped in NON_DEPENDENT_EXPR. * cp-objcp-common.cc (cp_common_init_ts): Remove NON_DEPENDENT_EXPR handling. * cp-tree.def (NON_DEPENDENT_EXPR): Remove. * cp-tree.h (build_non_dependent_expr): Temporarily redefine as the identity function. * cvt.cc (maybe_warn_nodiscard): Handle templated CALL_EXPR naming a local extern function. * cxx-pretty-print.cc (cxx_pretty_printer::expression): Remove NON_DEPENDENT_EXPR handling. * error.cc (dump_decl): Likewise. (dump_expr): Likewise. * expr.cc (mark_use): Likewise. (mark_exp_read): Likewise. * pt.cc (build_non_dependent_expr): Remove. * tree.cc (lvalue_kind): Remove NON_DEPENDENT_EXPR handling. (cp_stabilize_reference): Likewise. * typeck.cc (warn_for_null_address): Likewise. (cp_build_binary_op): Handle type-dependent SIZEOF_EXPR operands. (cp_build_unary_op) : Don't fold inside a template. gcc/testsuite/ChangeLog: * g++.dg/concepts/var-concept3.C: Adjust expected diagnostic for attempting to call a variable concept. --- gcc/c-family/c-warn.cc | 2 +- gcc/cp/class.cc | 9 -- gcc/cp/constexpr.cc | 9 -- gcc/cp/coroutines.cc | 3 +- gcc/cp/cp-objcp-common.cc | 1 - gcc/cp/cp-tree.def | 11 --- gcc/cp/cp-tree.h | 2 +- gcc/cp/cvt.cc | 4 +- gcc/cp/cxx-pretty-print.cc | 1 - gcc/cp/error.cc | 8 -- gcc/cp/expr.cc | 2 - gcc/cp/pt.cc | 92 -------------------- gcc/cp/tree.cc | 5 -- gcc/cp/typeck.cc | 13 +-- gcc/testsuite/g++.dg/concepts/var-concept3.C | 2 +- 15 files changed, 15 insertions(+), 149 deletions(-) diff --git a/gcc/c-family/c-warn.cc b/gcc/c-family/c-warn.cc index e67dd87a773..c07770394bf 100644 --- a/gcc/c-family/c-warn.cc +++ b/gcc/c-family/c-warn.cc @@ -3029,7 +3029,7 @@ check_address_or_pointer_of_packed_member (tree type, tree rhs) if (TREE_CODE (rhs) == CALL_EXPR) { rhs = CALL_EXPR_FN (rhs); /* Pointer expression. */ - if (rhs == NULL_TREE) + if (rhs == NULL_TREE || TREE_CODE (rhs) == IDENTIFIER_NODE) return NULL_TREE; rhs = TREE_TYPE (rhs); /* Pointer type. */ /* We could be called while processing a template and RHS could be diff --git a/gcc/cp/class.cc b/gcc/cp/class.cc index b71333af1f8..10de0437242 100644 --- a/gcc/cp/class.cc +++ b/gcc/cp/class.cc @@ -8843,15 +8843,6 @@ instantiate_type (tree lhstype, tree rhs, tsubst_flags_t complain) rhs = BASELINK_FUNCTIONS (rhs); } - /* If we are in a template, and have a NON_DEPENDENT_EXPR, we cannot - deduce any type information. */ - if (TREE_CODE (rhs) == NON_DEPENDENT_EXPR) - { - if (complain & tf_error) - error ("not enough type information"); - return error_mark_node; - } - /* There are only a few kinds of expressions that may have a type dependent on overload resolution. */ gcc_assert (TREE_CODE (rhs) == ADDR_EXPR diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc index 2a6601c0cbc..8c9abeeec1b 100644 --- a/gcc/cp/constexpr.cc +++ b/gcc/cp/constexpr.cc @@ -8054,7 +8054,6 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, case MODOP_EXPR: /* GCC internal stuff. */ case VA_ARG_EXPR: - case NON_DEPENDENT_EXPR: case BASELINK: case OFFSET_REF: if (!ctx->quiet) @@ -9922,14 +9921,6 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now, case BIND_EXPR: return RECUR (BIND_EXPR_BODY (t), want_rval); - case NON_DEPENDENT_EXPR: - /* Treat NON_DEPENDENT_EXPR as non-constant: it's not handled by - constexpr evaluation or tsubst, so fold_non_dependent_expr can't - do anything useful with it. And we shouldn't see it in a context - where a constant expression is strictly required, hence the assert. */ - gcc_checking_assert (!(flags & tf_error)); - return false; - case CLEANUP_POINT_EXPR: case MUST_NOT_THROW_EXPR: case TRY_CATCH_EXPR: diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index 3493d3c6ed3..df3cc820797 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -1421,8 +1421,7 @@ coro_validate_builtin_call (tree call, tsubst_flags_t) location_t loc = EXPR_LOCATION (arg); /* We expect alignof expressions in templates. */ - if (TREE_CODE (arg) == NON_DEPENDENT_EXPR - && TREE_CODE (TREE_OPERAND (arg, 0)) == ALIGNOF_EXPR) + if (TREE_CODE (arg) == ALIGNOF_EXPR) ; else if (!TREE_CONSTANT (arg)) { diff --git a/gcc/cp/cp-objcp-common.cc b/gcc/cp/cp-objcp-common.cc index 93b027b80ce..2093ae02466 100644 --- a/gcc/cp/cp-objcp-common.cc +++ b/gcc/cp/cp-objcp-common.cc @@ -525,7 +525,6 @@ cp_common_init_ts (void) MARK_TS_EXP (MUST_NOT_THROW_EXPR); MARK_TS_EXP (NEW_EXPR); MARK_TS_EXP (NOEXCEPT_EXPR); - MARK_TS_EXP (NON_DEPENDENT_EXPR); MARK_TS_EXP (OFFSETOF_EXPR); MARK_TS_EXP (OFFSET_REF); MARK_TS_EXP (PSEUDO_DTOR_EXPR); diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def index 0e66ca70e00..d78005e50b9 100644 --- a/gcc/cp/cp-tree.def +++ b/gcc/cp/cp-tree.def @@ -262,17 +262,6 @@ DEFTREECODE (TYPEID_EXPR, "typeid_expr", tcc_expression, 1) DEFTREECODE (NOEXCEPT_EXPR, "noexcept_expr", tcc_unary, 1) DEFTREECODE (SPACESHIP_EXPR, "spaceship_expr", tcc_expression, 2) -/* A placeholder for an expression that is not type-dependent, but - does occur in a template. When an expression that is not - type-dependent appears in a larger expression, we must compute the - type of that larger expression. That computation would normally - modify the original expression, which would change the mangling of - that expression if it appeared in a template argument list. In - that situation, we create a NON_DEPENDENT_EXPR to take the place of - the original expression. The expression is the only operand -- it - is only needed for diagnostics. */ -DEFTREECODE (NON_DEPENDENT_EXPR, "non_dependent_expr", tcc_expression, 1) - /* CTOR_INITIALIZER is a placeholder in template code for a call to setup_vtbl_pointer (and appears in all functions, not just ctors). */ DEFTREECODE (CTOR_INITIALIZER, "ctor_initializer", tcc_expression, 1) diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 6e34952da99..66b9a9c4b9a 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -7488,7 +7488,7 @@ 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); -extern tree build_non_dependent_expr (tree); +inline tree build_non_dependent_expr (tree t) { return t; } // XXX remove extern void make_args_non_dependent (vec *); extern bool reregister_specialization (tree, tree, tree); extern tree instantiate_non_dependent_expr (tree, tsubst_flags_t = tf_error); diff --git a/gcc/cp/cvt.cc b/gcc/cp/cvt.cc index 96abfae7725..fdd34c8562e 100644 --- a/gcc/cp/cvt.cc +++ b/gcc/cp/cvt.cc @@ -1048,7 +1048,7 @@ maybe_warn_nodiscard (tree expr, impl_conv_void implicit) call = TARGET_EXPR_INITIAL (expr); location_t loc = cp_expr_loc_or_input_loc (call); tree callee = cp_get_callee (call); - if (!callee) + if (!callee || identifier_p (callee)) return; tree type = TREE_TYPE (callee); @@ -1056,6 +1056,8 @@ maybe_warn_nodiscard (tree expr, impl_conv_void implicit) type = TYPE_PTRMEMFUNC_FN_TYPE (type); if (INDIRECT_TYPE_P (type)) type = TREE_TYPE (type); + if (!FUNC_OR_METHOD_TYPE_P (type)) + return; tree rettype = TREE_TYPE (type); tree fn = cp_get_fndecl_from_callee (callee); diff --git a/gcc/cp/cxx-pretty-print.cc b/gcc/cp/cxx-pretty-print.cc index eb16e63425f..6a82358f370 100644 --- a/gcc/cp/cxx-pretty-print.cc +++ b/gcc/cp/cxx-pretty-print.cc @@ -1207,7 +1207,6 @@ cxx_pretty_printer::expression (tree t) assignment_expression (t); break; - case NON_DEPENDENT_EXPR: case MUST_NOT_THROW_EXPR: expression (TREE_OPERAND (t, 0)); break; diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc index 8a5219a68a1..49476a57ead 100644 --- a/gcc/cp/error.cc +++ b/gcc/cp/error.cc @@ -1510,10 +1510,6 @@ dump_decl (cxx_pretty_printer *pp, tree t, int flags) dump_decl (pp, BASELINK_FUNCTIONS (t), flags); break; - case NON_DEPENDENT_EXPR: - dump_expr (pp, t, flags); - break; - case TEMPLATE_TYPE_PARM: if (flags & TFF_DECL_SPECIFIERS) pp->declaration (t); @@ -2942,10 +2938,6 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags) pp_cxx_right_paren (pp); break; - case NON_DEPENDENT_EXPR: - dump_expr (pp, TREE_OPERAND (t, 0), flags); - break; - case ARGUMENT_PACK_SELECT: dump_template_argument (pp, ARGUMENT_PACK_SELECT_FROM_PACK (t), flags); break; diff --git a/gcc/cp/expr.cc b/gcc/cp/expr.cc index cdd29c15fc3..8371a245d95 100644 --- a/gcc/cp/expr.cc +++ b/gcc/cp/expr.cc @@ -147,7 +147,6 @@ mark_use (tree expr, bool rvalue_p, bool read_p, } break; case COMPONENT_REF: - case NON_DEPENDENT_EXPR: recurse_op[0] = true; break; case COMPOUND_EXPR: @@ -371,7 +370,6 @@ mark_exp_read (tree exp) case ADDR_EXPR: case INDIRECT_REF: case FLOAT_EXPR: - case NON_DEPENDENT_EXPR: case VIEW_CONVERT_EXPR: mark_exp_read (TREE_OPERAND (exp, 0)); break; diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 73ac1cb597c..e565c0538b7 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -29294,98 +29294,6 @@ resolve_typename_type (tree type, bool only_current_p) return result; } -/* EXPR is an expression which is not type-dependent. Return a proxy - for EXPR that can be used to compute the types of larger - expressions containing EXPR. */ - -tree -build_non_dependent_expr (tree expr) -{ - tree orig_expr = expr; - tree inner_expr; - - /* When checking, try to get a constant value for all non-dependent - expressions in order to expose bugs in *_dependent_expression_p - and constexpr. This can affect code generation, see PR70704, so - only do this for -fchecking=2. */ - if (flag_checking > 1 - && cxx_dialect >= cxx11 - /* Don't do this during nsdmi parsing as it can lead to - unexpected recursive instantiations. */ - && !parsing_nsdmi () - /* Don't do this during concept processing either and for - the same reason. */ - && !processing_constraint_expression_p ()) - fold_non_dependent_expr (expr, tf_none); - - STRIP_ANY_LOCATION_WRAPPER (expr); - - /* Preserve OVERLOADs; the functions must be available to resolve - types. */ - inner_expr = expr; - if (TREE_CODE (inner_expr) == STMT_EXPR) - inner_expr = stmt_expr_value_expr (inner_expr); - if (TREE_CODE (inner_expr) == ADDR_EXPR) - inner_expr = TREE_OPERAND (inner_expr, 0); - if (TREE_CODE (inner_expr) == COMPONENT_REF) - inner_expr = TREE_OPERAND (inner_expr, 1); - if (is_overloaded_fn (inner_expr) - || TREE_CODE (inner_expr) == OFFSET_REF) - return orig_expr; - /* There is no need to return a proxy for a variable, parameter - or enumerator. */ - if (VAR_P (expr) || TREE_CODE (expr) == PARM_DECL - || TREE_CODE (expr) == CONST_DECL) - return orig_expr; - /* Preserve string constants; conversions from string constants to - "char *" are allowed, even though normally a "const char *" - cannot be used to initialize a "char *". */ - if (TREE_CODE (expr) == STRING_CST) - return orig_expr; - /* Preserve void and arithmetic constants, as an optimization -- there is no - reason to create a new node. */ - if (TREE_CODE (expr) == VOID_CST - || TREE_CODE (expr) == INTEGER_CST - || TREE_CODE (expr) == REAL_CST) - return orig_expr; - /* Preserve THROW_EXPRs -- all throw-expressions have type "void". - There is at least one place where we want to know that a - particular expression is a throw-expression: when checking a ?: - expression, there are special rules if the second or third - argument is a throw-expression. */ - if (TREE_CODE (expr) == THROW_EXPR) - return orig_expr; - - /* Don't wrap an initializer list, we need to be able to look inside. */ - if (BRACE_ENCLOSED_INITIALIZER_P (expr)) - return orig_expr; - - /* Don't wrap a dummy object, we need to be able to test for it. */ - if (is_dummy_object (expr)) - return orig_expr; - - if (TREE_CODE (expr) == COND_EXPR) - return build3 (COND_EXPR, - TREE_TYPE (expr), - build_non_dependent_expr (TREE_OPERAND (expr, 0)), - (TREE_OPERAND (expr, 1) - ? build_non_dependent_expr (TREE_OPERAND (expr, 1)) - : build_non_dependent_expr (TREE_OPERAND (expr, 0))), - build_non_dependent_expr (TREE_OPERAND (expr, 2))); - if (TREE_CODE (expr) == COMPOUND_EXPR) - return build2 (COMPOUND_EXPR, - TREE_TYPE (expr), - TREE_OPERAND (expr, 0), - build_non_dependent_expr (TREE_OPERAND (expr, 1))); - - /* If the type is unknown, it can't really be non-dependent */ - gcc_assert (TREE_TYPE (expr) != unknown_type_node); - - /* Otherwise, build a NON_DEPENDENT_EXPR. */ - return build1_loc (EXPR_LOCATION (orig_expr), NON_DEPENDENT_EXPR, - TREE_TYPE (expr), expr); -} - /* 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. */ diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc index eaf882f8854..a3d61d3e7c9 100644 --- a/gcc/cp/tree.cc +++ b/gcc/cp/tree.cc @@ -308,7 +308,6 @@ lvalue_kind (const_tree ref) its argument unmodified and we assign it to a const_tree. */ return lvalue_kind (BASELINK_FUNCTIONS (CONST_CAST_TREE (ref))); - case NON_DEPENDENT_EXPR: case PAREN_EXPR: return lvalue_kind (TREE_OPERAND (ref, 0)); @@ -412,10 +411,6 @@ cp_stabilize_reference (tree ref) STRIP_ANY_LOCATION_WRAPPER (ref); switch (TREE_CODE (ref)) { - case NON_DEPENDENT_EXPR: - /* We aren't actually evaluating this. */ - return ref; - /* We need to treat specially anything stabilize_reference doesn't handle specifically. */ case VAR_DECL: diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc index 8132bd7fccc..2cfa3c8a935 100644 --- a/gcc/cp/typeck.cc +++ b/gcc/cp/typeck.cc @@ -4844,9 +4844,6 @@ warn_for_null_address (location_t location, tree op, tsubst_flags_t complain) || warning_suppressed_p (op, OPT_Waddress)) return; - if (TREE_CODE (op) == NON_DEPENDENT_EXPR) - op = TREE_OPERAND (op, 0); - tree cop = fold_for_warn (op); if (TREE_CODE (cop) == NON_LVALUE_EXPR) @@ -5405,7 +5402,9 @@ cp_build_binary_op (const op_location_t &location, type0 = TREE_TYPE (type0); if (!TYPE_P (type1)) type1 = TREE_TYPE (type1); - if (INDIRECT_TYPE_P (type0) && same_type_p (TREE_TYPE (type0), type1)) + if (type0 + && INDIRECT_TYPE_P (type0) + && same_type_p (TREE_TYPE (type0), type1)) { if (!(TREE_CODE (first_arg) == PARM_DECL && DECL_ARRAY_PARAMETER_P (first_arg) @@ -5422,7 +5421,9 @@ cp_build_binary_op (const op_location_t &location, "first % operand was declared here"); } } - else if (TREE_CODE (type0) == ARRAY_TYPE + else if (!dependent_type_p (type0) + && !dependent_type_p (type1) + && TREE_CODE (type0) == ARRAY_TYPE && !char_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (type0))) /* Set by finish_parenthesized_expr. */ && !warning_suppressed_p (op1, OPT_Wsizeof_array_div) @@ -7399,6 +7400,8 @@ cp_build_unary_op (enum tree_code code, tree xarg, bool noconvert, complain); if (arg != error_mark_node) { + if (processing_template_decl) + return build1_loc (location, TRUTH_NOT_EXPR, boolean_type_node, arg); val = invert_truthvalue_loc (location, arg); if (obvalue_p (val)) val = non_lvalue_loc (location, val); diff --git a/gcc/testsuite/g++.dg/concepts/var-concept3.C b/gcc/testsuite/g++.dg/concepts/var-concept3.C index 6fd96a5042e..b4483ebca89 100644 --- a/gcc/testsuite/g++.dg/concepts/var-concept3.C +++ b/gcc/testsuite/g++.dg/concepts/var-concept3.C @@ -12,7 +12,7 @@ template template - requires C1() // { dg-error "cannot be used as a function" } + requires C1() // { dg-error "cannot call a concept" } void f1(U) { } template From patchwork Mon Sep 25 20:43:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 144570 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp1472049vqu; Mon, 25 Sep 2023 13:43:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHkV5kmRgepfBgigw0MMWEDF4OtZ/NKkYqvVeJ3GB7s3DRzxHViYjGDp1QdiXAKtz5kzcvN X-Received: by 2002:a17:906:5daa:b0:9ae:4776:5a32 with SMTP id n10-20020a1709065daa00b009ae47765a32mr380458ejv.30.1695674633052; Mon, 25 Sep 2023 13:43:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695674633; cv=none; d=google.com; s=arc-20160816; b=E26sJbKaFMKiVta0Vt9xr7XyzWYAnEOsqeihhA20PEmMYBjgrg/UnHmocyIMODW48H 2xW9/TcqIGqcdFyCWPyhjva4nfQffMkRlyAbuvyM+BpncmTpDKsaRQM9KZ7HpR7p2tdM sWhU0uEcbTTSRVD8EfC1mx12jlzgitoGGgHhNoLI6vWGcOLXQq3lemeocIyjcX6VmRPu ZK0SODZlMXvkVD0evWZF7nl/PAf+RlIy/Ykj8eB7gvfPjNqACPsxr8X1XGiM9kz47tKn 2tH/kYsGNpSBO67iFCMb7/m5lAa6ztTWK3Kw9rDIQ1pOA2pTpFPo8mcwCKDeaUojRqtf ULmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dmarc-filter:delivered-to; bh=rzazSARE1BZDeU01ne/ra6Pq3rvUSZJMQAoajPkeK8Q=; fh=1Hi9m88IqcWZGtfSxUrMGG+GBgL26N02X1SANXM6iTs=; b=pYV4tpkNreIENO9K5+cB6tQW+8UhpGQEekKtTKiL7KuRCeoGcrSlru8sgigCdZoZ++ IWWfMD4cUWTtT6Gb7fEI3GovifkTOlycgbrbznCGSfaDnCc1nVU5rQ+ri7+Bz/qLem/R il1wIq8g/I3EjKEUIvWQv+nTXLl9RggL0JlZpBlc+BELCgJAuPOgp785aLmNAsu5VWLH EFPv35BWKYmNRFL/8q6Ur8yibSLYtjfajIctNiliX7jF9IRV6iMyBZ2BCPmrCVDU9rXS lUMJnbCJiHPn7vGd30pkcm+C3c0AZXjLAoBjlyGmSLHH0wblGYyt22JaTNAQ9U9Vk8Y8 2kXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OVqoBWVS; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id i15-20020a1709063c4f00b009adb02a14ecsi9520112ejg.201.2023.09.25.13.43.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 13:43:53 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OVqoBWVS; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7D2A1385C6FD for ; Mon, 25 Sep 2023 20:43:37 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 38237385828E for ; Mon, 25 Sep 2023 20:43:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 38237385828E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695674590; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rzazSARE1BZDeU01ne/ra6Pq3rvUSZJMQAoajPkeK8Q=; b=OVqoBWVS10alFQO4kyh8YucXhfDrYob3GcwVnQYUVpHOFZrDoyHKmdcYkheAyiTuYc1233 6bXh4Dh96RuMv3tU2EKhyzp24cmdPNoJJ5ImvriLuRuWrWXmpcHl7vgMiamRhkhi22GIW6 auyRk8N8Ilo9AcJt2JN/P5UdeKasDgc= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-520-4_VSiAsWNMKEH3q6_-cFEw-1; Mon, 25 Sep 2023 16:43:09 -0400 X-MC-Unique: 4_VSiAsWNMKEH3q6_-cFEw-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-7740be79da3so1358388085a.3 for ; Mon, 25 Sep 2023 13:43:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695674588; x=1696279388; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rzazSARE1BZDeU01ne/ra6Pq3rvUSZJMQAoajPkeK8Q=; b=eoWlhTBKi5RwAnbKiTS5kjUS4NqtxZPEE2oqIAbtmKnXTjoaxO/JE7fIZJLyzFy+HG yh0bk7Xejf9+M+uOOZ/8tsHB9EM6UL93cs4adOEq6ic1yrstudaaRLh/OnDU27O94eYC dLyvpw9MqXJgoCCxH2+xH0rknLmdxjvLXfKRMtX9iCOR50WnHq6blInMOfEKfQN8lnob Z66zw6E3ydCzs0W36dUte2Zm/k7AK8OyknzPY9nVwuQRQCOfgQgRl9KYD7WBR8eBWdza vSaQ6PZUTiBv/hxzpyIl4w/Bsm05IEaJsihh3t50c4g0WpCMj38VfRhF7vSh7DhzHye9 zszA== X-Gm-Message-State: AOJu0YzZ4bkZe3C7PgHdz/r01hGFY0xuF35C08Wf8i86d3UDxQyXBZoQ X7m59d6zY8NmTT7P50XLlW3ESiB9zus2zJEiDAbcKES2IVQZSDaUtVZ1xfbG2zqKoKM5Xnpz7Sg vo8HNPcLB/Ox+rcCmXJMABmU+CIPq9oitrw3p2+17gLGwbzyfk4d7vDkyxvPMcR9KYq429TjvGH s= X-Received: by 2002:a05:622a:13:b0:417:de7d:f64e with SMTP id x19-20020a05622a001300b00417de7df64emr10068176qtw.62.1695674588245; Mon, 25 Sep 2023 13:43:08 -0700 (PDT) X-Received: by 2002:a05:622a:13:b0:417:de7d:f64e with SMTP id x19-20020a05622a001300b00417de7df64emr10068150qtw.62.1695674587809; Mon, 25 Sep 2023 13:43:07 -0700 (PDT) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id u18-20020a05622a14d200b004108fe9697asm4012691qtx.61.2023.09.25.13.43.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 13:43:07 -0700 (PDT) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH 2/2] c++: remove NON_DEPENDENT_EXPR, part 2 Date: Mon, 25 Sep 2023 16:43:02 -0400 Message-ID: <20230925204302.1277285-2-ppalka@redhat.com> X-Mailer: git-send-email 2.42.0.270.gbcb6cae296 In-Reply-To: <20230925204302.1277285-1-ppalka@redhat.com> References: <20230925204302.1277285-1-ppalka@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_ASCII_DIVIDERS, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778043723805765791 X-GMAIL-MSGID: 1778043723805765791 This much more mechanical patch removes build_non_dependent_expr (and make_args_non_dependent) and adjusts callers accordingly, 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): (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 **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 *); 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 **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 **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 *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 **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 *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 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))