C++ PATCH: PR c++/10432

Mark Mitchell mark@codesourcery.com
Thu Jun 12 00:13:00 GMT 2003


This patch fixes an error-recovery ICE (PR c++/10432).

Tested on i686-pc-linux-gnu, applied on the mainline.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2003-06-11  Mark Mitchell  <mark@codesourcery.com>

	PR c++/10432
	* cp-tree.h (finish_declarator): Remove.
	* decl.c (cp_finish_decl): Make sure to pop_nested_class even for
	erroneous declarations.
	* semantics.c (finish_declarator): Remove.

2003-06-11  Mark Mitchell  <mark@codesourcery.com>

	PR c++/10432
	* g++.dg/parse/error1.C: New test.

Index: cp/cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.850
diff -c -5 -p -r1.850 cp-tree.h
*** cp/cp-tree.h	10 Jun 2003 07:19:54 -0000	1.850
--- cp/cp-tree.h	11 Jun 2003 23:59:14 -0000
*************** extern tree finish_qualified_object_call
*** 4116,4126 ****
  extern tree finish_pseudo_destructor_expr       (tree, tree, tree);
  extern tree finish_unary_op_expr                (enum tree_code, tree);
  extern tree finish_compound_literal             (tree, tree);
  extern tree finish_fname                        (tree);
  extern int begin_function_definition            (tree, tree, tree);
- extern tree finish_declarator                   (tree, tree, tree, tree, int);
  extern void finish_translation_unit             (void);
  extern tree finish_template_type_parm           (tree, tree);
  extern tree finish_template_template_parm       (tree, tree);
  extern tree finish_parmlist                     (tree, int);
  extern tree begin_class_definition              (tree);
--- 4116,4125 ----
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.1063
diff -c -5 -p -r1.1063 decl.c
*** cp/decl.c	10 Jun 2003 18:32:55 -0000	1.1063
--- cp/decl.c	11 Jun 2003 23:59:20 -0000
*************** cp_finish_decl (tree decl, tree init, tr
*** 8021,8031 ****
      }
  
    type = TREE_TYPE (decl);
  
    if (type == error_mark_node)
!     return;
  
    if (TYPE_HAS_MUTABLE_P (type))
      TREE_READONLY (decl) = 0;
  
    if (processing_template_decl)
--- 8021,8031 ----
      }
  
    type = TREE_TYPE (decl);
  
    if (type == error_mark_node)
!     goto finish_end0;
  
    if (TYPE_HAS_MUTABLE_P (type))
      TREE_READONLY (decl) = 0;
  
    if (processing_template_decl)
Index: cp/semantics.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/semantics.c,v
retrieving revision 1.308
diff -c -5 -p -r1.308 semantics.c
*** cp/semantics.c	18 May 2003 09:42:09 -0000	1.308
--- cp/semantics.c	11 Jun 2003 23:59:29 -0000
*************** begin_function_definition (decl_specs, a
*** 1737,1761 ****
    reset_specialization ();
  
    return 1;
  }
  
- /* Finish an init-declarator.  Returns a DECL.  */
- 
- tree
- finish_declarator (declarator, declspecs, attributes,
- 		   prefix_attributes, initialized)
-      tree declarator;
-      tree declspecs;
-      tree attributes;
-      tree prefix_attributes;
-      int initialized;
- {
-   return start_decl (declarator, declspecs, initialized, attributes,
- 		     prefix_attributes); 
- }
- 
  /* Finish a translation unit.  */
  
  void 
  finish_translation_unit ()
  {
--- 1737,1746 ----
Index: testsuite/g++.dg/parse/error1.C
===================================================================
RCS file: testsuite/g++.dg/parse/error1.C
diff -N testsuite/g++.dg/parse/error1.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/parse/error1.C	11 Jun 2003 23:59:29 -0000
***************
*** 0 ****
--- 1,6 ----
+ struct INCOMPLETE;
+ template <int> struct X {
+     static INCOMPLETE value;
+ };
+ template <> INCOMPLETE X<1>::value = 0; // { dg-error "" }
+ 



More information about the Gcc-patches mailing list