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]

PATCH for Re: Template bug



Here's a patch for your problem.  Jason, OK?

-- 
Mark Mitchell 			mark@markmitchell.com
Mark Mitchell Consulting	http://www.markmitchell.com

1998-05-25  Mark Mitchell  <mark@markmitchell.com>

	* decl.c (pushtag): Avoid crashing on erroneous input.

Index: crash7.C
===================================================================
RCS file: crash7.C
diff -N crash7.C
*** /dev/null	Mon Dec 31 20:00:00 1979
--- crash7.C	Mon May 25 12:08:06 1998
***************
*** 0 ****
--- 1,10 ----
+ // Build don't link:
+ 
+ class foo 
+ {
+ };
+ 
+ template <class T : public foo> // ERROR - base clause
+ struct bar
+ {
+ };
Index: decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.119
diff -c -p -r1.119 decl.c
*** decl.c	1998/05/25 10:28:08	1.119
--- decl.c	1998/05/25 19:09:25
*************** pushtag (name, type, globalize)
*** 2272,2278 ****
  	  TYPE_NAME (type) = d;
  	  DECL_CONTEXT (d) = context;
  
! 	  if (IS_AGGR_TYPE (type)
  	      && (/* If !GLOBALIZE then we are looking at a
  		     definition.  It may not be a primary template.
  		     (For example, in:
--- 2272,2287 ----
  	  TYPE_NAME (type) = d;
  	  DECL_CONTEXT (d) = context;
  
! 	  if (processing_template_parmlist)
! 	    /* You can't declare a new template type in a template
! 	       parameter list.  But, you can declare a non-template
! 	       type:
! 
! 	         template <class A*> struct S;
! 
! 	       is a forward-declaration of `A'.  */
! 	    ;
! 	  else if (IS_AGGR_TYPE (type)
  	      && (/* If !GLOBALIZE then we are looking at a
  		     definition.  It may not be a primary template.
  		     (For example, in:
*************** pushtag (name, type, globalize)
*** 2290,2305 ****
  		         template <class U>
  		         friend class S2; 
  		       };
- 
- 		     declares S2 to be at global scope.  We must be
- 		     careful, however, of the following case:
- 
- 		       template <class A*> struct S;
  
! 		     which declares a non-template class `A'.  */
! 		  || (!processing_template_parmlist
! 		      && (processing_template_decl > 
! 			  template_class_depth (current_class_type)))))
  	    {
  	      d = push_template_decl_real (d, globalize);
  	      /* If the current binding level is the binding level for
--- 2299,2308 ----
  		         template <class U>
  		         friend class S2; 
  		       };
  
! 		     declares S2 to be at global scope.  */
! 		  || (processing_template_decl > 
! 		      template_class_depth (current_class_type))))
  	    {
  	      d = push_template_decl_real (d, globalize);
  	      /* If the current binding level is the binding level for


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