aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2022-05-04 17:08:08 -0400
committerPatrick Palka <ppalka@redhat.com>2022-05-04 17:08:08 -0400
commit8a98e3ff7e80bf2936f163d50309fd88d72564a0 (patch)
treeef4eb4a80f638857f2e3e3e62fe8a3eeabc6d1a5
parent1cd3faf5dddb3cbfa2ed308ecf3db4f70bff337e (diff)
downloadgcc-8a98e3ff7e80bf2936f163d50309fd88d72564a0.zip
gcc-8a98e3ff7e80bf2936f163d50309fd88d72564a0.tar.gz
gcc-8a98e3ff7e80bf2936f163d50309fd88d72564a0.tar.bz2
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.
-rw-r--r--gcc/cp/pt.cc6
-rw-r--r--gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr13.C11
-rw-r--r--gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr13a.C18
3 files changed, 34 insertions, 1 deletions
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index ac00290..2bec47d 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 0000000..d3b21c7
--- /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 0000000..69ae5dd
--- /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 = { {} };