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]

Re: New C++ testcase


Mark Mitchell wrote:
> 
> >>>>> "Bernd" == Bernd Schmidt <bernds@redhat.co.uk> writes:
> 
>     Bernd> Can I install this in the g++ testsuite?  Which name would
>     Bernd> be appropriate?
> 
> I have a feeling I looked at this, and that it only happens using the
> old mangler.  Does it crash with -fnew-abi?  If not, it's not
> interesting -- the old mangler is dying before 3.0.
we had talked about it, it's but 573. Yes it kills the new mangler,
that's because sizetype is used, rather than c_size_type_node.
Here's a new patch which DTRT and cleans up the code. ok?

built & tested on i686-pc-linux-gnu.
nathan
-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2000-11-07  Nathan Sidwell  <nathan@codesourcery.com>

	* decl.c (grok_op_properties): Always use coerce_new_type and
	coerce_delete_type.
	* decl2.c (coerce_new_type): Use c_size_type_node. Preserve
	exception specification. Tidy up.
	(coerce_delete_type): Preserve exception specification. Tidy up.

Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl.c,v
retrieving revision 1.704
diff -c -3 -p -r1.704 decl.c
*** decl.c	2000/11/03 22:24:21	1.704
--- decl.c	2000/11/07 11:48:17
*************** grok_op_properties (decl, virtualp, frie
*** 12444,12470 ****
        if (methodp)
  	revert_static_member_fn (decl);
  
!       /* Take care of function decl if we had syntax errors.  */
!       if (argtypes == NULL_TREE)
! 	TREE_TYPE (decl)
! 	  = build_function_type (ptr_type_node,
! 				 hash_tree_chain (integer_type_node,
! 						  void_list_node));
!       else
! 	TREE_TYPE (decl) = coerce_new_type (TREE_TYPE (decl));
      }
    else if (operator_code == DELETE_EXPR || operator_code == VEC_DELETE_EXPR)
      {
        if (methodp)
  	revert_static_member_fn (decl);
  
!       if (argtypes == NULL_TREE)
! 	TREE_TYPE (decl)
! 	  = build_function_type (void_type_node,
! 				 hash_tree_chain (ptr_type_node,
! 						  void_list_node));
!       else
! 	TREE_TYPE (decl) = coerce_delete_type (TREE_TYPE (decl));
      }
    else
      {
--- 12447,12460 ----
        if (methodp)
  	revert_static_member_fn (decl);
  
!       TREE_TYPE (decl) = coerce_new_type (TREE_TYPE (decl));
      }
    else if (operator_code == DELETE_EXPR || operator_code == VEC_DELETE_EXPR)
      {
        if (methodp)
  	revert_static_member_fn (decl);
  
!       TREE_TYPE (decl) = coerce_delete_type (TREE_TYPE (decl));
      }
    else
      {
Index: cp/decl2.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl2.c,v
retrieving revision 1.408
diff -c -3 -p -r1.408 decl2.c
*** decl2.c	2000/11/04 18:47:16	1.408
--- decl2.c	2000/11/07 11:48:45
*************** tree
*** 2301,2323 ****
  coerce_new_type (type)
       tree type;
  {
!   int e1 = 0, e2 = 0;
  
!   if (TREE_CODE (type) == METHOD_TYPE)
!     type = build_function_type (TREE_TYPE (type), TREE_CHAIN (TYPE_ARG_TYPES (type)));
!   if (! same_type_p (TREE_TYPE (type), ptr_type_node))
!     e1 = 1, error ("`operator new' must return type `void *'");
  
!   /* Technically the type must be `size_t', but we may not know
!      what that is.  */
!   if (TYPE_ARG_TYPES (type) == NULL_TREE)
!     e1 = 1, error ("`operator new' takes type `size_t' parameter");
!   else if (! same_type_p (TREE_VALUE (TYPE_ARG_TYPES (type)), sizetype))
!     e2 = 1, error ("`operator new' takes type `size_t' as first parameter");
!   if (e2)
!     type = build_function_type (ptr_type_node, tree_cons (NULL_TREE, sizetype, TREE_CHAIN (TYPE_ARG_TYPES (type))));
!   else if (e1)
!     type = build_function_type (ptr_type_node, TYPE_ARG_TYPES (type));
    return type;
  }
  
--- 2301,2334 ----
  coerce_new_type (type)
       tree type;
  {
!   int e = 0;
!   tree args = TYPE_ARG_TYPES (type);
  
!   my_friendly_assert (TREE_CODE (type) == FUNCTION_TYPE, 20001107);
!   
!   if (!same_type_p (TREE_TYPE (type), ptr_type_node))
!     e = 1, cp_error ("`operator new' must return type `%T'", ptr_type_node);
  
!   if (!args || args == void_list_node
!       || !same_type_p (TREE_VALUE (args), c_size_type_node))
!     {
!       e = 2;
!       if (args && args != void_list_node)
!         args = TREE_CHAIN (args);
!       cp_error ("`operator new' takes type `size_t' (`%T') as first parameter", c_size_type_node);
!     }
!   switch (e)
!   {
!     case 2:
!       args = tree_cons (NULL_TREE, c_size_type_node, args);
!       /* FALLTHROUGH */
!     case 1:
!       type = build_exception_variant
!               (build_function_type (ptr_type_node, args),
!                TYPE_RAISES_EXCEPTIONS (type));
!       /* FALLTHROUGH */
!     default:;
!   }
    return type;
  }
  
*************** tree
*** 2325,2387 ****
  coerce_delete_type (type)
       tree type;
  {
!   int e1 = 0, e2 = 0;
! #if 0
!   e3 = 0;
! #endif
!   tree arg_types = TYPE_ARG_TYPES (type);
! 
!   if (TREE_CODE (type) == METHOD_TYPE)
!     {
!       type = build_function_type (TREE_TYPE (type), TREE_CHAIN (arg_types));
!       arg_types = TREE_CHAIN (arg_types);
!     }
  
!   if (TREE_TYPE (type) != void_type_node)
!     e1 = 1, error ("`operator delete' must return type `void'");
  
!   if (arg_types == NULL_TREE
!       || ! same_type_p (TREE_VALUE (arg_types), ptr_type_node))
!     e2 = 1, error ("`operator delete' takes type `void *' as first parameter");
! 
! #if 0
!   if (arg_types
!       && TREE_CHAIN (arg_types)
!       && TREE_CHAIN (arg_types) != void_list_node)
      {
!       /* Again, technically this argument must be `size_t', but again
! 	 we may not know what that is.  */
!       tree t2 = TREE_VALUE (TREE_CHAIN (arg_types));
!       if (! same_type_p (t2, sizetype))
! 	e3 = 1, error ("second argument to `operator delete' must be of type `size_t'");
!       else if (TREE_CHAIN (TREE_CHAIN (arg_types)) != void_list_node)
! 	{
! 	  e3 = 1;
! 	  if (TREE_CHAIN (TREE_CHAIN (arg_types)))
! 	    error ("too many arguments in declaration of `operator delete'");
! 	  else
! 	    error ("`...' invalid in specification of `operator delete'");
! 	}
      }
! 
!   if (e3)
!     arg_types = tree_cons (NULL_TREE, ptr_type_node,
! 			   build_tree_list (NULL_TREE, sizetype));
!   else if (e3 |= e2)
!     {
!       if (arg_types == NULL_TREE)
! 	arg_types = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
!       else
! 	arg_types = tree_cons (NULL_TREE, ptr_type_node, TREE_CHAIN (arg_types));
!     }
!   else e3 |= e1;
! #endif
! 
!   if (e2)
!     arg_types = tree_cons (NULL_TREE, ptr_type_node,
! 			   arg_types ? TREE_CHAIN (arg_types): NULL_TREE);
!   if (e2 || e1)
!     type = build_function_type (void_type_node, arg_types);
  
    return type;
  }
--- 2336,2369 ----
  coerce_delete_type (type)
       tree type;
  {
!   int e = 0;
!   tree args = TYPE_ARG_TYPES (type);
!   
!   my_friendly_assert (TREE_CODE (type) == FUNCTION_TYPE, 20001107);
  
!   if (!same_type_p (TREE_TYPE (type), void_type_node))
!     e = 1, cp_error ("`operator delete' must return type `%T'", void_type_node);
  
!   if (!args || args == void_list_node
!       || !same_type_p (TREE_VALUE (args), ptr_type_node))
      {
!       e = 2;
!       if (args && args != void_list_node)
!         args = TREE_CHAIN (args);
!       cp_error ("`operator delete' takes type `%T' as first parameter", ptr_type_node);
      }
!   switch (e)
!   {
!     case 2:
!       args = tree_cons (NULL_TREE, ptr_type_node, args);
!       /* FALLTHROUGH */
!     case 1:
!       type = build_exception_variant
!               (build_function_type (void_type_node, args),
!                TYPE_RAISES_EXCEPTIONS (type));
!       /* FALLTHROUGH */
!     default:;
!   }
  
    return type;
  }
// Build don't link:
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 7 Nov 2000 <nathan@codesourcery.com>

// Bug 573. We ICE'd verifying operator new and operator delete conformed
// to the standard's expectation.

void *operator new (__SIZE_TYPE__); // ok
void operator new (__SIZE_TYPE__);  // ERROR - must return void *
void *operator new ();              // ERROR - must take size_t
void *operator new (char);          // ERROR - must take size_t
void *operator new (__SIZE_TYPE__, ...) throw(); // ok

void operator delete (void *) throw (); // ok
int operator delete (void *) throw ();          // ERROR - must return void
void operator delete () throw ();               // ERROR - must take void *
void operator delete (int *) throw ();          // ERROR - must take void *
void operator delete (void *, __SIZE_TYPE__) throw (); // ok

void operator delete (...) throw ();             // ERROR - must take void *
void operator delete (void *, ...) throw ();     // ok

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