From patchwork Wed Jan 4 09:32:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 38825 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp5051585wrt; Wed, 4 Jan 2023 01:33:15 -0800 (PST) X-Google-Smtp-Source: AMrXdXt0C/KSfulJk+WhPwSUUL0WAvxeByGoeUWG32JlVd1T+OGqb9EIX8hEAMHHH2e7IyHzqod6 X-Received: by 2002:a17:906:8592:b0:7f9:fa80:886a with SMTP id v18-20020a170906859200b007f9fa80886amr39901022ejx.73.1672824795277; Wed, 04 Jan 2023 01:33:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672824795; cv=none; d=google.com; s=arc-20160816; b=E6R2bv93TWCL8u220ot9mVRQ+qQI/jEwX5HYpvb0G2tgheNk5Bk2FUzjv0Ma093cCn JV074Xw+MQYHDTZ58DGG0m0YOrQhLyPvlVQdXvvFmw0vrX+/r8ik54+ncc8wjxDNo+/M RGYEiuVF4GYP0BgU5HYhQ0MsqwItgTjRiMrEQpf8kvu0ciYA1u2/u2CjiEDnz7nUARxg 3JhGAUCLyvFC98W/GIrcjfF4iIWeABZZUPwxtiLWtwF+uHA3wZufIrzzAlj20BWd430P feLB2o0nzy0kQxHa9pX2Lfk81ZIC9Qxs1tRjkOXZ+H20Ars3p60hqnmuOKNBI2FAg8rg gmLQ== 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-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=F8VDCd+wnYgWpTbuvCkw3MxJ1HEQuQjG/rUhACPfBQs=; b=pXCJ48i+VKJddgAnwQceFcNv5jgHWW067O193FedyOeBrpk8pwNDXk9a7AVNoHCDvh y1Kab9QNVWpW6ib33Pq7Kf0pbbF/p40b5tD9jJ3MIkCZ2g64kI7PHVzqfNhnydpaLVrv eujN4gvRJbsmWroH0uRRBNSAKSBzI1Rq0nPULkSZaoOQaN8WE7ixcf9VNT6ATuZkRhat ihQ4qyAfPKFxwom9bynvS+j2XmKuyxA6uv3lgcdK8PorTpnomUCggu1N1Ae6oPW0H1Iq fF9+hXQbN1rczMy6T6U86oqzcncbWEUAcNFgM+U8DyRQxjMaHwojXRnXNw7uNycL4cvX TguQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=wjqyFgXe; 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 sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id ds3-20020a170907724300b0078cdba56108si27702617ejc.296.2023.01.04.01.33.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 01:33:15 -0800 (PST) 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=wjqyFgXe; 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 E828D3858C27 for ; Wed, 4 Jan 2023 09:33:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E828D3858C27 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672824793; bh=F8VDCd+wnYgWpTbuvCkw3MxJ1HEQuQjG/rUhACPfBQs=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=wjqyFgXe2mKDzu6oErrw0YFB2H+hxyrxxWFVt/+zVhnf2ryQiqDjMn9tAZ52V0nMd 6WmwY0/1XqHqN/NX/x7rdIX2+PXeECyad8+I8953uOIWlc6ZVNmBmWHQCA815Vp7yk dWO3RX8Tafva5PhIP5YZUh4U0cwrsHpc8OaGSAYo= 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 3CD743858D1E for ; Wed, 4 Jan 2023 09:32:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3CD743858D1E Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-119-5N0Y0RcxNju3XEYw_mgX3Q-1; Wed, 04 Jan 2023 04:32:30 -0500 X-MC-Unique: 5N0Y0RcxNju3XEYw_mgX3Q-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F343D3803908 for ; Wed, 4 Jan 2023 09:32:29 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.223]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B0AD8140EBF5; Wed, 4 Jan 2023 09:32:29 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 3049WR6I2398003 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 4 Jan 2023 10:32:27 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 3049WQfX2398002; Wed, 4 Jan 2023 10:32:26 +0100 Date: Wed, 4 Jan 2023 10:32:26 +0100 To: Jason Merrill Cc: gcc-patches@gcc.gnu.org, Patrick Palka Subject: [PATCH] c++: Error recovery in merge_default_template_args [PR108206] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754083932726590814?= X-GMAIL-MSGID: =?utf-8?q?1754083932726590814?= Hi! We ICE on the following testcase during error recovery, both new_parm and old_parm are error_mark_node, the ICE is on error ("redefinition of default argument for %q+#D", new_parm); inform (DECL_SOURCE_LOCATION (old_parm), "original definition appeared here"); where we don't print anything useful for new_parm and ICE trying to access DECL_SOURCE_LOCATION of old_parm. I think we shouldn't diagnose anything when either of the parms is erroneous, GCC 11 before merge_default_template_args has been added was doing if (TREE_VEC_ELT (tmpl_parms, i) == error_mark_node || TREE_VEC_ELT (parms, i) == error_mark_node) continue; tmpl_parm = TREE_VALUE (TREE_VEC_ELT (tmpl_parms, i)); if (error_operand_p (tmpl_parm)) return false; in redeclare_class_template. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2023-01-04 Jakub Jelinek PR c++/108206 * decl.cc (merge_default_template_args): Return false if either new_parm or old_parm are erroneous. * g++.dg/template/pr108206.C: New test. Jakub --- gcc/cp/decl.cc.jj 2022-12-22 11:09:52.026181629 +0100 +++ gcc/cp/decl.cc 2023-01-03 18:11:25.202223528 +0100 @@ -1556,6 +1556,8 @@ merge_default_template_args (tree new_pa tree old_parm = TREE_VALUE (TREE_VEC_ELT (old_parms, i)); tree& new_default = TREE_PURPOSE (TREE_VEC_ELT (new_parms, i)); tree& old_default = TREE_PURPOSE (TREE_VEC_ELT (old_parms, i)); + if (error_operand_p (new_parm) || error_operand_p (old_parm)) + return false; if (new_default != NULL_TREE && old_default != NULL_TREE) { auto_diagnostic_group d; --- gcc/testsuite/g++.dg/template/pr108206.C.jj 2023-01-03 18:14:18.768730450 +0100 +++ gcc/testsuite/g++.dg/template/pr108206.C 2023-01-03 18:13:40.427281176 +0100 @@ -0,0 +1,5 @@ +// PR c++/108206 +// { dg-do compile { target c++11 } } + +template void foo (T1); // { dg-error "'X' has not been declared" } +template void foo (T2); // { dg-error "'X' has not been declared" }