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 r13-123] c++: ICE during aggr CTAD for member tmpl [PR105476]
Date: Wed,  4 May 2022 21:09:11 +0000 (GMT)	[thread overview]
Message-ID: <20220504210911.8539E3858D1E@sourceware.org> (raw)

https://gcc.gnu.org/g:8a98e3ff7e80bf2936f163d50309fd88d72564a0

commit r13-123-g8a98e3ff7e80bf2936f163d50309fd88d72564a0
Author: Patrick Palka <ppalka@redhat.com>
Date:   Wed May 4 17:08:08 2022 -0400

    c++: ICE during aggr CTAD for member tmpl [PR105476]
    
    Here we're crashing from maybe_aggr_guide ultimately because
    processing_template_decl isn't set when partially instantiating the
    guide's parameter list; this causes us to force completion of the
    dependent type Visitor_functior<Fn>, which of course fails and results
    in an unexpected error_mark_node (the instantation should always succeed).
    
            PR c++/105476
    
    gcc/cp/ChangeLog:
    
            * pt.cc (maybe_aggr_guide): Set processing_template_decl when
            partially instantiating the guide's parameter list.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp2a/class-deduction-aggr13.C: New test.
            * g++.dg/cpp2a/class-deduction-aggr13a.C: New test.

Diff:
---
 gcc/cp/pt.cc                                         |  6 +++++-
 gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr13.C  | 11 +++++++++++
 gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr13a.C | 18 ++++++++++++++++++
 3 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index ac002907a41..2bec47dc295 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -29569,7 +29569,11 @@ maybe_aggr_guide (tree tmpl, tree init, vec<tree,va_gc> *args)
 	 PARMS, so that its template level is properly reduced and we don't get
 	 mismatches when deducing types using the guide with PARMS.  */
       if (member_template_p)
-	parms = tsubst (parms, DECL_TI_ARGS (tmpl), complain, init);
+	{
+	  ++processing_template_decl;
+	  parms = tsubst (parms, DECL_TI_ARGS (tmpl), complain, init);
+	  --processing_template_decl;
+	}
     }
   else if (TREE_CODE (init) == TREE_LIST)
     {
diff --git a/gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr13.C b/gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr13.C
new file mode 100644
index 00000000000..d3b21c722c8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr13.C
@@ -0,0 +1,11 @@
+// PR c++/105476
+// { dg-do compile { target c++17 } }
+
+template<class> struct Visitor_functor;
+
+template<class> struct Events {
+  template<class... Fn> struct Visitor : Visitor_functor<Fn>::type_t... { };
+};
+
+using ev_t = Events<int>;
+ev_t::Visitor v = { {} }; // { dg-error "too many initializers" }
diff --git a/gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr13a.C b/gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr13a.C
new file mode 100644
index 00000000000..69ae5dd4b60
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr13a.C
@@ -0,0 +1,18 @@
+// PR c++/105476
+// { dg-do compile { target c++20 } }
+// A valid version of class-deduction-aggr13.C.
+
+template<class> struct Visitor_functor;
+
+template<> struct Visitor_functor<int> {
+  using type_t = int;
+};
+
+template<class T> struct Events {
+  template<class Fn=T> struct Visitor {
+    Visitor_functor<Fn>::type_t t;
+  };
+};
+
+using ev_t = Events<int>;
+ev_t::Visitor v = { {} };


                 reply	other threads:[~2022-05-04 21:09 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=20220504210911.8539E3858D1E@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).