This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for c++/85242, ICE with class defn in template parm
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 6 Apr 2018 11:09:55 -0400
- Subject: C++ PATCH for c++/85242, ICE with class defn in template parm
Here, we were trying to start defining a template in the middle of the
template parameter list for another template. Adjusting the
PROCESSING_REAL_TEMPLATE_DECL_P macro to exclude this situation seems
appropriate.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit f7bcdc914de03d87a99bc7ebd85fefb031028ef0
Author: Jason Merrill <jason@redhat.com>
Date: Fri Apr 6 09:07:23 2018 -0400
PR c++/85242 - ICE with class definition in template parm.
* cp-tree.h (PROCESSING_REAL_TEMPLATE_DECL_P): False if
processing_template_parmlist.
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index dbe34c096f0..204791e51cf 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -4719,7 +4719,8 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
entity with its own template parameter list, and which is not a
full specialization. */
#define PROCESSING_REAL_TEMPLATE_DECL_P() \
- (processing_template_decl > template_class_depth (current_scope ()))
+ (!processing_template_parmlist \
+ && processing_template_decl > template_class_depth (current_scope ()))
/* Nonzero if this VAR_DECL or FUNCTION_DECL has already been
instantiated, i.e. its definition has been generated from the
diff --git a/gcc/testsuite/g++.dg/template/error58.C b/gcc/testsuite/g++.dg/template/error58.C
new file mode 100644
index 00000000000..cede1c94887
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/error58.C
@@ -0,0 +1,8 @@
+// PR c++/85242
+
+namespace N
+{
+ struct A {};
+}
+
+template<struct N::A {}> void foo(); // { dg-error "" }