This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for DR 1004 (use of injected type name as template)

While I was doing the standardese drafting for core language issue 1004, I noticed that when I implemented these semantics before I missed a case. Fixed thus.

Tested x86_64-pc-linux-gnu, applied to trunk.
commit 086ac7e09768d54b4fea6f936593d9e16f1f38ca
Author: Jason Merrill <>
Date:   Wed Nov 10 23:59:55 2010 -0600

    	DR 1004
    	* decl.c (make_unbound_class_template): Handle using
    	injected-type-name as template.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 714516e..55e0d6a 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -3227,6 +3227,9 @@ make_unbound_class_template (tree context, tree name, tree parm_list,
       if (MAYBE_CLASS_TYPE_P (context))
 	tmpl = lookup_field (context, name, 0, false);
+      if (tmpl && TREE_CODE (tmpl) == TYPE_DECL)
+	tmpl = maybe_get_template_decl_from_type_decl (tmpl);
       if (!tmpl || !DECL_CLASS_TEMPLATE_P (tmpl))
 	  if (complain & tf_error)
diff --git a/gcc/testsuite/g++.dg/template/injected2.C b/gcc/testsuite/g++.dg/template/injected2.C
new file mode 100644
index 0000000..bd09ccc
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/injected2.C
@@ -0,0 +1,9 @@
+// DR 1004
+template <class T, template<class>class U = T::template B> struct A { };
+template <class T> struct B {
+  template <class U> friend struct B;
+A<B<int> > a;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]