From patchwork Mon Nov 20 02:53:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 166923 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1947906vqn; Sun, 19 Nov 2023 18:54:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IGc0HfIh+rlByU1aJw/+H6OAj7buFP2oGZiMX3n18MlgJrMScMMseBmWngkTR3Scsf8+YTW X-Received: by 2002:a05:620a:28cf:b0:77b:c8ab:af94 with SMTP id l15-20020a05620a28cf00b0077bc8abaf94mr6871971qkp.67.1700448867546; Sun, 19 Nov 2023 18:54:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700448867; cv=pass; d=google.com; s=arc-20160816; b=EP2MlKNXcOL4FXeLj5aCXlX35jBdaopa9yKlWiqbxhPlOIgLYvJPbwMIvl/1E8B9dB pTFL3Y2WDxdcGdG7J7r+QQ18l0fgM//pjcFJGtGJnZ58AO477uv/Wsee7GGaKcOHKuHP mnPK62PSBPomD04Ofzo1VC+T/+6zxz9l0ZUX9RT5nhXHLwt4Xju7Dv8M/uRoQWeGwp2o cruSXWOqWL1q3lsuB8ORMPJxRd5GjpcOVmuwYfDinDTg2iifGew3RIyf9k6cs4tOKCLw Xl4SelaOBEFy89hUwH1yoX7C/Oc/idm9dQkDlyrtJJSQanszfiZx408pUybOyi51VnJW RkHw== ARC-Message-Signature: i=2; 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:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=J3HMUozMCr29v9K+6LOyzvECaNnSH/Sd3uAQGokxHHY=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=wwC4McHrJmHjw0P9Df2b46rNQwkxnnDFrTomW6ho43kdxMnV/w1g98TNAsuXVmmPh9 2UCYIa0ILDHpFeJjCNpjkWhTuo2GcGoaM5wLfPJ8UXng6h1uiLI03cpU3O8m9wu45U1N vPm8W3DWZI/xfg29ZKCERsXpksZVgCsSrgTtwdy1u8w57PsFghnLspViq8okZJWoMph9 PvDpp1L/RI4JJaj6By7xEQFXSCpcxipdXC/tx6nueIUvj9OY1Cvd/T83KrqU1Vn4QXVL Fl67UX/pAlNhVSgmvrpdH4t4uLJs+xi+uJy57VepVtDfFu8ON8r87jodGjZTg9wUphiC UC2g== ARC-Authentication-Results: i=2; mx.google.com; dkim=neutral (body hash did not verify) header.i=@redhat.com header.s=mimecast20190719 header.b=d9IkqGPi; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id f11-20020a05620a15ab00b007743448d7ddsi6168359qkk.212.2023.11.19.18.54.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 18:54:27 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@redhat.com header.s=mimecast20190719 header.b=d9IkqGPi; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (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 53786383E735 for ; Mon, 20 Nov 2023 02:54:27 +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.129.124]) by sourceware.org (Postfix) with ESMTPS id 2F1FF3858401 for ; Mon, 20 Nov 2023 02:54:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2F1FF3858401 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2F1FF3858401 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700448845; cv=none; b=a7q46x5bEwm2H6YZOsKVPGaNZCfH+xBJe0bNgVt4QDgJ2wJK7BeWOa8JKwGEnIdzYGGE3kSAT9Z0c2Vo4KvZp9AuoE022qZao8pbnN8FSt1W3JtfzU8HB1wMkRhSPcDKeyulVHLsjv30DV9nS+N5XwgFUptqdNHGxzvGzYjeRjg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700448845; c=relaxed/simple; bh=jRJUxSBZo+0jxXYxmKPGSfEjzeg1ZynuFfUt88xB/l4=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=maZgav/GkfkTchbvazW8dqKWbvTUMPr0nCZEa7bJAlIBYhl4PTOmFNJrp5aP5ZGXp1V0nxXeTnC1ZN4ZQ/89RPF0ZpLD6EkUuMSquETbzWO3LAV5T6FA5BCUQqA6QpUFBiAwLTL91z4yLcgk8l46MmRy5WmJ2oXcNLrsog50CXc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700448842; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Yi58amE3Vrlu568wIhZ7pVLfwR3MYoylmPKyx3dIo4g=; b=d9IkqGPiXfXqhCRjrzT7gnvP7KSUMz+03P9FtTIAM1FMXcBDbz52T9f5pXM3jKSCMNa7Ln 7iepFDB/xYcVdyS1pp7Syy6xdZyMDaNaUORxouCs6u6XTz+IiwVxlcJlWKghYvfD1sCJpy wDrM76EJnhF8xWrRTCrj+/pifRFCMR4= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-103-jXYolWIJNs2vQWpAHZ-ibA-1; Sun, 19 Nov 2023 21:54:00 -0500 X-MC-Unique: jXYolWIJNs2vQWpAHZ-ibA-1 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-41cd433742dso58056571cf.2 for ; Sun, 19 Nov 2023 18:54:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700448840; x=1701053640; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=J3HMUozMCr29v9K+6LOyzvECaNnSH/Sd3uAQGokxHHY=; b=o2MG27SvlXg3uTH9ULAXD/0bAHw1/YH+w+fqLRWfdwuvRZ4gkqVEKP7XsV25OfJ5wQ jqgB6Xm0//p0yOmQC0eb3F88jNA03pqpcws1xkfJfkHja/IiAlWSgVs9n/LKB442czG/ M3euCuhV+sVZS3dTmhwVpb9x/G2kKg24XBg4cXhaIGapvt0yvTGOZFQU7laip9WGqizh H8kgZztmZXLxp2qE3UAE8OV+TDW65eamfl4fvlliQmu7URNLEC2j7EXILAtjvorj6KUV HDvJuHvi8pbQBfhWN8WvIfBubh7jPHpZa3Z/XLd5vreRJf+s3gIOCNv3IeOqMAvlbhNu yorw== X-Gm-Message-State: AOJu0Yw9tQ46uoUbwWqsABo8+JPhyyDfTQVL2yZ4l03z8dujJeJpFNrQ ed33dJC4c6a0eRMbrfF29psyQnE93pREILF6XFWYXq4k1JE61EXD/edtNjDaglr24ys6XS7PIkE +9HcZtT4IXhmn03jYS6GpfWyX6+C42pZMvF2U8qU0bSLxsXW+LKZ3KAuarQOL0aBSiH09btWrwg == X-Received: by 2002:a05:622a:14c9:b0:421:b8bc:88f6 with SMTP id u9-20020a05622a14c900b00421b8bc88f6mr7071135qtx.46.1700448839842; Sun, 19 Nov 2023 18:53:59 -0800 (PST) X-Received: by 2002:a05:622a:14c9:b0:421:b8bc:88f6 with SMTP id u9-20020a05622a14c900b00421b8bc88f6mr7071124qtx.46.1700448839382; Sun, 19 Nov 2023 18:53:59 -0800 (PST) Received: from jason.com (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id c14-20020ac8660e000000b004198d026be6sm2333359qtp.35.2023.11.19.18.53.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 18:53:58 -0800 (PST) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: add DECL_IMPLICIT_TEMPLATE_PARM_P macro Date: Sun, 19 Nov 2023 21:53:56 -0500 Message-Id: <20231120025356.2937834-1-jason@redhat.com> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-24.4 required=5.0 tests=BAYES_00, DKIM_INVALID, DKIM_SIGNED, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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: 1783049871614367948 X-GMAIL-MSGID: 1783049871614367948 Tested x86_64-pc-linux-gnu, applying to trunk. -- 8< -- Let's use a more informative name instead of DECL_VIRTUAL_P directly. gcc/cp/ChangeLog: * cp-tree.h (DECL_TEMPLATE_PARM_CHECK): New. (DECL_IMPLICIT_TEMPLATE_PARM_P): New. (decl_template_parm_check): New. * mangle.cc (write_closure_template_head): Use it. * parser.cc (synthesize_implicit_template_parm): Likewise. * pt.cc (template_parameters_equivalent_p): Likewise. --- gcc/cp/cp-tree.h | 19 +++++++++++++++++++ gcc/cp/mangle.cc | 2 +- gcc/cp/parser.cc | 2 +- gcc/cp/pt.cc | 3 ++- 4 files changed, 23 insertions(+), 3 deletions(-) base-commit: 0d734c79387191005c909c54c7556a88254c401b diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index c7a1cf610c8..7b0b7c6a17e 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -677,10 +677,14 @@ template_info_decl_check (const_tree t, const char* f, int l, const char* fn) tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, 0); \ __t; }) +#define DECL_TEMPLATE_PARM_CHECK(NODE) \ + decl_template_parm_check ((NODE), __FILE__, __LINE__, __FUNCTION__) + #else /* ENABLE_TREE_CHECKING */ #define TEMPLATE_INFO_DECL_CHECK(NODE) (NODE) #define THUNK_FUNCTION_CHECK(NODE) (NODE) +#define DECL_TEMPLATE_PARM_CHECK(NODE) (NODE) #endif /* ENABLE_TREE_CHECKING */ @@ -3577,6 +3581,11 @@ struct GTY(()) lang_decl { need. But we want a more descriptive name. */ #define DECL_VTABLE_OR_VTT_P(NODE) DECL_VIRTUAL_P (VAR_DECL_CHECK (NODE)) +/* 1 iff a _DECL for a template parameter came from + synthesize_implicit_template_parm. */ +#define DECL_IMPLICIT_TEMPLATE_PARM_P(NODE) \ + DECL_VIRTUAL_P (DECL_TEMPLATE_PARM_CHECK (NODE)) + /* 1 iff FUNCTION_TYPE or METHOD_TYPE has a ref-qualifier (either & or &&). */ #define FUNCTION_REF_QUALIFIED(NODE) \ TREE_LANG_FLAG_4 (FUNC_OR_METHOD_CHECK (NODE)) @@ -5057,6 +5066,16 @@ get_vec_init_expr (tree t) || TREE_CODE (NODE) == TYPE_DECL \ || TREE_CODE (NODE) == TEMPLATE_DECL)) +#if ENABLE_TREE_CHECKING +inline tree +decl_template_parm_check (const_tree t, const char *f, int l, const char *fn) +{ + if (!DECL_TEMPLATE_PARM_P (t)) + tree_check_failed (t, f, l, fn, 0); + return const_cast(t); +} +#endif + /* Nonzero for a raw template parameter node. */ #define TEMPLATE_PARM_P(NODE) \ (TREE_CODE (NODE) == TEMPLATE_TYPE_PARM \ diff --git a/gcc/cp/mangle.cc b/gcc/cp/mangle.cc index afa68da871c..5137305ed07 100644 --- a/gcc/cp/mangle.cc +++ b/gcc/cp/mangle.cc @@ -1744,7 +1744,7 @@ write_closure_template_head (tree tmpl) continue; parm = TREE_VALUE (parm); - if (DECL_VIRTUAL_P (parm)) + if (DECL_IMPLICIT_TEMPLATE_PARM_P (parm)) // A synthetic parm, we're done. break; diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index d1104336215..f556b8f3c01 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -50895,7 +50895,7 @@ synthesize_implicit_template_parm (cp_parser *parser, tree constr) Note that DECL_ARTIFICIAL is used elsewhere for template parameters. */ if (TREE_VALUE (new_parm) != error_mark_node) - DECL_VIRTUAL_P (TREE_VALUE (new_parm)) = true; + DECL_IMPLICIT_TEMPLATE_PARM_P (TREE_VALUE (new_parm)) = true; tree new_decl = get_local_decls (); if (non_type) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 324f6f01555..1de9d3eb44f 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -3359,7 +3359,8 @@ template_parameters_equivalent_p (const_tree parm1, const_tree parm2) /* ... one parameter was introduced by a parameter declaration, then both are. This case arises as a result of eagerly rewriting declarations during parsing. */ - if (DECL_VIRTUAL_P (decl1) != DECL_VIRTUAL_P (decl2)) + if (DECL_IMPLICIT_TEMPLATE_PARM_P (decl1) + != DECL_IMPLICIT_TEMPLATE_PARM_P (decl2)) return false; /* ... if either declares a pack, they both do. */