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 to template/array handling


Fixes g++.pt/array6.C with -gdwarf-2; we weren't calling variable_size in
the instantiation.

Mark, I suspect that there was some reason why tsubst wasn't already
checking uses_template_parms, but the comment doesn't explain it.

1999-11-15  Jason Merrill  <jason@casey.cygnus.com>

	* cp-tree.h, decl.c (compute_array_index_type): Make nonstatic.
	* pt.c (tsubst, case INTEGER_TYPE): Call it.  
	Check uses_template_parms.

Index: pt.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/pt.c,v
retrieving revision 1.381
diff -c -p -r1.381 pt.c
*** pt.c	1999/11/16 01:37:39	1.381
--- pt.c	1999/11/16 04:54:20
*************** tsubst (t, args, complain, in_decl)
*** 6180,6186 ****
  	       function, but leaving some arguments for subsequent
  	       deduction, MAX may be template-dependent even if we're
  	       not PROCESSING_TEMPLATE_DECL.  */
! 	    || TREE_CODE (max) != INTEGER_CST)
  	  {
  	    tree itype = make_node (INTEGER_TYPE);
  	    TYPE_MIN_VALUE (itype) = size_zero_node;
--- 6180,6187 ----
  	       function, but leaving some arguments for subsequent
  	       deduction, MAX may be template-dependent even if we're
  	       not PROCESSING_TEMPLATE_DECL.  */
! 	    || (TREE_CODE (max) != INTEGER_CST
! 		&& uses_template_parms (max)))
  	  {
  	    tree itype = make_node (INTEGER_TYPE);
  	    TYPE_MIN_VALUE (itype) = size_zero_node;
*************** tsubst (t, args, complain, in_decl)
*** 6210,6217 ****
  	    return error_mark_node;
  	  }
  
! 	max = fold (build_binary_op (MINUS_EXPR, max, integer_one_node));
! 	return build_index_type (max);
        }
  
      case TEMPLATE_TYPE_PARM:
--- 6211,6217 ----
  	    return error_mark_node;
  	  }
  
! 	return compute_array_index_type (NULL_TREE, max);
        }
  
      case TEMPLATE_TYPE_PARM:
Index: decl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl.c,v
retrieving revision 1.503
diff -c -p -r1.503 decl.c
*** decl.c	1999/11/16 01:37:38	1.503
--- decl.c	1999/11/16 04:54:31
*************** static void destroy_local_static PROTO((
*** 175,181 ****
  static void destroy_local_var PROTO((tree));
  static void finish_constructor_body PROTO((void));
  static void finish_destructor_body PROTO((void));
- static tree compute_array_index_type PROTO((tree, tree));
  static tree create_array_type_for_decl PROTO((tree, tree, tree));
  
  #if defined (DEBUG_CP_BINDING_LEVELS)
--- 175,180 ----
*************** check_static_variable_definition (decl, 
*** 8689,8695 ****
     appropriate index type for the array.  If non-NULL, NAME is the
     name of the thing being declared.  */
  
! static tree
  compute_array_index_type (name, size)
       tree name;
       tree size;
--- 8690,8696 ----
     appropriate index type for the array.  If non-NULL, NAME is the
     name of the thing being declared.  */
  
! tree
  compute_array_index_type (name, size)
       tree name;
       tree size;
Index: cp-tree.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/cp-tree.h,v
retrieving revision 1.348
diff -c -p -r1.348 cp-tree.h
*** cp-tree.h	1999/11/16 01:37:38	1.348
--- cp-tree.h	1999/11/16 04:54:36
*************** cp-tree.h			PROTO((void))
*** 3497,3504 ****
  extern void replace_defarg			PROTO((tree, tree));
  extern void print_other_binding_stack		PROTO((struct binding_level *));
  extern void revert_static_member_fn             PROTO((tree*, tree*, tree*));
! extern void fixup_anonymous_aggr               PROTO((tree));
  extern int check_static_variable_definition     PROTO((tree, tree));
  extern void push_local_binding                  PROTO((tree, tree, int));
  extern int push_class_binding                   PROTO((tree, tree));
  extern tree check_default_argument              PROTO((tree, tree));
--- 3497,3505 ----
  extern void replace_defarg			PROTO((tree, tree));
  extern void print_other_binding_stack		PROTO((struct binding_level *));
  extern void revert_static_member_fn             PROTO((tree*, tree*, tree*));
! extern void fixup_anonymous_aggr                PROTO((tree));
  extern int check_static_variable_definition     PROTO((tree, tree));
+ extern tree compute_array_index_type		PROTO((tree, tree));
  extern void push_local_binding                  PROTO((tree, tree, int));
  extern int push_class_binding                   PROTO((tree, tree));
  extern tree check_default_argument              PROTO((tree, tree));


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