From patchwork Wed Jul 19 18:05:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1809985 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=PX+btcmT; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R5kJv4mpKz20FK for ; Thu, 20 Jul 2023 04:06:07 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E7B18385AFB5 for ; Wed, 19 Jul 2023 18:06:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E7B18385AFB5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689789964; bh=BBjsB8Vmwoxu3VswRZ01qHWNiic3cteCqrO1Hn1jQTg=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=PX+btcmTUXJ6QY1aF90flkI8UDecw36EfIU6vUrAZw/X1JE5Hr5AeaO+EgjiWJu6M jUzGiL+qx9OtYpaUjz1IOo/KX5H0WV+eoDy0tz2USJ7aZk+kVWJXaHu0XqeKSvnu98 W/tPwk2hgh9orGQ4lapMMFccwS9FwNqvIjpNSXDg= 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 777B6385AF95 for ; Wed, 19 Jul 2023 18:05:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 777B6385AF95 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-61-8Exar72tPYWczs1yosK2sA-1; Wed, 19 Jul 2023 14:05:40 -0400 X-MC-Unique: 8Exar72tPYWczs1yosK2sA-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-40539d12372so145911cf.0 for ; Wed, 19 Jul 2023 11:05:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689789938; x=1692381938; 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=BBjsB8Vmwoxu3VswRZ01qHWNiic3cteCqrO1Hn1jQTg=; b=JI5CpY+JvQv6U/ASfSk8fGx4VLV1SJH0uzGVT3VDVyMwtI2cRPpKK10gOPFjRmRVKM RExh4czsrJACu3jKkmyPGn2wo3j4xZABJSMT5Q/asCb7wjVT2/vlKqrJZO5K73PrZyvv 2zTnUqUhui7s/b2Ter36yPrHD9j+pFbEvAUUaL+o414Snz9QkyD/m7ZtwGtgU4aUXRI0 ko5/d4pMrIme4si5vL70OZt53RA6jHxhgWBKeyHzSCLyRzieDmWC56ZhqKilRYIBX2mK FQ9sbJfH00Lvr0OBhsRvB3LB2uLfKZl/t7P2uVZ4mfiwIuHej45rrQZ/mN/YjH2wBmEp YmOw== X-Gm-Message-State: ABy/qLacxRQo1Stnc0G9MqqpBbCRha8Knh+xFbpeqobZHF5m2C60R0Jn NqWBd0RW16chL1gZSvQot2G5KiicHA4SNe0elsSO7m1ev/Ik8dbqmySz8u5K8hMTTon5P86+IHq Ma92uH0nGmA3SJihr6ZT6jQr9/p9FgY8LjO9wgzx+nQXFJ9g9gY1UquuVZ82yo3yzEnHZ08oK65 A= X-Received: by 2002:ac8:5ac3:0:b0:403:a7c0:c597 with SMTP id d3-20020ac85ac3000000b00403a7c0c597mr23037900qtd.19.1689789938417; Wed, 19 Jul 2023 11:05:38 -0700 (PDT) X-Google-Smtp-Source: APBJJlGaIVW+E0LVCh6SFNVGQijUeGn2oGuZlQgVvAvNmu2kAD+fuVikJSN0Xibg9NsfB3cuj9GEtA== X-Received: by 2002:ac8:5ac3:0:b0:403:a7c0:c597 with SMTP id d3-20020ac85ac3000000b00403a7c0c597mr23037871qtd.19.1689789938104; Wed, 19 Jul 2023 11:05:38 -0700 (PDT) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id h23-20020ac87457000000b003f9b9d7f319sm1484412qtr.70.2023.07.19.11.05.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jul 2023 11:05:37 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH] c++: passing partially inst tmpl as ttp [PR110566] Date: Wed, 19 Jul 2023 14:05:36 -0400 Message-ID: <20230719180536.2447863-1-ppalka@redhat.com> X-Mailer: git-send-email 2.41.0.376.gcba07a324d MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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: Patrick Palka via Gcc-patches From: Patrick Palka Reply-To: Patrick Palka Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk/13? -- >8 -- Since the arguments 'pargs' passed to the coerce_template_parms from coerce_template_template_parms are always a full set, we need to make sure we always pass the parameters of the most general template because if the template is partially instantiated then the levels won't match up. In the testcase below during said call to coerce_template_parms the parameters are {X, Y} both level 1, but the arguments are {{int}, {N, M}}, which leads to a crash during auto deduction of X and Y. PR c++/110566 gcc/cp/ChangeLog: * pt.cc (coerce_template_template_parms): Simplify by using DECL_INNERMOST_TEMPLATE_PARMS and removing redundant asserts. Always pass the parameters of the most general template to coerce_template_parms. gcc/testsuite/ChangeLog: * g++.dg/template/ttp38.C: New test. --- gcc/cp/pt.cc | 12 +++++------- gcc/testsuite/g++.dg/template/ttp38.C | 12 ++++++++++++ 2 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/ttp38.C diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index d882e9dd117..8723868823e 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -8073,12 +8073,10 @@ coerce_template_template_parms (tree parm_tmpl, tree parm, arg; int variadic_p = 0; - tree parm_parms = INNERMOST_TEMPLATE_PARMS (DECL_TEMPLATE_PARMS (parm_tmpl)); - tree arg_parms_full = DECL_TEMPLATE_PARMS (arg_tmpl); - tree arg_parms = INNERMOST_TEMPLATE_PARMS (arg_parms_full); - - gcc_assert (TREE_CODE (parm_parms) == TREE_VEC); - gcc_assert (TREE_CODE (arg_parms) == TREE_VEC); + tree parm_parms = DECL_INNERMOST_TEMPLATE_PARMS (parm_tmpl); + tree arg_parms = DECL_INNERMOST_TEMPLATE_PARMS (arg_tmpl); + tree gen_arg_tmpl = most_general_template (arg_tmpl); + tree gen_arg_parms = DECL_INNERMOST_TEMPLATE_PARMS (gen_arg_tmpl); nparms = TREE_VEC_LENGTH (parm_parms); nargs = TREE_VEC_LENGTH (arg_parms); @@ -8134,7 +8132,7 @@ coerce_template_template_parms (tree parm_tmpl, scope_args = TI_ARGS (tinfo); pargs = add_to_template_args (scope_args, pargs); - pargs = coerce_template_parms (arg_parms, pargs, NULL_TREE, tf_none); + pargs = coerce_template_parms (gen_arg_parms, pargs, NULL_TREE, tf_none); if (pargs != error_mark_node) { tree targs = make_tree_vec (nargs); diff --git a/gcc/testsuite/g++.dg/template/ttp38.C b/gcc/testsuite/g++.dg/template/ttp38.C new file mode 100644 index 00000000000..7d25d291e81 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/ttp38.C @@ -0,0 +1,12 @@ +// PR c++/110566 +// { dg-do compile { target c++20 } } + +template class> +struct A; + +template +struct B { + template struct C; +}; + +using type = A::C>;