re PR c++/22147 (ICE in get_bindings)
authorMark Mitchell <mark@codesourcery.com>
Tue, 27 Sep 2005 23:31:57 +0000 (23:31 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Tue, 27 Sep 2005 23:31:57 +0000 (23:31 +0000)
PR c++/22147
* name-lookup.c (maybe_process_template_type_declaration): Don't
treat forward declarations of classes as templates just because
we're processing_template_decl.
* pt.c (tsubst_decl): Clear DECL_TEMPLATE_INFO for friend
functions.

PR c++/22147
* g++.dg/template/friend37.C: New test.
* g++.dg/parse/crash28.C: Adjust error markers.

From-SVN: r104713

gcc/cp/ChangeLog
gcc/cp/name-lookup.c
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/crash28.C
gcc/testsuite/g++.dg/template/friend37.C [new file with mode: 0644]

index bdc7237e4bf7499bc6c5323d2b548325bec24e9d..0c429cff6d0c0340c37ac772f442c04c03be83e0 100644 (file)
@@ -1,3 +1,12 @@
+2005-09-27  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/22147
+       * name-lookup.c (maybe_process_template_type_declaration): Don't
+       treat forward declarations of classes as templates just because
+       we're processing_template_decl.
+       * pt.c (tsubst_decl): Clear DECL_TEMPLATE_INFO for friend
+       functions. 
+
 2005-09-26  Jason Merrill  <jason@redhat.com>
 
        PR c++/13764
index f25a3342d70d3720f2bc1c0a2f98cd9a30b5b08e..29e5f2b2be6fbb566372189e7131fb5459783723 100644 (file)
@@ -4689,6 +4689,11 @@ maybe_process_template_type_declaration (tree type, int is_friend,
 
        is a forward-declaration of `A'.  */
     ;
+  else if (b->kind == sk_namespace
+          && current_binding_level->kind != sk_namespace)
+    /* If this new type is being injected into a containing scope,
+       then it's not a template type.  */
+    ;
   else
     {
       gcc_assert (IS_AGGR_TYPE (type) || TREE_CODE (type) == ENUMERAL_TYPE);
index be2f0312bdf9d7deab7f64f6b88cf3c57ce0427b..1217580f75f844fc6058515aaa323d3c46428688 100644 (file)
@@ -6510,6 +6510,8 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
                && !uses_template_parms (argvec))
              tsubst_default_arguments (r);
          }
+       else
+         DECL_TEMPLATE_INFO (r) = NULL_TREE;
 
        /* Copy the list of befriending classes.  */
        for (friends = &DECL_BEFRIENDING_CLASSES (r);
index e6375b5576bdd6c02a3b20743a6286deca13a321..74cb23fe2fb9322f6ee3b33cbf209318322b1b3d 100644 (file)
@@ -1,3 +1,9 @@
+2005-09-27  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/22147
+       * g++.dg/template/friend37.C: New test.
+       * g++.dg/parse/crash28.C: Adjust error markers.
+       
 2005-09-27  Jakub Jelinek  <jakub@redhat.com>
 
        PR fortran/18518
index 9c38f89ba425cf1cdd8a5f85f984e488dfca4469..bc491655768541770335ecb985a8d660a0da4ad0 100644 (file)
@@ -6,9 +6,9 @@
 //        Volker Reichelt <reichelt@gcc.gnu.org>
 
 template <class _Tp> class insert_iterator<slist<_Tp> > {}; // { dg-error "not a template|not declared in this scope|expected unqualified-id|extra" }
-template <class _Value> class insert_iterator<int > { // { dg-error "template parameters not used|_Value" }
+template <class _Value> class insert_iterator<int > { // { dg-error "template" }
   hash_set<_Value>; // { dg-error "no type|expected" }
 };
 
 template<int> struct A<X<> > {}; // { dg-error "not a template|not declared in this scope|expected unqualified-id|extra" }
-struct A {}; // { dg-error "template argument required" }
+struct A {};
diff --git a/gcc/testsuite/g++.dg/template/friend37.C b/gcc/testsuite/g++.dg/template/friend37.C
new file mode 100644 (file)
index 0000000..7c86829
--- /dev/null
@@ -0,0 +1,15 @@
+// PR c++/22147
+
+template<typename> struct A;
+
+template<typename T> void foo(A<T>* p) { *p; }
+
+template<typename> struct A
+{
+  friend void foo<class X>(A<X>*);
+};
+
+void bar()
+{
+  foo<int>(0);
+}