From patchwork Tue Jul 25 19:55:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 125787 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2698681vqg; Tue, 25 Jul 2023 12:56:54 -0700 (PDT) X-Google-Smtp-Source: APBJJlFaIQz+pxj8o8YvnJsKL0srlrG+K0Mk8/HfJHYa5pIr1J7IdmEyLd7GouxCy4MdsNelkr94 X-Received: by 2002:a17:906:314a:b0:992:872:76d4 with SMTP id e10-20020a170906314a00b00992087276d4mr12570747eje.17.1690315014325; Tue, 25 Jul 2023 12:56:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690315014; cv=none; d=google.com; s=arc-20160816; b=kMVHOv+9PgV0BT499UFcKPHLYyg/lPQKLUYhSQGFNTl+FAShhrRJpq3xyGISoA2bJn pYGsJDhv0xAOytFllI+xqLQPw1n9SaVQrAF7WQaktzX6gG1nX+IMV2dV6la/2WjkMbIk zfHpuV5+7BtDvB10YsY8wVuVCZR8dSHXTO6uiuv4tcZNFAbOtAnSFwtqKyh/NxQEy1qj BEVQH/im/Q1ZIJx0TxAEI/fbo/ctb/s5MN53PAVDIY2WRz5dae7QsUIYNrdX5Mp1EmkC 6g1fJPTysRIBdEZMSDCfkY8OxZp9UBGvx6P1prnT7PY7FOFc2dB7GDbqZByEzhlEsoGL qkwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=UnMmU1LBceIvZntlMizid281mqHsOu927cN1m2FKMo8=; fh=1drzuSgAqPtVUclta6Ecfzgh/wYNtWpRJF7yhohVT0I=; b=nZFI3OV6krjWctyYkcYeJvA7w078OSXG/uOHoWq5zlxjQ976Tj7c1dVjVhqwIcrqrR kMiPeGrxvXvzPttxIAYi2YUSc2zRMkaeiY5G5vFmLAPxZPdU1dDknMb6EfX7QPFXKMJj K3nPnLg9moCjZ8RsQ1JvBDEPRyRZ7gi2dwANEFqUTqE/K9lcHj82ZRPxUjTQuEP65kjm KI/RtmZbRtU+Kw2kzv3/gHZqL+idl6x9gGRZYqAwblkYeYVCv/fjgRpbsd/J+cFZHXJn fFa4a/48wKW882llUYVx5tNb8EkYe1tAikoLAt8esDfoX4bO9ugGH4gETiymkVnRHm4f G5nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=PuXRmYhs; 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=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id t21-20020a1709066bd500b009937e7c4e53si8208025ejs.343.2023.07.25.12.56.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 12:56:54 -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=@gcc.gnu.org header.s=default header.b=PuXRmYhs; 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E00D4385C6E5 for ; Tue, 25 Jul 2023 19:56:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E00D4385C6E5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1690315001; bh=UnMmU1LBceIvZntlMizid281mqHsOu927cN1m2FKMo8=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=PuXRmYhsxr3GOMCOzcriR2XKaUl/9x9/tP1OmtnQ1JtRxW7dooOIOybYwbkXEcYc4 vY+9utKkytnBjjhkCv6pvDlvOoPXPblZXUCB10ls0IyW1bYXbII6h+98UQGDHRu4b8 X/+EjIr8MEbDcbxgNppYKE5Qu9bQwpGhwfclZD6A= 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 399C53858C3A for ; Tue, 25 Jul 2023 19:55:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 399C53858C3A Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-465-yGYzIUCRPP-NVyGr5Pnc3g-1; Tue, 25 Jul 2023 15:55:56 -0400 X-MC-Unique: yGYzIUCRPP-NVyGr5Pnc3g-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3C0008022EF for ; Tue, 25 Jul 2023 19:55:56 +0000 (UTC) Received: from pdp-11.lan (unknown [10.22.8.212]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E23A1121330; Tue, 25 Jul 2023 19:55:56 +0000 (UTC) To: GCC Patches , Jason Merrill Subject: [PATCH] c++: clear tf_partial et al in instantiate_template [PR108960] Date: Tue, 25 Jul 2023 15:55:52 -0400 Message-ID: <20230725195552.1249139-1-polacek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Marek Polacek via Gcc-patches From: Marek Polacek Reply-To: Marek Polacek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772423756299028213 X-GMAIL-MSGID: 1772423756299028213 Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? -- >8 -- In we concluded that we might clear all flags except tf_warning_or_error when performing instantiate_template. PR c++/108960 gcc/cp/ChangeLog: * pt.cc (lookup_and_finish_template_variable): Don't clear tf_partial here. (instantiate_template): Reset all complain flags except tf_warning_or_error. --- gcc/cp/pt.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) base-commit: 6e424febfbcb27c21a7fe3a137e614765f9cf9d2 diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 21b08a6266a..265e2a59a52 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -10396,12 +10396,6 @@ lookup_and_finish_template_variable (tree templ, tree targs, tree var = lookup_template_variable (templ, targs, complain); if (var == error_mark_node) return error_mark_node; - /* We may be called while doing a partial substitution, but the - type of the variable template may be auto, in which case we - will call do_auto_deduction in mark_used (which clears tf_partial) - and the auto must be properly reduced at that time for the - deduction to work. */ - complain &= ~tf_partial; var = finish_template_variable (var, complain); mark_used (var); return var; @@ -22008,6 +22002,14 @@ instantiate_template (tree tmpl, tree orig_args, tsubst_flags_t complain) if (tmpl == error_mark_node) return error_mark_node; + /* The other flags are not relevant anymore here, especially tf_partial + shouldn't be set. For instance, we may be called while doing a partial + substitution of a template variable, but the type of the variable + template may be auto, in which case we will call do_auto_deduction + in mark_used (which clears tf_partial) and the auto must be properly + reduced at that time for the deduction to work. */ + complain &= tf_warning_or_error; + gcc_assert (TREE_CODE (tmpl) == TEMPLATE_DECL); if (modules_p ())