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: Tweak `void' parameter type handling again



This patch makes sure that we don't even create FUNCTION_TYPEs with
`void' anywhere except in the last position.

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

2000-11-18  Mark Mitchell  <mark@codesourcery.com>

	* decl.c (grokparms): Don't even function types of `void' type,
	either.
	* mangle.c (write_type): Don't crash when confronted with the
	error_mark_node.

Index: gcc/cp/decl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl.c,v
retrieving revision 1.714
diff -c -p -r1.714 decl.c
*** decl.c	2000/11/19 02:34:29	1.714
--- decl.c	2000/11/19 04:54:42
*************** grokparms (first_parm)
*** 12025,12075 ****
  	  /* It's not a good idea to actually create parameters of
  	     type `void'; other parts of the compiler assume that a
  	     void type terminates the parameter list.  */
  	  TREE_TYPE (decl) = error_mark_node;
          }
!       
!       /* Top-level qualifiers on the parameters are
!          ignored for function types.  */
!       type = TYPE_MAIN_VARIANT (type);
!       if (TREE_CODE (type) == METHOD_TYPE)
!         {
!           cp_error ("parameter `%D' invalidly declared method type", decl);
!           type = build_pointer_type (type);
!           TREE_TYPE (decl) = type;
!         }
!       else if (TREE_CODE (type) == OFFSET_TYPE)
!         {
!           cp_error ("parameter `%D' invalidly declared offset type", decl);
!           type = build_pointer_type (type);
!           TREE_TYPE (decl) = type;
!         }
!       else if (abstract_virtuals_error (decl, type))
!         any_error = 1;  /* Seems like a good idea. */
!       else if (POINTER_TYPE_P (type))
!         {
!           /* [dcl.fct]/6, parameter types cannot contain pointers (references)
!              to arrays of unknown bound.  */
!           tree t = type;
!           
!           while (POINTER_TYPE_P (t)
!                  || (TREE_CODE (t) == ARRAY_TYPE
!                      && TYPE_DOMAIN (t) != NULL_TREE))
!     	    t = TREE_TYPE (t);
!           if (TREE_CODE (t) == ARRAY_TYPE)
!     	    cp_error ("parameter `%D' includes %s to array of unknown bound `%T'",
!     		      decl, TYPE_PTR_P (type) ? "pointer" : "reference", t);
!         }
  
!       DECL_ARG_TYPE (decl) = TREE_TYPE (decl);
!       if (PROMOTE_PROTOTYPES
! 	  && (TREE_CODE (type) == INTEGER_TYPE
! 	      || TREE_CODE (type) == ENUMERAL_TYPE)
! 	  && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))
! 	DECL_ARG_TYPE (decl) = integer_type_node;
!       if (!any_error && init)
!         init = check_default_argument (decl, init);
!       else
! 	init = NULL_TREE;
  
        TREE_CHAIN (decl) = decls;
        decls = decl;
--- 12025,12079 ----
  	  /* It's not a good idea to actually create parameters of
  	     type `void'; other parts of the compiler assume that a
  	     void type terminates the parameter list.  */
+ 	  type = error_mark_node;
  	  TREE_TYPE (decl) = error_mark_node;
          }
! 
!       if (type != error_mark_node) 
! 	{
! 	  /* Top-level qualifiers on the parameters are
! 	     ignored for function types.  */
! 	  type = TYPE_MAIN_VARIANT (type);
! 	  if (TREE_CODE (type) == METHOD_TYPE)
! 	    {
! 	      cp_error ("parameter `%D' invalidly declared method type", decl);
! 	      type = build_pointer_type (type);
! 	      TREE_TYPE (decl) = type;
! 	    }
! 	  else if (TREE_CODE (type) == OFFSET_TYPE)
! 	    {
! 	      cp_error ("parameter `%D' invalidly declared offset type", decl);
! 	      type = build_pointer_type (type);
! 	      TREE_TYPE (decl) = type;
! 	    }
! 	  else if (abstract_virtuals_error (decl, type))
! 	    any_error = 1;  /* Seems like a good idea. */
! 	  else if (POINTER_TYPE_P (type))
! 	    {
! 	      /* [dcl.fct]/6, parameter types cannot contain pointers
! 		 (references) to arrays of unknown bound.  */
! 	      tree t = type;
! 
! 	      while (POINTER_TYPE_P (t)
! 		     || (TREE_CODE (t) == ARRAY_TYPE
! 			 && TYPE_DOMAIN (t) != NULL_TREE))
! 		t = TREE_TYPE (t);
! 	      if (TREE_CODE (t) == ARRAY_TYPE)
! 		cp_error ("parameter `%D' includes %s to array of unknown bound `%T'",
! 			  decl, TYPE_PTR_P (type) ? "pointer" : "reference", t);
! 	    }
  
! 	  DECL_ARG_TYPE (decl) = TREE_TYPE (decl);
! 	  if (PROMOTE_PROTOTYPES
! 	      && (TREE_CODE (type) == INTEGER_TYPE
! 		  || TREE_CODE (type) == ENUMERAL_TYPE)
! 	      && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))
! 	    DECL_ARG_TYPE (decl) = integer_type_node;
! 	  if (!any_error && init)
! 	    init = check_default_argument (decl, init);
! 	  else
! 	    init = NULL_TREE;
! 	}
  
        TREE_CHAIN (decl) = decls;
        decls = decl;
Index: gcc/cp/mangle.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/mangle.c,v
retrieving revision 1.19
diff -c -p -r1.19 mangle.c
*** mangle.c	2000/11/16 22:36:20	1.19
--- mangle.c	2000/11/19 04:54:43
*************** write_type (type)
*** 1245,1250 ****
--- 1245,1253 ----
  
    MANGLE_TRACE_TREE ("type", type);
  
+   if (type == error_mark_node)
+     return;
+ 
    if (find_substitution (type))
      return;
    
Index: gcc/testsuite/g++.old-deja/g++.abi/cxa_vec.C
===================================================================
RCS file: /cvs/gcc/egcs/gcc/testsuite/g++.old-deja/g++.abi/cxa_vec.C,v
retrieving revision 1.2
diff -c -p -r1.2 cxa_vec.C
*** cxa_vec.C	2000/11/16 04:14:37	1.2
--- cxa_vec.C	2000/11/19 04:54:44
*************** void test1 ()
*** 97,103 ****
        started = true;
        std::set_terminate (test1);
        
!       ctor_count = dtor_count = 5;
        dtor_repeat = false;
        blocks = 0;
        
--- 97,103 ----
        started = true;
        std::set_terminate (test1);
        
!       dtor_count = 5;
        dtor_repeat = false;
        blocks = 0;
        

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