public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Patrick Palka <ppalka@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-5052] c++: unexpanded pack in var tmpl partial spec [PR100652]
Date: Tue,  9 Nov 2021 14:11:07 +0000 (GMT)	[thread overview]
Message-ID: <20211109141107.087443858C2C@sourceware.org> (raw)

https://gcc.gnu.org/g:a19f09cb03d7f69377e6d12162e5d6df78a82849

commit r12-5052-ga19f09cb03d7f69377e6d12162e5d6df78a82849
Author: Patrick Palka <ppalka@redhat.com>
Date:   Tue Nov 9 09:09:12 2021 -0500

    c++: unexpanded pack in var tmpl partial spec [PR100652]
    
    Here we're failing to spot 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.
    
            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.

Diff:
---
 gcc/cp/pt.c                              | 17 ++++++++++++-----
 gcc/testsuite/g++.dg/cpp1y/var-templ69.C |  5 +++++
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 2638d3ce3d4..b2916f8aa4b 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<class...> int var;
+template<class... Ts> char var<bool, Ts>; // { dg-error "parameter packs not expanded" }


                 reply	other threads:[~2021-11-09 14:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211109141107.087443858C2C@sourceware.org \
    --to=ppalka@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).