This is the mail archive of the gcc-bugs@gcc.gnu.org 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]

Re: explicit instantiation gives internal error



You wrote that this:

  class A {
  public:
    static void f();
  };

  template <class T>
  class B : public A {
    friend void A::f();
  };

  template <class T>
  class C : public B<T>
  {
  };

  template class C<char>;

caused an internal compiler error.  Fixed with this patch.

Thanks for the report!

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

2000-01-11  Mark Mitchell  <mark@codesourcery.com>

	* friend.c (do_friend): Don't resolve scopes when processing
	template declarations, even if the qualifying scope doesn't
	involve template parameters.

Index: testsuite/g++.old-deja/g++.pt/friend43.C
===================================================================
RCS file: friend43.C
diff -N friend43.C
*** /dev/null	Tue May  5 13:32:27 1998
--- friend43.C	Tue Jan 11 00:52:07 2000
***************
*** 0 ****
--- 1,19 ----
+ // Build don't link:
+ // Origin: Matt Austern <austern@isolde.engr.sgi.com>
+ 
+ class A {
+ public:
+   static void f();
+ };
+ 
+ template <class T>
+ class B : public A {
+   friend void A::f();
+ };
+ 
+ template <class T>
+ class C : public B<T>
+ {
+ };
+ 
+ template class C<char>;
Index: cp/friend.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/friend.c,v
retrieving revision 1.49
diff -c -p -r1.49 friend.c
*** friend.c	1999/10/07 16:41:47	1.49
--- friend.c	2000/01/11 08:52:12
***************
*** 1,5 ****
  /* Help friends in C++.
!    Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
  
  This file is part of GNU CC.
  
--- 1,5 ----
  /* Help friends in C++.
!    Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
  
  This file is part of GNU CC.
  
*************** do_friend (ctype, declarator, decl, parm
*** 402,408 ****
        /* We can't do lookup in a type that involves template
  	 parameters.  Instead, we rely on tsubst_friend_function
  	 to check the validity of the declaration later.  */
!       if (uses_template_parms (ctype))
  	add_friend (current_class_type, decl);
        /* A nested class may declare a member of an enclosing class
  	 to be a friend, so we do lookup here even if CTYPE is in
--- 402,408 ----
        /* We can't do lookup in a type that involves template
  	 parameters.  Instead, we rely on tsubst_friend_function
  	 to check the validity of the declaration later.  */
!       if (processing_template_decl)
  	add_friend (current_class_type, decl);
        /* A nested class may declare a member of an enclosing class
  	 to be a friend, so we do lookup here even if CTYPE is in

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