This is the mail archive of the gcc-patches@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]

[C++ PATCH] Fix bug 1585


Hi,
I've installed this obvious fix for bug 1585. We were erroneously
accepting `template <> class T' as a template template parm.

built & tested on i686-pc-linux-gnu.

nathan
-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2001-01-11  Nathan Sidwell  <nathan@codesourcery.com>

	* parse.y (template_parm_header, template_spec_header): New
	reductions. Split out from ...
	(template_header): ... here. Use them.
	(template_template_parm): Use template_parm_header.
	* semantics.c (finish_template_template_parm): Add assert.

Index: cp/parse.y
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/parse.y,v
retrieving revision 1.208
diff -c -3 -p -r1.208 parse.y
*** parse.y	2001/01/05 16:35:34	1.208
--- parse.y	2001/01/11 09:10:11
*************** cp_parse_init ()
*** 395,401 ****
  %type <ttype> maybe_parmlist
  %type <ttype> member_init
  %type <ftype> member_init_list
! %type <ttype> template_header template_parm_list template_parm
  %type <ttype> template_type_parm template_template_parm
  %type <code>  template_close_bracket
  %type <ttype> apparent_template_type
--- 395,402 ----
  %type <ttype> maybe_parmlist
  %type <ttype> member_init
  %type <ftype> member_init_list
! %type <ttype> template_parm_header template_spec_header template_header
! %type <ttype> template_parm_list template_parm
  %type <ttype> template_type_parm template_template_parm
  %type <code>  template_close_bracket
  %type <ttype> apparent_template_type
*************** extern_lang_string:
*** 599,614 ****
  		  pop_lang_context (); push_lang_context ($2); }
  	;
  
! template_header:
  	  TEMPLATE '<'
  		{ begin_template_parm_list (); }
  	  template_parm_list '>'
  		{ $$ = end_template_parm_list ($4); }
! 	| TEMPLATE '<' '>'
                  { begin_specialization(); 
  		  $$ = NULL_TREE; }
  	;
  
  template_parm_list:
  	  template_parm
  		{ $$ = process_template_parm (NULL_TREE, $1); }
--- 600,623 ----
  		  pop_lang_context (); push_lang_context ($2); }
  	;
  
! template_parm_header:
  	  TEMPLATE '<'
  		{ begin_template_parm_list (); }
  	  template_parm_list '>'
  		{ $$ = end_template_parm_list ($4); }
! 	;
! 
! template_spec_header:
! 	  TEMPLATE '<' '>'
                  { begin_specialization(); 
  		  $$ = NULL_TREE; }
  	;
  
+ template_header:
+ 	  template_parm_header
+ 	| template_spec_header
+ 	;
+ 
  template_parm_list:
  	  template_parm
  		{ $$ = process_template_parm (NULL_TREE, $1); }
*************** template_type_parm:
*** 630,636 ****
  	;
  
  template_template_parm:
! 	  template_header aggr maybe_identifier
                  { $$ = finish_template_template_parm ($2, $3); }
  	;
  
--- 639,645 ----
  	;
  
  template_template_parm:
! 	  template_parm_header aggr maybe_identifier
                  { $$ = finish_template_template_parm ($2, $3); }
  	;
  
Index: cp/semantics.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/semantics.c,v
retrieving revision 1.184
diff -c -3 -p -r1.184 semantics.c
*** semantics.c	2000/12/22 14:51:22	1.184
--- semantics.c	2001/01/11 09:10:23
*************** finish_template_template_parm (aggr, ide
*** 1689,1694 ****
--- 1689,1696 ----
    DECL_ARTIFICIAL (decl) = 1;
    end_template_decl ();
  
+   my_friendly_assert (DECL_TEMPLATE_PARMS (tmpl), 20010110);
+ 
    return finish_template_type_parm (aggr, tmpl);
  }
  
// Build don't link:

// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 10 Jan 2001 <nathan@codesourcery.com>

// Bug 1585. We ICEd on a template template parm with no parms.

template<template<class> class C> class B;
template<template<> class C> class D; // ERROR - parse error

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