This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
PATCH for Re: Template bug
- To: theron at cs dot ucsb dot edu
- Subject: PATCH for Re: Template bug
- From: Mark Mitchell <mark at markmitchell dot com>
- Date: Mon, 25 May 1998 12:13:32 -0700
- CC: egcs-bugs at cygnus dot com
- References: <Pine.LNX.3.96.980514050949.1826A-200000@cthulhu>
- Reply-to: mark at markmitchell dot com
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