C++ PATCH: More parser tidying

Mark Mitchell mark@codesourcery.com
Sun Jul 7 22:49:00 GMT 2002


Here's another minor patch to bring the new parser closer to compiling
again.

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

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

2002-07-07  Mark Mitchell  <mark@codesourcery.com>

	* Make-lang.in (cp/parse.o): Depend on decl.h.
	* cp-tree.h (do_decl_instantiation): Change prototype.
	* parse.y: Include decl.h.
	(parse_decl_instantiation): New function.
	(explicit_instantiation): Use it.
	* pt.c (do_decl_instantiation): Accept a DECL, not a DECLARATOR
	and DECLSPECS.
	
Index: Make-lang.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/Make-lang.in,v
retrieving revision 1.115
diff -c -p -r1.115 Make-lang.in
*** Make-lang.in	4 Jun 2002 07:09:54 -0000	1.115
--- Make-lang.in	8 Jul 2002 01:53:12 -0000
*************** cp/optimize.o: cp/optimize.c $(CXX_TREE_
*** 301,307 ****
  cp/mangle.o: cp/mangle.c $(CXX_TREE_H) toplev.h real.h
  
  cp/parse.o: cp/parse.c $(CXX_TREE_H) flags.h cp/lex.h except.h output.h \
! 	$(SYSTEM_H) toplev.h $(GGC_H) gt-cp-parse.h
  	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(BIG_SWITCHFLAG) \
  		$(srcdir)/cp/parse.c $(OUTPUT_OPTION)
  #
--- 301,307 ----
  cp/mangle.o: cp/mangle.c $(CXX_TREE_H) toplev.h real.h
  
  cp/parse.o: cp/parse.c $(CXX_TREE_H) flags.h cp/lex.h except.h output.h \
! 	cp/decl.h $(SYSTEM_H) toplev.h $(GGC_H) gt-cp-parse.h
  	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(BIG_SWITCHFLAG) \
  		$(srcdir)/cp/parse.c $(OUTPUT_OPTION)
  #
Index: cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.723
diff -c -p -r1.723 cp-tree.h
*** cp-tree.h	26 Jun 2002 17:03:41 -0000	1.723
--- cp-tree.h	8 Jul 2002 01:53:13 -0000
*************** extern tree tinst_for_decl			PARAMS ((vo
*** 4124,4130 ****
  extern void mark_decl_instantiated		PARAMS ((tree, int));
  extern int more_specialized			PARAMS ((tree, tree, int, int));
  extern void mark_class_instantiated		PARAMS ((tree, int));
! extern void do_decl_instantiation		PARAMS ((tree, tree, tree));
  extern void do_type_instantiation		PARAMS ((tree, tree, tsubst_flags_t));
  extern tree instantiate_decl			PARAMS ((tree, int));
  extern tree get_bindings			PARAMS ((tree, tree, tree));
--- 4124,4130 ----
  extern void mark_decl_instantiated		PARAMS ((tree, int));
  extern int more_specialized			PARAMS ((tree, tree, int, int));
  extern void mark_class_instantiated		PARAMS ((tree, int));
! extern void do_decl_instantiation		(tree, tree);
  extern void do_type_instantiation		PARAMS ((tree, tree, tsubst_flags_t));
  extern tree instantiate_decl			PARAMS ((tree, int));
  extern tree get_bindings			PARAMS ((tree, tree, tree));
Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parse.y,v
retrieving revision 1.267
diff -c -p -r1.267 parse.y
*** parse.y	26 Jun 2002 17:03:43 -0000	1.267
--- parse.y	8 Jul 2002 01:53:13 -0000
*************** Boston, MA 02111-1307, USA.  */
*** 36,41 ****
--- 36,42 ----
  #include "input.h"
  #include "flags.h"
  #include "cp-tree.h"
+ #include "decl.h"
  #include "lex.h"
  #include "c-pragma.h"		/* For YYDEBUG definition.  */
  #include "output.h"
*************** static void check_class_key PARAMS ((tre
*** 132,137 ****
--- 133,139 ----
  static tree parse_scoped_id PARAMS ((tree));
  static tree parse_xref_tag (tree, tree, int);
  static tree parse_handle_class_head (tree, tree, tree, int, int *);
+ static void parse_decl_instantiation (tree, tree, tree);
  
  /* Cons up an empty parameter list.  */
  static inline tree
*************** explicit_instantiation:
*** 1047,1059 ****
            end_explicit_instantiation
  	| TEMPLATE begin_explicit_instantiation typed_declspecs declarator
  		{ tree specs = strip_attrs ($3.t);
! 		  do_decl_instantiation (specs, $4, NULL_TREE); }
            end_explicit_instantiation
  	| TEMPLATE begin_explicit_instantiation notype_declarator
! 		{ do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
            end_explicit_instantiation
  	| TEMPLATE begin_explicit_instantiation constructor_declarator
! 		{ do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
            end_explicit_instantiation
  	| SCSPEC TEMPLATE begin_explicit_instantiation typespec ';'
  		{ do_type_instantiation ($4.t, $1, 1);
--- 1049,1061 ----
            end_explicit_instantiation
  	| TEMPLATE begin_explicit_instantiation typed_declspecs declarator
  		{ tree specs = strip_attrs ($3.t);
! 		  parse_decl_instantiation (specs, $4, NULL_TREE); }
            end_explicit_instantiation
  	| TEMPLATE begin_explicit_instantiation notype_declarator
! 		{ parse_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
            end_explicit_instantiation
  	| TEMPLATE begin_explicit_instantiation constructor_declarator
! 		{ parse_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
            end_explicit_instantiation
  	| SCSPEC TEMPLATE begin_explicit_instantiation typespec ';'
  		{ do_type_instantiation ($4.t, $1, 1);
*************** explicit_instantiation:
*** 1063,1077 ****
  	| SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
            declarator
  		{ tree specs = strip_attrs ($4.t);
! 		  do_decl_instantiation (specs, $5, $1); }
            end_explicit_instantiation
  		{}
  	| SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
! 		{ do_decl_instantiation (NULL_TREE, $4, $1); }
            end_explicit_instantiation
  		{}
  	| SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
! 		{ do_decl_instantiation (NULL_TREE, $4, $1); }
            end_explicit_instantiation
  		{}
  	;
--- 1065,1079 ----
  	| SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
            declarator
  		{ tree specs = strip_attrs ($4.t);
! 		  parse_decl_instantiation (specs, $5, $1); }
            end_explicit_instantiation
  		{}
  	| SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
! 		{ parse_decl_instantiation (NULL_TREE, $4, $1); }
            end_explicit_instantiation
  		{}
  	| SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
! 		{ parse_decl_instantiation (NULL_TREE, $4, $1); }
            end_explicit_instantiation
  		{}
  	;
*************** parse_xref_tag (tree aggr, tree name, in
*** 4072,4078 ****
    return xref_tag (tag_kind, name, attributes, globalize);
  }
  
! /* Like handle_class_head, but AGGR may be as for parse_xref_tag. */
  
  static tree
  parse_handle_class_head (tree aggr, tree scope, tree id, 
--- 4074,4080 ----
    return xref_tag (tag_kind, name, attributes, globalize);
  }
  
! /* Like handle_class_head, but AGGR may be as for parse_xref_tag.  */
  
  static tree
  parse_handle_class_head (tree aggr, tree scope, tree id, 
*************** parse_handle_class_head (tree aggr, tree
*** 4083,4088 ****
--- 4085,4100 ----
    parse_split_aggr (aggr, &tag_kind, &attributes);
    return handle_class_head (tag_kind, scope, id, attributes, 
  			    defn_p, new_type_p);
+ }
+ 
+ /* Like do_decl_instantiation, but the declarator has not yet been
+    parsed.  */
+ 
+ static void
+ parse_decl_instantiation (tree declspecs, tree declarator, tree storage)
+ {
+   tree decl = grokdeclarator (declarator, declspecs, NORMAL, 0, NULL);
+   do_decl_instantiation (decl, storage);
  }
  
  #include "gt-cp-parse.h"
Index: pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.594
diff -c -p -r1.594 pt.c
*** pt.c	25 Jun 2002 15:35:26 -0000	1.594
--- pt.c	8 Jul 2002 01:53:15 -0000
*************** most_specialized_class (tmpl, args)
*** 9468,9480 ****
    return champ;
  }
  
! /* called from the parser.  */
  
  void
! do_decl_instantiation (declspecs, declarator, storage)
!      tree declspecs, declarator, storage;
  {
-   tree decl = grokdeclarator (declarator, declspecs, NORMAL, 0, NULL);
    tree result = NULL_TREE;
    int extern_p = 0;
  
--- 9463,9473 ----
    return champ;
  }
  
! /* Explicitly instantiate DECL.  */
  
  void
! do_decl_instantiation (tree decl, tree storage)
  {
    tree result = NULL_TREE;
    int extern_p = 0;
  



More information about the Gcc-patches mailing list