From patchwork Wed Feb 5 23:38:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1234056 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-518999-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=N8Shwbdt; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=D/Fcwkua; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48CdKt5sd9z9sPK for ; Thu, 6 Feb 2020 10:38:24 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:content-type :content-transfer-encoding; q=dns; s=default; b=Be15a2yNxE88yJp/ aA5xPws1vaC1F42OLBfxyxD89TwYDiTyqulTbI/eFacpN8q+ShDdiUZrhgCZEJZx KoaNsvHazU6ufNtqjqC4IjUGAuSHMV75VbptlpfLhXhT3Qx3fyRApnxsXpwj2Irn etzAnFmN8Tkq23JmVIFOwf6ygno= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:content-type :content-transfer-encoding; s=default; bh=Ojkrv6x1bFc3MRQu3BcPlE L1MXw=; b=N8ShwbdtcU552xU/9FjB+oeA+X3yPATT/y2eUfoCAGOb7cwdhJxnXz paiTcc2zXukb0sa6uxYPFtVAKXuLTzm4FPPMJyKGCytzMjYAiyBhSAuDHBzbsEmw CAcZX5QWJd7pQEcE5M5z+zUVSZUbnc1w3wJg0QpQiLWHMOvYnb8sk= Received: (qmail 2796 invoked by alias); 5 Feb 2020 23:38:16 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 2786 invoked by uid 89); 5 Feb 2020 23:38:16 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=boring X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (205.139.110.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 05 Feb 2020 23:38:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580945893; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pqRYMCX07IPzT/jOcPjVxqvcR66ePPlG0wcVVWaky1U=; b=D/FcwkuafB2GaSS2xU+ODlV7tnzKMEIGqAsA1XoRkSrCjHbWZX98qcSystDHlEM2uZyq53 0rE+iaZ7yAeyKe9/8yfJLPBTD7SeY0zPQm/S0IR9cELF/eHrTvT5OQs1y7k9I6s7RnlaSq fLzSBUC8Q2fCAHp3ifDNpC4wgkyyl1s= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-146-zcVOfGo7M6m-VyR16S4adA-1; Wed, 05 Feb 2020 18:38:10 -0500 Received: by mail-qv1-f71.google.com with SMTP id b8so2575795qvw.3 for ; Wed, 05 Feb 2020 15:38:10 -0800 (PST) Received: from barrymore.redhat.com (209-6-216-142.s141.c3-0.smr-cbr1.sbo-smr.ma.cable.rcncustomer.com. [209.6.216.142]) by smtp.gmail.com with ESMTPSA id h4sm712495qtp.24.2020.02.05.15.38.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Feb 2020 15:38:08 -0800 (PST) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [COMMITTED] c++: Fix decltype of empty pack expansion of parm. Date: Wed, 5 Feb 2020 18:38:06 -0500 Message-Id: <20200205233806.12139-1-jason@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-IsSubscribed: yes In unevaluated context, we only substitute a single PARM_DECL, not the entire chain, but the handling of an empty pack expansion was missing that check. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/93140 * pt.c (tsubst_decl) [PARM_DECL]: Check cp_unevaluated_operand in handling of TREE_CHAIN for empty pack. --- gcc/cp/pt.c | 2 +- gcc/testsuite/g++.dg/cpp0x/variadic-parm1.C | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-parm1.C base-commit: 5a8ad97b6e4823d4ded00a3ce8d80e4bf93368d4 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 40ff3c3a089..01bade85cdf 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -14076,7 +14076,7 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) /* Zero-length parameter packs are boring. Just substitute into the chain. */ - if (len == 0) + if (len == 0 && !cp_unevaluated_operand) RETURN (tsubst (TREE_CHAIN (t), args, complain, TREE_CHAIN (t))); } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-parm1.C b/gcc/testsuite/g++.dg/cpp0x/variadic-parm1.C new file mode 100644 index 00000000000..4300c781400 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-parm1.C @@ -0,0 +1,17 @@ +// PR c++/93140 +// { dg-do compile { target c++11 } } + +int +bar () +{ + return 42; +} + +template +void foo (R... r, decltype (bar (r...)) x = 0) {} + +int +main () +{ + foo (3); +}