From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id B48343870877 for ; Thu, 27 May 2021 17:42:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B48343870877 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-443-kzPer9y9MaC3R-XDbrVq1Q-1; Thu, 27 May 2021 13:42:19 -0400 X-MC-Unique: kzPer9y9MaC3R-XDbrVq1Q-1 Received: by mail-qt1-f199.google.com with SMTP id g13-20020ac8580d0000b02901e117526d0fso613191qtg.5 for ; Thu, 27 May 2021 10:42:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=sStJE+p5lpxqAAJVbeOH2Y0Eg7+/G+hcTmkDm+VU3E0=; b=pMzeM/+OgPvLAX0Id5Vs0j4nw5g65VCJKT5yjQE/5nAJpM3DUKOTcgifWkeEFir2FU pRnr+YCIHBnNHeJlg1yCYNEeUBAEBJWFyZZarXrmpeH2YfdsWy8arQVZC/e4t+R/7o14 8hxVyZqng8R46ky6Z8Wf3WDFe79+IGtnOTOGMYWR089SWW4yS7ZPyy1W3JNBU+3E/RYa weAy/ujRi8BEipR6ot3FTD7G+z3U5Zpln58Px5TyQ7RXMdXb1fxBoU8fWq2SX/NO4nUO feLccxUPAx5NkNswlBbsUIKi2HCEzwQMXruQ/tHQz1upoonKN7MCvV2+FpfdpZjYB1Uk w7ZQ== X-Gm-Message-State: AOAM531YZUXfvO8lJnOojliX3duvuMTLGyNoHs7L+kcoCWxLm2wo7HFo qloGsU/yk+OjJb/NseakDFW23Hm1DpesjaOjn6zbk8GeBBBV20A/8NiVhobyp4QdxE8VgiK3vKQ +quSozVK2KItcW6lA1Q3uooP9vGSt1AYCfVEGgnSeh0lzCqcVjg9BHovlFAUGXKLynA== X-Received: by 2002:a37:30b:: with SMTP id 11mr4466186qkd.206.1622137339008; Thu, 27 May 2021 10:42:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPD5etL8lkOtDD9izCRhq8zASKD1Rz7zOPTtF1N9KcEobSQL/96RM8IsGNto3aitYjg2S6vQ== X-Received: by 2002:a37:30b:: with SMTP id 11mr4466154qkd.206.1622137338646; Thu, 27 May 2021 10:42:18 -0700 (PDT) Received: from barrymore.redhat.com ([130.44.159.43]) by smtp.gmail.com with ESMTPSA id m67sm1807209qkd.108.2021.05.27.10.42.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 10:42:17 -0700 (PDT) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: argument pack with expansion [PR86355] Date: Thu, 27 May 2021 13:42:15 -0400 Message-Id: <20210527174215.2671518-1-jason@redhat.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" X-Spam-Status: No, score=-13.4 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_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-List-Received-Date: Thu, 27 May 2021 17:42:23 -0000 This testcase revealed that we were using PACK_EXPANSION_EXTRA_ARGS a lot more than necessary; use_pack_expansion_extra_args_p meant to use it in the case of corresponding arguments in different argument packs differing in whether they are pack expansions, but it was mistakenly also returning true for the case of a single argument pack containing both expansion and non-expansion elements. Surprisingly, just disabling that didn't lead to any regressions in the testsuite; it seems other changes have prevented us getting to this point for code that used to exercise it. So this patch limits the check to arguments in the same position in the packs, and asserts that we never actually see a mismatch. PR c++/86355 gcc/cp/ChangeLog: * pt.c (use_pack_expansion_extra_args_p): Don't compare args from the same argument pack. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/alias-decl-variadic2.C: New test. --- gcc/cp/pt.c | 7 +++++-- gcc/testsuite/g++.dg/cpp0x/alias-decl-variadic2.C | 13 +++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/alias-decl-variadic2.C diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index e4950aa448a..bb22d685617 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -12422,9 +12422,9 @@ use_pack_expansion_extra_args_p (tree parm_packs, return false; } - bool has_expansion_arg = false; for (int i = 0 ; i < arg_pack_len; ++i) { + bool has_expansion_arg = false; bool has_non_expansion_arg = false; for (tree parm_pack = parm_packs; parm_pack; @@ -12444,7 +12444,10 @@ use_pack_expansion_extra_args_p (tree parm_packs, } if (has_expansion_arg && has_non_expansion_arg) - return true; + { + gcc_checking_assert (false); + return true; + } } return false; } diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-variadic2.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-variadic2.C new file mode 100644 index 00000000000..4299c7e88dc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-variadic2.C @@ -0,0 +1,13 @@ +// PR c++/86355 +// { dg-do compile { target c++11 } } + +template struct integral_constant { + static const int value = 1; +}; +template using mp_all = integral_constant; +template using check2 = mp_all>>; +check2<> x; + +template struct assert_same; +template struct assert_same { }; +assert_same> a; base-commit: 9b94785dedb08b006419bec1a402614d9241317a -- 2.27.0