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]
Other format: [Raw text]

[C++ PATCH] Fix 18143


This fixes 18143 by renabling the larger thunk range.  I touch
the common code so need approval.

I discovered that the cloned_function slot could be overloaded, and
this patch achieves that.  I've tweaked the tree_check failure function
to deal with an empty list of expected tree codes, as the two new thunk
and non-thunk accessor macros are doing more than merely checking for
a particular tree code.

booted & tested on i686-pc-linux-gnu, ok?

nathan
--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

2004-11-10  Nathan Sidwell  <nathan@codesourcery.com>

	* tree.c (tree_check_failed): Emit general error if the list of
	node types is empty.

	PR c++/18143
	* cp-tree.h (NON_THUNK_FUNCTION_CHECK, THUNK_FUNCTION_CHECK): New.
	(struct lang_decl_flags): Add thunk_p flag.
	(struct lang_decl): Remove separate fixed_offset. Place
	cloned_function and fixed_offset into union.
	(DECL_CLONED_FUNCTION_P, DECL_CLONED_FUNCTION): Adjust.
	(DECL_THUNK_P, SET_DECL_THUNK_P): Adjust.
	(THUNK_FIXED_OFFSET): Adjust.
	* method.c (make_thunk): Adjust.

Index: tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.c,v
retrieving revision 1.444
diff -c -3 -p -r1.444 tree.c
*** tree.c	3 Nov 2004 19:55:30 -0000	1.444
--- tree.c	5 Nov 2004 10:18:52 -0000
*************** get_set_constructor_bytes (tree init, un
*** 5402,5409 ****
  #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
  
  /* Complain that the tree code of NODE does not match the expected 0
!    terminated list of trailing codes. FILE, LINE, and FUNCTION are of
!    the caller.  */
  
  void
  tree_check_failed (const tree node, const char *file,
--- 5402,5410 ----
  #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
  
  /* Complain that the tree code of NODE does not match the expected 0
!    terminated list of trailing codes. The trailing code list can be
!    empty, for a more vague error message.  FILE, LINE, and FUNCTION
!    are of the caller.  */
  
  void
  tree_check_failed (const tree node, const char *file,
*************** tree_check_failed (const tree node, cons
*** 5418,5439 ****
    while ((code = va_arg (args, int)))
      length += 4 + strlen (tree_code_name[code]);
    va_end (args);
!   va_start (args, function);
!   buffer = alloca (length);
!   length = 0;
!   while ((code = va_arg (args, int)))
      {
!       if (length)
  	{
! 	  strcpy (buffer + length, " or ");
! 	  length += 4;
  	}
!       strcpy (buffer + length, tree_code_name[code]);
!       length += strlen (tree_code_name[code]);
      }
!   va_end (args);
  
!   internal_error ("tree check: expected %s, have %s in %s, at %s:%d",
  		  buffer, tree_code_name[TREE_CODE (node)],
  		  function, trim_filename (file), line);
  }
--- 5419,5445 ----
    while ((code = va_arg (args, int)))
      length += 4 + strlen (tree_code_name[code]);
    va_end (args);
!   if (length)
      {
!       va_start (args, function);
!       length += strlen ("expected ");
!       buffer = alloca (length);
!       length = 0;
!       while ((code = va_arg (args, int)))
  	{
! 	  const char *prefix = length ? " or " : "expected ";
! 	  
! 	  strcpy (buffer + length, prefix);
! 	  length += strlen (prefix);
! 	  strcpy (buffer + length, tree_code_name[code]);
! 	  length += strlen (tree_code_name[code]);
  	}
!       va_end (args);
      }
!   else
!     buffer = (char *)"unexpected node";
  
!   internal_error ("tree check: %s, have %s in %s, at %s:%d",
  		  buffer, tree_code_name[TREE_CODE (node)],
  		  function, trim_filename (file), line);
  }
Index: cp/cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.1068
diff -c -3 -p -r1.1068 cp-tree.h
*** cp/cp-tree.h	30 Oct 2004 21:17:26 -0000	1.1068
--- cp/cp-tree.h	5 Nov 2004 10:19:05 -0000
*************** struct diagnostic_context;
*** 163,168 ****
--- 163,186 ----
  #define BOUND_TEMPLATE_TEMPLATE_PARM_TYPE_CHECK(NODE) \
    TREE_CHECK(NODE,BOUND_TEMPLATE_TEMPLATE_PARM)
  
+ #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
+ #define NON_THUNK_FUNCTION_CHECK(NODE) __extension__			\
+ ({  const tree __t = (NODE);						\
+     if (TREE_CODE (__t) != FUNCTION_DECL &&				\
+  	TREE_CODE (__t) != TEMPLATE_DECL && __t->decl.lang_specific	\
+ 	&& __t->decl.lang_specific->decl_flags.thunk_p)			\
+       tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, 0);	\
+     __t; })
+ #define THUNK_FUNCTION_CHECK(NODE) __extension__			\
+ ({  const tree __t = (NODE);						\
+     if (TREE_CODE (__t) != FUNCTION_DECL || !__t->decl.lang_specific	\
+ 	|| !__t->decl.lang_specific->decl_flags.thunk_p)		\
+       tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, 0); 	\
+      __t; })
+ #else
+ #define NON_THUNK_FUNCTION_CHECK(NODE) (NODE)
+ #define THUNK_FUNCTION_CHECK(NODE) (NODE)
+ #endif
  
  /* Language-dependent contents of an identifier.  */
  
*************** struct lang_decl_flags GTY(())
*** 1496,1504 ****
   
    unsigned u2sel : 1;
    unsigned can_be_full : 1;
    unsigned this_thunk_p : 1;
    unsigned repo_available_p : 1;
!   unsigned dummy : 4;
  
    union lang_decl_u {
      /* In a FUNCTION_DECL for which DECL_THUNK_P holds, this is
--- 1514,1523 ----
   
    unsigned u2sel : 1;
    unsigned can_be_full : 1;
+   unsigned thunk_p : 1;
    unsigned this_thunk_p : 1;
    unsigned repo_available_p : 1;
!   unsigned dummy : 3;
  
    union lang_decl_u {
      /* In a FUNCTION_DECL for which DECL_THUNK_P holds, this is
*************** struct lang_decl GTY(())
*** 1540,1554 ****
  
  	unsigned u3sel : 1;
  	unsigned pending_inline_p : 1;
! 	unsigned spare : 3;
  	
- 	/* In a FUNCTION_DECL for which THUNK_P holds this is the
- 	   THUNK_FIXED_OFFSET.  The largest object that can be
- 	   thunked is thus 262144, which is what is required [limits].
- 	   We have to store a signed value as for regular thunks this
- 	   is <= 0, and for covariant thunks it is >= 0.  */
- 	signed fixed_offset : 19;
- 
  	/* For a non-thunk function decl, this is a tree list of
    	   friendly classes. For a thunk function decl, it is the
    	   thunked to function decl.  */
--- 1559,1566 ----
  
  	unsigned u3sel : 1;
  	unsigned pending_inline_p : 1;
! 	unsigned spare : 22;
  	
  	/* For a non-thunk function decl, this is a tree list of
    	   friendly classes. For a thunk function decl, it is the
    	   thunked to function decl.  */
*************** struct lang_decl GTY(())
*** 1562,1570 ****
  	   will be chained on the return pointer thunk.  */
  	tree context;
  
! 	/* In a FUNCTION_DECL, this is DECL_CLONED_FUNCTION.  */
! 	tree cloned_function;
! 
  	union lang_decl_u3
  	{
  	  struct sorted_fields_type * GTY ((tag ("0"), reorder ("resort_sorted_fields")))
--- 1574,1590 ----
  	   will be chained on the return pointer thunk.  */
  	tree context;
  
! 	union lang_decl_u5
! 	{
! 	  /* In a non-thunk FUNCTION_DECL or TEMPLATE_DECL, this is
! 	     DECL_CLONED_FUNCTION.  */
! 	  tree GTY ((tag ("0"))) cloned_function;
! 	  
! 	  /* In a FUNCTION_DECL for which THUNK_P holds this is the
! 	     THUNK_FIXED_OFFSET.  */
! 	  HOST_WIDE_INT GTY ((tag ("1"))) fixed_offset;
! 	} GTY ((desc ("%0.decl_flags.thunk_p"))) u5;
! 	
  	union lang_decl_u3
  	{
  	  struct sorted_fields_type * GTY ((tag ("0"), reorder ("resort_sorted_fields")))
*************** struct lang_decl GTY(())
*** 1667,1682 ****
  
  /* Nonzero if NODE (a FUNCTION_DECL) is a cloned constructor or
     destructor.  */
! #define DECL_CLONED_FUNCTION_P(NODE)		\
!   ((TREE_CODE (NODE) == FUNCTION_DECL 		\
!     || TREE_CODE (NODE) == TEMPLATE_DECL)	\
!    && DECL_LANG_SPECIFIC (NODE)			\
     && DECL_CLONED_FUNCTION (NODE) != NULL_TREE)
  
  /* If DECL_CLONED_FUNCTION_P holds, this is the function that was
     cloned.  */
  #define DECL_CLONED_FUNCTION(NODE) \
!   (DECL_LANG_SPECIFIC (NODE)->u.f.cloned_function)
  
  /* Perform an action for each clone of FN, if FN is a function with
     clones.  This macro should be used like:
--- 1687,1703 ----
  
  /* Nonzero if NODE (a FUNCTION_DECL) is a cloned constructor or
     destructor.  */
! #define DECL_CLONED_FUNCTION_P(NODE)			\
!   ((TREE_CODE (NODE) == FUNCTION_DECL			\
!     || TREE_CODE (NODE) == TEMPLATE_DECL)		\
!    && DECL_LANG_SPECIFIC (NODE)				\
!    && !DECL_LANG_SPECIFIC (NODE)->decl_flags.thunk_p	\
     && DECL_CLONED_FUNCTION (NODE) != NULL_TREE)
  
  /* If DECL_CLONED_FUNCTION_P holds, this is the function that was
     cloned.  */
  #define DECL_CLONED_FUNCTION(NODE) \
!   (DECL_LANG_SPECIFIC (NON_THUNK_FUNCTION_CHECK(NODE))->u.f.u5.cloned_function)
  
  /* Perform an action for each clone of FN, if FN is a function with
     clones.  This macro should be used like:
*************** struct lang_decl GTY(())
*** 1868,1874 ****
  /* Nonzero if NODE is a thunk, rather than an ordinary function.  */
  #define DECL_THUNK_P(NODE)			\
    (TREE_CODE (NODE) == FUNCTION_DECL		\
!    && DECL_LANG_FLAG_7 (NODE))
  
  /* Nonzero if NODE is a this pointer adjusting thunk.  */
  #define DECL_THIS_THUNK_P(NODE)			\
--- 1889,1902 ----
  /* Nonzero if NODE is a thunk, rather than an ordinary function.  */
  #define DECL_THUNK_P(NODE)			\
    (TREE_CODE (NODE) == FUNCTION_DECL		\
!    && DECL_LANG_SPECIFIC (NODE)			\
!    && DECL_LANG_SPECIFIC (NODE)->decl_flags.thunk_p)
!      
! /* Set DECL_THUNK_P for node.  */
! #define SET_DECL_THUNK_P(NODE, THIS_ADJUSTING)			\
!   (DECL_LANG_SPECIFIC (NODE)->decl_flags.thunk_p = 1,		\
!    DECL_LANG_SPECIFIC (NODE)->u.f.u3sel = 1,			\
!    DECL_LANG_SPECIFIC (NODE)->decl_flags.this_thunk_p = (THIS_ADJUSTING))
  
  /* Nonzero if NODE is a this pointer adjusting thunk.  */
  #define DECL_THIS_THUNK_P(NODE)			\
*************** struct lang_decl GTY(())
*** 1890,1901 ****
  #define DECL_EXTERN_C_FUNCTION_P(NODE) \
    (DECL_NON_THUNK_FUNCTION_P (NODE) && DECL_EXTERN_C_P (NODE))
  
- /* Set DECL_THUNK_P for node.  */
- #define SET_DECL_THUNK_P(NODE, THIS_ADJUSTING)			\
-   (DECL_LANG_FLAG_7 (NODE) = 1, 				\
-    DECL_LANG_SPECIFIC (NODE)->u.f.u3sel = 1,			\
-    DECL_LANG_SPECIFIC (NODE)->decl_flags.this_thunk_p = (THIS_ADJUSTING))
- 
  /* True iff DECL is an entity with vague linkage whose definition is
     available in this translation unit.  */
  #define DECL_REPO_AVAILABLE_P(NODE) \
--- 1918,1923 ----
*************** struct lang_decl GTY(())
*** 2807,2813 ****
  /* An integer indicating how many bytes should be subtracted from the
     this or result pointer when this function is called.  */
  #define THUNK_FIXED_OFFSET(DECL) \
!   (DECL_LANG_SPECIFIC (VAR_OR_FUNCTION_DECL_CHECK (DECL))->u.f.fixed_offset)
  
  /* A tree indicating how to perform the virtual adjustment. For a this
     adjusting thunk it is the number of bytes to be added to the vtable
--- 2829,2835 ----
  /* An integer indicating how many bytes should be subtracted from the
     this or result pointer when this function is called.  */
  #define THUNK_FIXED_OFFSET(DECL) \
!   (DECL_LANG_SPECIFIC (THUNK_FUNCTION_CHECK (DECL))->u.f.u5.fixed_offset)
  
  /* A tree indicating how to perform the virtual adjustment. For a this
     adjusting thunk it is the number of bytes to be added to the vtable
Index: cp/method.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/method.c,v
retrieving revision 1.316
diff -c -3 -p -r1.316 method.c
*** cp/method.c	5 Oct 2004 13:27:39 -0000	1.316
--- cp/method.c	5 Nov 2004 10:19:06 -0000
*************** make_thunk (tree function, bool this_adj
*** 150,157 ****
    DECL_SAVED_FUNCTION_DATA (thunk) = NULL;
    DECL_DESTRUCTOR_P (thunk) = 0;
    DECL_CONSTRUCTOR_P (thunk) = 0;
-   /* And neither is it a clone.  */
-   DECL_CLONED_FUNCTION (thunk) = NULL_TREE;
    DECL_EXTERNAL (thunk) = 1;
    DECL_ARTIFICIAL (thunk) = 1;
    /* Even if this thunk is a member of a local class, we don't
--- 150,155 ----

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