if (hp_som_som_object_present &&	 (code2 == TYPE_CODE_PTR))
if (deprecated_hp_som_som_object_present	 && (code2 == TYPE_CODE_PTR))
value_cast (struct type *type, struct value *arg2){  enum type_code code1;  enum type_code code2;  int scalar;  struct type *type2;  int convert_to_boolean = 0;  if (VALUE_TYPE (arg2) == type)    return arg2;  CHECK_TYPEDEF (type);  code1 = TYPE_CODE (type);  COERCE_REF (arg2);  type2 = check_typedef (VALUE_TYPE (arg2));  /* A cast to an undetermined-length array_type, such as (TYPE [])OBJECT,     is treated like a cast to (TYPE [N])OBJECT,     where N is sizeof(OBJECT)/sizeof(TYPE). */  if (code1 == TYPE_CODE_ARRAY)    {      struct type *element_type = TYPE_TARGET_TYPE (type);      unsigned element_length = TYPE_LENGTH (check_typedef (element_type));      if (element_length > 0	&& TYPE_ARRAY_UPPER_BOUND_TYPE (type) == BOUND_CANNOT_BE_DETERMINED)	{	  struct type *range_type = TYPE_INDEX_TYPE (type);	  int val_length = TYPE_LENGTH (type2);	  LONGEST low_bound, high_bound, new_length;	  if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0)	    low_bound = 0, high_bound = 0;	  new_length = val_length / element_length;	  if (val_length % element_length != 0)	    warning ("array element type size does not divide object size in cast");	  /* FIXME-type-allocation: need a way to free this type when we are	     done with it.  */	  range_type = create_range_type ((struct type *) NULL,					  TYPE_TARGET_TYPE (range_type),					  low_bound,					  new_length + low_bound - 1);	  VALUE_TYPE (arg2) = create_array_type ((struct type *) NULL,						 element_type, range_type);	  return arg2;	}    }  if (current_language->c_style_arrays      && TYPE_CODE (type2) == TYPE_CODE_ARRAY)    arg2 = value_coerce_array (arg2);  if (TYPE_CODE (type2) == TYPE_CODE_FUNC)    arg2 = value_coerce_function (arg2);  type2 = check_typedef (VALUE_TYPE (arg2));  COERCE_VARYING_ARRAY (arg2, type2);  code2 = TYPE_CODE (type2);  if (code1 == TYPE_CODE_COMPLEX)    return cast_into_complex (type, arg2);  if (code1 == TYPE_CODE_BOOL)    {      code1 = TYPE_CODE_INT;      convert_to_boolean = 1;    }  if (code1 == TYPE_CODE_CHAR)    code1 = TYPE_CODE_INT;  if (code2 == TYPE_CODE_BOOL || code2 == TYPE_CODE_CHAR)    code2 = TYPE_CODE_INT;  scalar = (code2 == TYPE_CODE_INT || code2 == TYPE_CODE_FLT	    || code2 == TYPE_CODE_ENUM || code2 == TYPE_CODE_RANGE);  if (code1 == TYPE_CODE_STRUCT      && code2 == TYPE_CODE_STRUCT      && TYPE_NAME (type) != 0)    {      /* Look in the type of the source to see if it contains the         type of the target as a superclass.  If so, we'll need to         offset the object in addition to changing its type.  */      struct value *v = search_struct_field (type_name_no_tag (type),					 arg2, 0, type2, 1);      if (v)	{	  VALUE_TYPE (v) = type;	  return v;	}    }  if (code1 == TYPE_CODE_FLT && scalar)    return value_from_double (type, value_as_double (arg2));  else if ((code1 == TYPE_CODE_INT || code1 == TYPE_CODE_ENUM	    || code1 == TYPE_CODE_RANGE)	   && (scalar || code2 == TYPE_CODE_PTR))    {      LONGEST longest;      if (hp_som_som_object_present &&	/* if target compiled by HP aCC */	  (code2 == TYPE_CODE_PTR))	{	  unsigned int *ptr;	  struct value *retvalp;	  switch (TYPE_CODE (TYPE_TARGET_TYPE (type2)))	    {	      /* With HP aCC, pointers to data members have a bias */	    case TYPE_CODE_MEMBER:	      retvalp = value_from_longest (type, value_as_long (arg2));	      /* force evaluation */	      ptr = (unsigned int *) VALUE_CONTENTS (retvalp);	      *ptr &= ~0x20000000;	/* zap 29th bit to remove bias */	      return retvalp;	      /* While pointers to methods don't really point to a function */	    case TYPE_CODE_METHOD:	      error ("Pointers to methods not supported with HP aCC");	    default:	      break;		/* fall out and go to normal handling */	    }	}      /* When we cast pointers to integers, we mustn't use         POINTER_TO_ADDRESS to find the address the pointer         represents, as value_as_long would.  GDB should evaluate         expressions just as the compiler would --- and the compiler         sees a cast as a simple reinterpretation of the pointer's         bits.  */      if (code2 == TYPE_CODE_PTR)        longest = extract_unsigned_integer (VALUE_CONTENTS (arg2),                                            TYPE_LENGTH (type2));      else        longest = value_as_long (arg2);      return value_from_longest (type, convert_to_boolean ?				 (LONGEST) (longest ? 1 : 0) : longest);    }  else if (code1 == TYPE_CODE_PTR && (code2 == TYPE_CODE_INT  ||				      code2 == TYPE_CODE_ENUM ||				      code2 == TYPE_CODE_RANGE))    {      /* TYPE_LENGTH (type) is the length of a pointer, but we really	 want the length of an address! -- we are really dealing with	 addresses (i.e., gdb representations) not pointers (i.e.,	 target representations) here.	 This allows things like "print *(int *)0x01000234" to work	 without printing a misleading message -- which would	 otherwise occur when dealing with a target having two byte	 pointers and four byte addresses.  */      int addr_bit = TARGET_ADDR_BIT;      LONGEST longest = value_as_long (arg2);      if (addr_bit < sizeof (LONGEST) * HOST_CHAR_BIT)	{	  if (longest >= ((LONGEST) 1 << addr_bit)	      || longest <= -((LONGEST) 1 << addr_bit))	    warning ("value truncated");	}      return value_from_longest (type, longest);    }  else if (TYPE_LENGTH (type) == TYPE_LENGTH (type2))    {      if (code1 == TYPE_CODE_PTR && code2 == TYPE_CODE_PTR)	{	  struct type *t1 = check_typedef (TYPE_TARGET_TYPE (type));	  struct type *t2 = check_typedef (TYPE_TARGET_TYPE (type2));	  if (TYPE_CODE (t1) == TYPE_CODE_STRUCT	      && TYPE_CODE (t2) == TYPE_CODE_STRUCT	      && !value_logical_not (arg2))	    {	      struct value *v;	      /* Look in the type of the source to see if it contains the	         type of the target as a superclass.  If so, we'll need to	         offset the pointer rather than just change its type.  */	      if (TYPE_NAME (t1) != NULL)		{		  v = search_struct_field (type_name_no_tag (t1),					   value_ind (arg2), 0, t2, 1);		  if (v)		    {		      v = value_addr (v);		      VALUE_TYPE (v) = type;		      return v;		    }		}	      /* Look in the type of the target to see if it contains the	         type of the source as a superclass.  If so, we'll need to	         offset the pointer rather than just change its type.	         FIXME: This fails silently with virtual inheritance.  */	      if (TYPE_NAME (t2) != NULL)		{		  v = search_struct_field (type_name_no_tag (t2),				       value_zero (t1, not_lval), 0, t1, 1);		  if (v)		    {                      CORE_ADDR addr2 = value_as_address (arg2);                      addr2 -= (VALUE_ADDRESS (v)                                + VALUE_OFFSET (v)                                + VALUE_EMBEDDED_OFFSET (v));                      return value_from_pointer (type, addr2);		    }		}	    }	  /* No superclass found, just fall through to change ptr type.  */	}      VALUE_TYPE (arg2) = type;      arg2 = value_change_enclosing_type (arg2, type);      VALUE_POINTED_TO_OFFSET (arg2) = 0;	/* pai: chk_val */      return arg2;    }  else if (VALUE_LVAL (arg2) == lval_memory)    {      return value_at_lazy (type, VALUE_ADDRESS (arg2) + VALUE_OFFSET (arg2),			    VALUE_BFD_SECTION (arg2));    }  else if (code1 == TYPE_CODE_VOID)    {      return value_zero (builtin_type_void, not_lval);    }  else    {      error ("Invalid cast.");      return 0;    }}