This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for c++/63309 (ICE with invalid definition of template member)
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 09 Oct 2014 14:06:43 -0400
- Subject: C++ PATCH for c++/63309 (ICE with invalid definition of template member)
- Authentication-results: sourceware.org; auth=none
push_template_decl handles checking that template parameter lists make
sense, but we were never calling it for a definition of a member class
of a class template. Fixed by calling it in cp_parser_class_head, where
previously we had only called it for redefinition of primary templates.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit 65f6fa41abaf6f9829b7aee62524c9d92f0c2ce3
Author: Jason Merrill <jason@redhat.com>
Date: Wed Oct 8 21:53:55 2014 -0400
PR c++/63309
* parser.c (cp_parser_class_head): push_template_decl for members
of templates, too.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index bc992b2..a9edcd5 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -20222,9 +20222,7 @@ cp_parser_class_head (cp_parser* parser,
template either from the template headers or the type we're
defining, so that we diagnose both extra and missing headers. */
if ((PROCESSING_REAL_TEMPLATE_DECL_P ()
- || (CLASSTYPE_TEMPLATE_INFO (TREE_TYPE (type))
- && PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE
- (TREE_TYPE (type)))))
+ || CLASSTYPE_TEMPLATE_INFO (TREE_TYPE (type)))
&& !CLASSTYPE_TEMPLATE_SPECIALIZATION (TREE_TYPE (type)))
{
type = push_template_decl (type);
diff --git a/gcc/testsuite/g++.dg/template/nested6.C b/gcc/testsuite/g++.dg/template/nested6.C
new file mode 100644
index 0000000..f5b8054
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/nested6.C
@@ -0,0 +1,19 @@
+// PR c++/63309
+
+template <class T>
+class A
+{
+public:
+ class B;
+};
+
+template <class T, class I>
+class A<T>::B // { dg-error "template parameters|required" }
+{
+};
+
+int main()
+{
+ A<int>::B myB; // { dg-prune-output "incomplete type" }
+ return 0;
+}