From patchwork Mon Nov 8 14:45:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 47213 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 583923857C65 for ; Mon, 8 Nov 2021 14:46:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 583923857C65 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1636382785; bh=2uSH4CWhlkw/c3jCleo/xdk161PgM3vFlh3nck31VU8=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=CfFYshf1CX3aW/l/Llvbn+0g7s6iZK45euYGsHDjl1gm8HFJSZo3QoR5UuDx/chFj QMyk3W5AFKg8KbH84rldUtNO/7Y70nc3I/1su0+LbUnM0ztUz+GBuv1lfCiCSunWSv g2IxByiXrm3KJ2jGO7Kd/xeYUZdJ6QakdeJPghZ4= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id 718D23858C2C for ; Mon, 8 Nov 2021 14:45:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 718D23858C2C Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-518-D-CtNRJnOSut6c4G70-ZwQ-1; Mon, 08 Nov 2021 09:45:55 -0500 X-MC-Unique: D-CtNRJnOSut6c4G70-ZwQ-1 Received: by mail-qv1-f69.google.com with SMTP id kl17-20020a056214519100b003ba5b03606fso16070908qvb.0 for ; Mon, 08 Nov 2021 06:45:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2uSH4CWhlkw/c3jCleo/xdk161PgM3vFlh3nck31VU8=; b=wIcaTl5jAeURu7vUt2QWuGxm3cLWBfi5rh+FANbymhSS4Kf+O9o0qr14QDa8y4m+np puTlnJuRzyBSBRnpVHaInRhuaNTxKOpD5ql/SbLRAZD3BFN8UyPt0JqxsvE5MSouOMKs Bkua+oyTczIF88Dx5fWeTbNbxSBjfoWR9c9tcOTM7Z1w59XTrEwegBBJtfom4rF0B2xB 6GYCtQe+QCC8u+l9jenlCWl2oKMFdqeQAkYJCZLbNpqOJVK9EtmIGlkTz/A/8F8jW7Ux QqSQwiAnVqlrfkFqm8zHM63aHRs7ylrjJ1HnG24uYMoYSjahxCHLF+kU+8677jldDv9/ 5OEg== X-Gm-Message-State: AOAM5304VLFsiOUPXcdvziqAsrFoZaPjWld9ijX+/jI6xWy05VWG/eOV HtgjoGqb0R/kF3+yRpvNZrf3IQHV3uDsz7GzSNTfKIXjECB9hgmjoDbEbSVZD9H21ILSbO+U7x2 98UOArz3FSCeFbD5ZBxikhwUOhnEJzSrCaiYSgaJ9vHjFNvuTHW0kH/Fsh58FHU4o2ew= X-Received: by 2002:a05:622a:1a93:: with SMTP id s19mr310522qtc.414.1636382754417; Mon, 08 Nov 2021 06:45:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJw+2uRv24ifUkYsPQq+0fzY6F5oatA1QRXutw0hyDaBm2sn9ICE01VTz8z9lcv7W6lweyjKYw== X-Received: by 2002:a05:622a:1a93:: with SMTP id s19mr310488qtc.414.1636382754156; Mon, 08 Nov 2021 06:45:54 -0800 (PST) Received: from localhost.localdomain (ool-457d493a.dyn.optonline.net. [69.125.73.58]) by smtp.gmail.com with ESMTPSA id j19sm4166222qkp.28.2021.11.08.06.45.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Nov 2021 06:45:53 -0800 (PST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: unexpanded pack in var tmpl partial spec [PR100652] Date: Mon, 8 Nov 2021 09:45:52 -0500 Message-Id: <20211108144552.3257237-1-ppalka@redhat.com> X-Mailer: git-send-email 2.34.0.rc1.14.g88d915a634 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-16.0 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_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Here we're not spotting a bare parameter pack appearing in the argument list of a variable template partial specialization because we only look for them within the decl's TREE_TYPE, which is sufficient for class templates but not for variable templates. Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk? PR c++/100652 gcc/cp/ChangeLog: * pt.c (push_template_decl): Check for bare parameter packs in the argument list of a variable template partial specialization. gcc/testsuite/ChangeLog: * g++.dg/cpp1y/var-templ69.C: New test. --- gcc/cp/pt.c | 17 ++++++++++++----- gcc/testsuite/g++.dg/cpp1y/var-templ69.C | 5 +++++ 2 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp1y/var-templ69.C diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index b82b9cc3cd2..991a20a85d4 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -5877,12 +5877,19 @@ push_template_decl (tree decl, bool is_friend) if (check_for_bare_parameter_packs (TYPE_RAISES_EXCEPTIONS (type))) TYPE_RAISES_EXCEPTIONS (type) = NULL_TREE; } - else if (check_for_bare_parameter_packs (is_typedef_decl (decl) - ? DECL_ORIGINAL_TYPE (decl) - : TREE_TYPE (decl))) + else { - TREE_TYPE (decl) = error_mark_node; - return error_mark_node; + if (check_for_bare_parameter_packs (is_typedef_decl (decl) + ? DECL_ORIGINAL_TYPE (decl) + : TREE_TYPE (decl))) + { + TREE_TYPE (decl) = error_mark_node; + return error_mark_node; + } + + if (is_partial && VAR_P (decl) + && check_for_bare_parameter_packs (DECL_TI_ARGS (decl))) + return error_mark_node; } if (is_partial) diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ69.C b/gcc/testsuite/g++.dg/cpp1y/var-templ69.C new file mode 100644 index 00000000000..420d617368c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/var-templ69.C @@ -0,0 +1,5 @@ +// PR c++/100652 +// { dg-do compile { target c++14 } } + +template int var; +template char var; // { dg-error "parameter packs not expanded" }