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]
Other format: [Raw text]

[C++] fix 18758


This fixes 18758, an ICE on invalid.  cp_parser_class_head
returns error_mark_node on some kinds of errors and NULL_TREE on others.
It was returning the wrong one.

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

nathan
--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

2004-12-02  Nathan Sidwell  <nathan@codesourcery.com>

	PR c++/18758
	* parser.c (cp_parser_class_head): Return NULL_TREE when
	push_template_decl fails.  Update comment.

Index: cp/parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.287
diff -c -3 -p -r1.287 parser.c
*** cp/parser.c	2 Dec 2004 11:34:45 -0000	1.287
--- cp/parser.c	2 Dec 2004 13:23:17 -0000
*************** cp_parser_class_specifier (cp_parser* pa
*** 12443,12448 ****
--- 12443,12450 ----
     *NESTED_NAME_SPECIFIER_P to TRUE iff one of the productions
     involving a nested-name-specifier was used, and FALSE otherwise.
  
+    Returns error_mark_node if this is not a class-head.
+    
     Returns NULL_TREE if the class-head is syntactically valid, but
     semantically invalid in a way that means we should skip the entire
     body of the class.  */
*************** cp_parser_class_head (cp_parser* parser,
*** 12714,12720 ****
        type = TYPE_MAIN_DECL (TREE_TYPE (type));
        if (PROCESSING_REAL_TEMPLATE_DECL_P ()
  	  && !CLASSTYPE_TEMPLATE_SPECIALIZATION (TREE_TYPE (type)))
! 	type = push_template_decl (type);
        type = TREE_TYPE (type);
        if (nested_name_specifier)
  	{
--- 12716,12730 ----
        type = TYPE_MAIN_DECL (TREE_TYPE (type));
        if (PROCESSING_REAL_TEMPLATE_DECL_P ()
  	  && !CLASSTYPE_TEMPLATE_SPECIALIZATION (TREE_TYPE (type)))
! 	{
! 	  type = push_template_decl (type);
! 	  if (type == error_mark_node)
! 	    {
! 	      type = NULL_TREE;
! 	      goto done;
! 	    }
! 	}
!       
        type = TREE_TYPE (type);
        if (nested_name_specifier)
  	{
namespace N
{
  struct A; // { dg-error "previous declaration" "" }
}

template<int I>
struct N::A {}; // { dg-error "redeclared" "" }

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