From patchwork Thu Dec 15 16:15:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 33699 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp454829wrn; Thu, 15 Dec 2022 08:16:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf646B07ckpXU4eG/A0ODHecJ622enuIkOcuo9fRgh3ACPjhtSIfM/6VZIvEBGpo/YvVwqLo X-Received: by 2002:a17:907:6e0f:b0:7c4:f343:77a8 with SMTP id sd15-20020a1709076e0f00b007c4f34377a8mr7224590ejc.9.1671120991214; Thu, 15 Dec 2022 08:16:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671120991; cv=none; d=google.com; s=arc-20160816; b=KVIYVcTiBgTWNrkibcckucMBSLZe44Wj1PhnLHre4SoMfUkyy5Jl2/KNwXifTaQAKk P6hLXZtd2FUd6Ow39W50ORNeB9s4D2W09TGXFk5arfyJ8/p2vC65Kt6vHSrDcROFhD/Z PLkKuuuYYYEy2a6gwLFPvAxdDvSFYW7kswsIBjfSuZ9mtyM83srSTx2fNWRMo1inTZhh VC38M5VLYRX/Bd2iqLoeL9W7LxE6ZYQXrDLGuTJcWNx1kRxM+uLr9NzMg3Us4xbQybhd xEpyLfoH7H49Fa6yVuZxgZHpQQLvj+eAw7uYDt0H4DBLL4HbhsNRoGmEstwyqT17rrM1 WZxg== 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:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=IYSQQlh059Oq+Z1sGwNxOJzM/Fsta+DeEpDa1SkEMlg=; b=BItweX3g6bA16CJ6HTi9g9X1LNxOGHj4hRtwo+BUsLGUTgcr1ctdi4bU6G4o6+yXub 2Dq2FdtlTDOto7ZT8Xd4pl2VljSkFmVx+kL7aJZ/4wEm5sxKSrTEjqD71jk80scQBtwr y8XjHo3RDc2puZPnIoD2KI4i7/aX2HHV1MQjJgeYP0/hRFvxVCuuB8Wnrs4tblLt/cfN nAiy7LSd6Eb/xse3QgSmrSf21Qxbicuo37WBXrCRfxuSSDs4kSf51HriGFDgyFrcKQ0i opeMLWbUersB3SdiSMOM6QPusZaf5oFsykYg+EEjLhVZwVczMWuuPV6APKxnWkRnRAV7 LRkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=uqfqpk3G; 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 n8-20020a05640205c800b0046cf9020abfsi17381297edx.607.2022.12.15.08.16.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 08:16:31 -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=uqfqpk3G; 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 E1E8E38187EB for ; Thu, 15 Dec 2022 16:16:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E1E8E38187EB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671120989; bh=IYSQQlh059Oq+Z1sGwNxOJzM/Fsta+DeEpDa1SkEMlg=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=uqfqpk3G8dMDyddrf/5iy1s9ZDYDEwr0EMqGEbTnb5BypFy6efguwfq5eZ4AqtXER ldsmtXni1aGafJvqFhE5gFv8f4C3IySPVWnzatwiTCN1GAUn2+zlJtE2z3SZQ0vLbv kSsE6Uf54rZGET4nGOoMzngfqVE/D8WKxGu1/LsA= 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 0F77A38187EB for ; Thu, 15 Dec 2022 16:15:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0F77A38187EB Received: from mail-yb1-f199.google.com (mail-yb1-f199.google.com [209.85.219.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-119-4xK_KSxYNt2pmSQoM12jzw-1; Thu, 15 Dec 2022 11:15:39 -0500 X-MC-Unique: 4xK_KSxYNt2pmSQoM12jzw-1 Received: by mail-yb1-f199.google.com with SMTP id h67-20020a25d046000000b00729876d3b2bso4328839ybg.17 for ; Thu, 15 Dec 2022 08:15:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=IYSQQlh059Oq+Z1sGwNxOJzM/Fsta+DeEpDa1SkEMlg=; b=52btO/5SiJIFqPl55LHsHzQJh9mMYjMQsRZrwzl3+gxYqDhCb0ohgCLUEmgLs3xk83 UZnSo8r8gwquqAUr7lzpKFGSlNN0G138jBiQuB9kNwmzl1Maavc/yMCOa4zKVCOfENSb Bsl28TExPsw56mCybuuj/5E5IaAXyyAkRNgEznfgkUuBbi9SGuioWOkAG/o6ursYFd4E 7EW3XlVL9/8p0O5MM/mCrtYDqocBnF31bol6QhJP2Dr+Ka3Gzx7wIyDC1JoR0vOwkF2O kCPpytKc6masFJZfRMHu4JNoTVCeL00XEpJOj/gpxT4wB0C0GSpkNqFLyscu8gSFe2Wz Xn8Q== X-Gm-Message-State: ANoB5pkAIPYEJNohvD+CaNNhuLawzxHvI4uqfvLIQ8FqX3XXZ0rOp+w4 P2ektjVcTcxMsdAiWRrMgwW9QzOkc0kC4iJAF83oJl3g3nzqHZFdYjHKgGZ9KSxk51zfKRBSIQL XjeJWkLG+7z0J4uxOOri8P8sL7qRRKAWszvPRJQ7N95BoYKEZGdCT4TejD7eUriImlkc= X-Received: by 2002:a05:7500:7597:b0:ea:75ee:dd79 with SMTP id jt23-20020a057500759700b000ea75eedd79mr2848796gab.2.1671120938111; Thu, 15 Dec 2022 08:15:38 -0800 (PST) X-Received: by 2002:a05:7500:7597:b0:ea:75ee:dd79 with SMTP id jt23-20020a057500759700b000ea75eedd79mr2848772gab.2.1671120937554; Thu, 15 Dec 2022 08:15:37 -0800 (PST) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id m16-20020a05620a291000b006feb0007217sm12552276qkp.65.2022.12.15.08.15.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 08:15:37 -0800 (PST) To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH] c++: variadic using-decl with parm pack in terminal name [PR102104] Date: Thu, 15 Dec 2022 11:15:35 -0500 Message-Id: <20221215161535.2731182-1-ppalka@redhat.com> X-Mailer: git-send-email 2.39.0.56.g57e2c6ebbe 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_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: Patrick Palka via Gcc-patches From: Patrick Palka Reply-To: Patrick Palka 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?1752297364371324857?= X-GMAIL-MSGID: =?utf-8?q?1752297364371324857?= There's a curious corner case with variadic member using-decls: the terminal name can also contain a parameter pack, and only through naming a conversion function, e.g. using A::operator Ts...; We currently only handle parameter packs appearing in the qualifying scope of a variadic using-decl; this patch adds support for the above case as well, representing such a using-decl with two pack expansions, one for the qualifying scope and one for the terminal name (despite logically there being just one). Then at instantiation time we manually merge them. Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk? PR c++/102104 PR c++/108090 gcc/cp/ChangeLog: * error.cc (dump_decl) : Look through a pack expansion in the name as well. * parser.c (cp_parser_using_declaration): Handle a parameter pack appearing in the terminal name of a variadic using-decl. * pt.c (tsubst_decl) : Likewise. Combine the handling of variadic and non-variadic using-decls. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/using-variadic1.C: New test. * g++.dg/cpp1z/using-variadic1a.C: New test. * g++.dg/cpp1z/using-variadic1b.C: New test. * g++.dg/cpp1z/using-variadic1c.C: New test. * g++.dg/cpp1z/using-variadic2.C: New test. * g++.dg/cpp1z/using-variadic3.C: New test. --- gcc/cp/error.cc | 9 ++ gcc/cp/parser.cc | 33 ++++++- gcc/cp/pt.cc | 91 ++++++++++++++----- gcc/testsuite/g++.dg/cpp1z/using-variadic1.C | 29 ++++++ gcc/testsuite/g++.dg/cpp1z/using-variadic1a.C | 34 +++++++ gcc/testsuite/g++.dg/cpp1z/using-variadic1b.C | 37 ++++++++ gcc/testsuite/g++.dg/cpp1z/using-variadic1c.C | 33 +++++++ gcc/testsuite/g++.dg/cpp1z/using-variadic2.C | 24 +++++ gcc/testsuite/g++.dg/cpp1z/using-variadic3.C | 8 ++ 9 files changed, 272 insertions(+), 26 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp1z/using-variadic1.C create mode 100644 gcc/testsuite/g++.dg/cpp1z/using-variadic1a.C create mode 100644 gcc/testsuite/g++.dg/cpp1z/using-variadic1b.C create mode 100644 gcc/testsuite/g++.dg/cpp1z/using-variadic1c.C create mode 100644 gcc/testsuite/g++.dg/cpp1z/using-variadic2.C create mode 100644 gcc/testsuite/g++.dg/cpp1z/using-variadic3.C diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc index 12b28e8ee5b..e7f60335cc0 100644 --- a/gcc/cp/error.cc +++ b/gcc/cp/error.cc @@ -1477,11 +1477,20 @@ dump_decl (cxx_pretty_printer *pp, tree t, int flags) if (!(flags & TFF_UNQUALIFIED_NAME)) { tree scope = USING_DECL_SCOPE (t); + tree name = DECL_NAME (t); if (PACK_EXPANSION_P (scope)) { scope = PACK_EXPANSION_PATTERN (scope); variadic = true; } + if (identifier_p (name) + && IDENTIFIER_CONV_OP_P (name) + && PACK_EXPANSION_P (TREE_TYPE (name))) + { + name = make_conv_op_name (PACK_EXPANSION_PATTERN + (TREE_TYPE (name))); + variadic = true; + } dump_type (pp, scope, flags); pp_cxx_colon_colon (pp); } diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 03550308365..2e2d81c1316 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -21705,7 +21705,38 @@ cp_parser_using_declaration (cp_parser* parser, pedwarn (ell->location, OPT_Wc__17_extensions, "pack expansion in using-declaration only available " "with %<-std=c++17%> or %<-std=gnu++17%>"); - qscope = make_pack_expansion (qscope); + + /* A parameter pack can appear in the qualifying scope, and/or in the + terminal name (if naming a conversion function). Logically they're + part of a single pack expansion of the overall USING_DECL, but we + express them as separate pack expansions within the USING_DECL since + we can't create a pack expansion over a USING_DECL. */ + bool saw_parm_pack = false; + if (uses_parameter_packs (qscope)) + { + qscope = make_pack_expansion (qscope); + saw_parm_pack = true; + } + /* It can also appear in the terminal name (if naming a conversion + function). */ + if (identifier_p (identifier) + && IDENTIFIER_CONV_OP_P (identifier) + && uses_parameter_packs (TREE_TYPE (identifier))) + { + identifier = make_conv_op_name (make_pack_expansion + (TREE_TYPE (identifier))); + saw_parm_pack = true; + } + if (!saw_parm_pack) + { + /* Issue an error in terms using a SCOPE_REF that includes both + components. */ + tree name + = build_qualified_name (NULL_TREE, qscope, identifier, false); + make_pack_expansion (name); + gcc_assert (seen_error ()); + qscope = identifier = error_mark_node; + } } /* The function we call to handle a using-declaration is different diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 44058d30799..2fb7d6832ea 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -14963,43 +14963,84 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) if (DECL_DEPENDENT_P (t) || uses_template_parms (USING_DECL_SCOPE (t))) { + /* True iff this using-decl was written as a pack expansion + (and a pack appeared in its scope or name). If a pack + appeared in both, we expand the packs separately and + manually merge them. */ + bool variadic_p = false; + tree scope = USING_DECL_SCOPE (t); - tree name = tsubst_copy (DECL_NAME (t), args, complain, in_decl); if (PACK_EXPANSION_P (scope)) { - tree vec = tsubst_pack_expansion (scope, args, complain, in_decl); - int len = TREE_VEC_LENGTH (vec); - r = make_tree_vec (len); - for (int i = 0; i < len; ++i) + scope = tsubst_pack_expansion (scope, args, complain, in_decl); + variadic_p = true; + } + else + scope = tsubst_copy (scope, args, complain, in_decl); + + tree name = DECL_NAME (t); + if (IDENTIFIER_CONV_OP_P (name) + && PACK_EXPANSION_P (TREE_TYPE (name))) + { + name = tsubst_pack_expansion (TREE_TYPE (name), args, + complain, in_decl); + if (name == error_mark_node) { - tree escope = TREE_VEC_ELT (vec, i); - tree elt = do_class_using_decl (escope, name); - if (!elt) - { - r = error_mark_node; - break; - } - else - { - TREE_PROTECTED (elt) = TREE_PROTECTED (t); - TREE_PRIVATE (elt) = TREE_PRIVATE (t); - } - TREE_VEC_ELT (r, i) = elt; + r = error_mark_node; + break; } + for (int i = 0; i < TREE_VEC_LENGTH (name); i++) + TREE_VEC_ELT (name, i) + = make_conv_op_name (TREE_VEC_ELT (name, i)); + variadic_p = true; } else + name = tsubst_copy (name, args, complain, in_decl); + + int len; + if (!variadic_p) + len = 1; + else if (TREE_CODE (scope) == TREE_VEC + && TREE_CODE (name) == TREE_VEC) { - tree inst_scope = tsubst_copy (USING_DECL_SCOPE (t), args, - complain, in_decl); - r = do_class_using_decl (inst_scope, name); - if (!r) - r = error_mark_node; + if (TREE_VEC_LENGTH (scope) != TREE_VEC_LENGTH (name)) + { + error ("mismatched argument pack lengths"); + r = error_mark_node; + break; + } + len = TREE_VEC_LENGTH (scope); + } + else if (TREE_CODE (scope) == TREE_VEC) + len = TREE_VEC_LENGTH (scope); + else /* TREE_CODE (name) == TREE_VEC */ + len = TREE_VEC_LENGTH (name); + + r = make_tree_vec (len); + for (int i = 0; i < len; ++i) + { + tree escope = (TREE_CODE (scope) == TREE_VEC + ? TREE_VEC_ELT (scope, i) + : scope); + tree ename = (TREE_CODE (name) == TREE_VEC + ? TREE_VEC_ELT (name, i) + : name); + tree elt = do_class_using_decl (escope, ename); + if (!elt) + { + r = error_mark_node; + break; + } else { - TREE_PROTECTED (r) = TREE_PROTECTED (t); - TREE_PRIVATE (r) = TREE_PRIVATE (t); + TREE_PROTECTED (elt) = TREE_PROTECTED (t); + TREE_PRIVATE (elt) = TREE_PRIVATE (t); } + TREE_VEC_ELT (r, i) = elt; } + + if (!variadic_p && r != error_mark_node) + r = TREE_VEC_ELT (r, 0); } else { diff --git a/gcc/testsuite/g++.dg/cpp1z/using-variadic1.C b/gcc/testsuite/g++.dg/cpp1z/using-variadic1.C new file mode 100644 index 00000000000..7a8bcbbe372 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/using-variadic1.C @@ -0,0 +1,29 @@ +// PR c++/102104 +// { dg-do compile { target c++17 } } + +struct A { + using target_type = bool*; + operator bool*(); +}; + +struct B { + using target_type = long*; + operator long*(); +}; + +template +struct cls : private Bases... { + using Bases::operator typename Bases::target_type...; +}; + +cls v1; +bool* a1 = v1; +long* b1 = v1; + +cls v2; +bool* a2 = v2; // { dg-error "cannot convert" } +long* b2 = v2; + +cls v3; +bool* a3 = v3; +long* b3 = v3; // { dg-error "cannot convert" } diff --git a/gcc/testsuite/g++.dg/cpp1z/using-variadic1a.C b/gcc/testsuite/g++.dg/cpp1z/using-variadic1a.C new file mode 100644 index 00000000000..0393cab6ace --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/using-variadic1a.C @@ -0,0 +1,34 @@ +// PR c++/102104 +// A version of using-variadic1.C where the qualifying scope and the +// terminal name of the using-declaration use different parameter packs. +// { dg-do compile { target c++17 } } + +struct A { + using target_type = bool*; + operator bool*(); +}; + +struct B { + using target_type = long*; + operator long*(); +}; + +template +struct cls { + template + struct nested : private Bases... { + using Bases::operator typename Ts::target_type...; + }; +}; + +cls::nested v1; +bool* a1 = v1; +long* b1 = v1; + +cls::nested v2; +bool* a2 = v2; // { dg-error "cannot convert" } +long* b2 = v2; + +cls::nested v3; +bool* a3 = v3; +long* b3 = v3; // { dg-error "cannot convert" } diff --git a/gcc/testsuite/g++.dg/cpp1z/using-variadic1b.C b/gcc/testsuite/g++.dg/cpp1z/using-variadic1b.C new file mode 100644 index 00000000000..fd3a41718b6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/using-variadic1b.C @@ -0,0 +1,37 @@ +// PR c++/102104 +// A version of using-variadic1.C where only the qualifying scope +// uses a parameter pack. +// { dg-do compile { target c++17 } } + +struct A { + using target_type = bool*; +}; + +struct B { + using target_type = long*; +}; + +struct C { + operator bool*(); + operator long*(); +}; + +template +struct cls { + template + struct nested : private Base { + using Base::operator typename Ts::target_type...; + }; +}; + +cls::nested v1; +bool* a1 = v1; +long* b1 = v1; + +cls::nested v2; +bool* a2 = v2; // { dg-error "inaccessible|not an accessible" } +long* b2 = v2; + +cls::nested v3; +bool* a3 = v3; +long* b3 = v3; // { dg-error "inaccessible|not an accessible" } diff --git a/gcc/testsuite/g++.dg/cpp1z/using-variadic1c.C b/gcc/testsuite/g++.dg/cpp1z/using-variadic1c.C new file mode 100644 index 00000000000..aa86b28fd2e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/using-variadic1c.C @@ -0,0 +1,33 @@ +// PR c++/102104 +// A version of of using-variadic1.C where only the terminal name +// uses a parameter pack. +// { dg-do compile { target c++17 } } + +struct A { + operator bool*(); +}; + +struct B { + operator bool*(); +}; + +struct C { + using target_type = bool*; +}; + +template +struct cls { + template + struct nested : private Bases... { + using Bases::operator typename T::target_type...; + }; +}; + +cls::nested v1; +bool* a1 = v1; // { dg-error "ambiguous" } + +cls::nested v2; +bool* a2 = v2; + +cls::nested v3; +bool* a3 = v3; diff --git a/gcc/testsuite/g++.dg/cpp1z/using-variadic2.C b/gcc/testsuite/g++.dg/cpp1z/using-variadic2.C new file mode 100644 index 00000000000..1d68ceece8a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/using-variadic2.C @@ -0,0 +1,24 @@ +// PR c++/102104 +// A version of using-variadic1a.C where the argument packs have +// different lengths. +// { dg-do compile { target c++17 } } + +struct A { + using target_type = bool*; + operator bool*(); +}; + +struct B { + using target_type = long*; + operator long*(); +}; + +template +struct cls { + template + struct nested : private Bases... { + using Bases::operator typename Ts::target_type...; // { dg-error "lengths" } + }; +}; + +cls::nested v1; // { dg-message "required from here" } diff --git a/gcc/testsuite/g++.dg/cpp1z/using-variadic3.C b/gcc/testsuite/g++.dg/cpp1z/using-variadic3.C new file mode 100644 index 00000000000..4e1d6894e56 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/using-variadic3.C @@ -0,0 +1,8 @@ +// PR c++/108090 +// { dg-do compile { target c++17 } } + +template struct As { operator T(); }; +template struct AsAll : As... { + using As::operator T...; +}; +AsAll x;