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 to remove 0-operand cast mangling


My patch of September 6 added a new mangling for 0-operand casts such as T(). Since then that mangling has been dropped from the ABI as insufficiently general (we would need something else for 2+ operand casts) and isn't necessary now that we have the type stub mangling. So I'm removing it from the compiler and demangler as well.

Tested x86_64-pc-linux-gnu, applied to trunk.
2009-01-05  Jason Merrill  <jason@redhat.com>

	* gcc/cp/mangle.c (write_expression): Remove mangling for zero-operand
	casts.
	* libiberty/cp-demangle.c (d_expression): Remove mangling for zero-op
	casts.

Index: gcc/cp/mangle.c
===================================================================
*** gcc/cp/mangle.c	(revision 143080)
--- gcc/cp/mangle.c	(working copy)
*************** write_expression (tree expr)
*** 2348,2359 ****
  
  	case CAST_EXPR:
  	  write_type (TREE_TYPE (expr));
  	  if (!TREE_OPERAND (expr, 0))
! 	    /* "T()" is mangled as "T(void)".  */
! 	    write_char ('v');
  	  else if (list_length (TREE_OPERAND (expr, 0)) > 1)
- 	    /* FIXME the above hack for T() needs to be replaced with
- 	       something more general.  */
  	    sorry ("mangling function-style cast with more than one argument");
  	  else
  	    write_expression (TREE_VALUE (TREE_OPERAND (expr, 0)));
--- 2348,2359 ----
  
  	case CAST_EXPR:
  	  write_type (TREE_TYPE (expr));
+ 	  /* There is no way to mangle a zero-operand cast like
+ 	     "T()".  */
  	  if (!TREE_OPERAND (expr, 0))
! 	    sorry ("zero-operand casts cannot be mangled due to a defect "
! 		   "in the C++ ABI");
  	  else if (list_length (TREE_OPERAND (expr, 0)) > 1)
  	    sorry ("mangling function-style cast with more than one argument");
  	  else
  	    write_expression (TREE_VALUE (TREE_OPERAND (expr, 0)));
Index: libiberty/cp-demangle.c
===================================================================
*** libiberty/cp-demangle.c	(revision 143080)
--- libiberty/cp-demangle.c	(working copy)
*************** d_expression (struct d_info *di)
*** 2609,2620 ****
  	  args = op->u.s_extended_operator.args;
  	  break;
  	case DEMANGLE_COMPONENT_CAST:
! 	  if (d_peek_char (di) == 'v')
! 	    /* T() encoded as an operand of void.  */
! 	    return d_make_comp (di, DEMANGLE_COMPONENT_UNARY, op,
! 				cplus_demangle_type (di));
! 	  else
! 	    args = 1;
  	  break;
  	}
  
--- 2609,2615 ----
  	  args = op->u.s_extended_operator.args;
  	  break;
  	case DEMANGLE_COMPONENT_CAST:
! 	  args = 1;
  	  break;
  	}
  
*************** d_print_comp (struct d_print_info *dpi,
*** 3807,3818 ****
  	  d_print_cast (dpi, d_left (dc));
  	  d_append_char (dpi, ')');
  	}
!       if (d_left (dc)->type == DEMANGLE_COMPONENT_CAST
! 	  && d_right (dc)->type == DEMANGLE_COMPONENT_BUILTIN_TYPE)
! 	/* type() -- FIXME what about type(multiple,args) */
! 	d_append_string (dpi, "()");
!       else
! 	d_print_subexpr (dpi, d_right (dc));
        return;
  
      case DEMANGLE_COMPONENT_BINARY:
--- 3802,3808 ----
  	  d_print_cast (dpi, d_left (dc));
  	  d_append_char (dpi, ')');
  	}
!       d_print_subexpr (dpi, d_right (dc));
        return;
  
      case DEMANGLE_COMPONENT_BINARY:

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