* gdbtypes.c, ch-lang.c, ch-typeprint.c (numerous places):
Add check_typedef/CHECK_TYPEDEF as needed.
+ * alpha-tdep.c, c-exp.y, h8500-tdep.c, f-exp.y, f-valprint.c,
+ findvar.c, hppa-tdep.c, infcmd.c, language.c, printcmd.c,
+ rs6000-tdep.c, symmisc.c, symtab.c:
+ Add check_typedef/CHECK_TYPEDEF as needed.
+
* top.c (command_line_input): Only strip out an initial #-comment.
Looking for internal comments is language-specific (breaks Scheme).
for (i = 0, m_arg = alpha_args; i < nargs; i++, m_arg++)
{
value_ptr arg = args[i];
+ struct type *arg_type = check_typedef (VALUE_TYPE (arg));
/* Cast argument to long if necessary as the compiler does it too. */
- switch (TYPE_CODE (VALUE_TYPE (arg)))
+ switch (TYPE_CODE (arg_type))
{
case TYPE_CODE_INT:
case TYPE_CODE_BOOL:
case TYPE_CODE_CHAR:
case TYPE_CODE_RANGE:
case TYPE_CODE_ENUM:
- if (TYPE_LENGTH (VALUE_TYPE (arg)) < TYPE_LENGTH (builtin_type_long))
- arg = value_cast (builtin_type_long, arg);
+ if (TYPE_LENGTH (arg_type) < TYPE_LENGTH (builtin_type_long))
+ {
+ arg_type = builtin_type_long;
+ arg = value_cast (arg_type, arg);
+ }
break;
default:
break;
}
- m_arg->len = TYPE_LENGTH (VALUE_TYPE (arg));
+ m_arg->len = TYPE_LENGTH (arg_type);
m_arg->offset = accumulate_size;
accumulate_size = (accumulate_size + m_arg->len + 7) & ~7;
m_arg->contents = VALUE_CONTENTS(arg);
exp : SIZEOF '(' type ')' %prec UNARY
{ write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (builtin_type_int);
+ CHECK_TYPEDEF ($3);
write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
write_exp_elt_opcode (OP_LONG); }
;
exp : SIZEOF '(' type ')' %prec UNARY
{ write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (builtin_type_f_integer);
+ CHECK_TYPEDEF ($3);
write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
write_exp_elt_opcode (OP_LONG); }
;
/* Patch in a valid length value. */
TYPE_LENGTH (type) =
- (upper_bound - lower_bound + 1) * TYPE_LENGTH (TYPE_TARGET_TYPE (type));
+ (upper_bound - lower_bound + 1) * TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type)));
}
/* Function that sets up the array offset,size table for the array
LONGEST val;
CORE_ADDR addr;
+ CHECK_TYPEDEF (type);
switch (TYPE_CODE (type))
{
case TYPE_CODE_STRING:
else
{
addr = unpack_pointer (type, valaddr);
- elttype = TYPE_TARGET_TYPE (type);
+ elttype = check_typedef (TYPE_TARGET_TYPE (type));
if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
{
struct type *type;
enum type_code newval_type_code;
- type = VALUE_TYPE (newval);
+ type = check_typedef (VALUE_TYPE (newval));
newval_type_code = TYPE_CODE (type);
if ((newval_type_code != TYPE_CODE_INT
&& newval_type_code != TYPE_CODE_PTR)
|| TYPE_LENGTH (type) != sizeof (new_regval))
error ("Illegal type (%s) for assignment to $%s\n",
- TYPE_NAME (type), var->name);
+ TYPE_NAME (VALUE_TYPE (newval)), var->name);
new_regval = *(long *) VALUE_CONTENTS_RAW (newval);
alignment required by their fields. */
static int
-hppa_alignof (arg)
- struct type *arg;
+hppa_alignof (type)
+ struct type *type;
{
int max_align, align, i;
- switch (TYPE_CODE (arg))
+ CHECK_TYPEDEf (type);
+ switch (TYPE_CODE (type))
{
case TYPE_CODE_PTR:
case TYPE_CODE_INT:
case TYPE_CODE_FLT:
- return TYPE_LENGTH (arg);
+ return TYPE_LENGTH (type);
case TYPE_CODE_ARRAY:
- return hppa_alignof (TYPE_FIELD_TYPE (arg, 0));
+ return hppa_alignof (TYPE_FIELD_TYPE (type, 0));
case TYPE_CODE_STRUCT:
case TYPE_CODE_UNION:
max_align = 2;
- for (i = 0; i < TYPE_NFIELDS (arg); i++)
+ for (i = 0; i < TYPE_NFIELDS (type); i++)
{
/* Bit fields have no real alignment. */
- if (!TYPE_FIELD_BITPOS (arg, i))
+ if (!TYPE_FIELD_BITPOS (type, i))
{
- align = hppa_alignof (TYPE_FIELD_TYPE (arg, i));
+ align = hppa_alignof (TYPE_FIELD_TYPE (type, i));
max_align = max (max_align, align);
}
}
binop_result_type (v1, v2)
value_ptr v1, v2;
{
- int l1,l2,size,uns;
+ int size,uns;
+ struct type *t1 = check_typedef (VALUE_TYPE (v1));
+ struct type *t2 = check_typedef (VALUE_TYPE (v2));
- l1 = TYPE_LENGTH(VALUE_TYPE(v1));
- l2 = TYPE_LENGTH(VALUE_TYPE(v2));
+ int l1 = TYPE_LENGTH (t1);
+ int l2 = TYPE_LENGTH (t2);
switch(current_language->la_language)
{
case language_c:
case language_cplus:
- if (TYPE_CODE(VALUE_TYPE(v1))==TYPE_CODE_FLT)
- return TYPE_CODE(VALUE_TYPE(v2)) == TYPE_CODE_FLT && l2 > l1 ?
+ if (TYPE_CODE (t1)==TYPE_CODE_FLT)
+ return TYPE_CODE(t2) == TYPE_CODE_FLT && l2 > l1 ?
VALUE_TYPE(v2) : VALUE_TYPE(v1);
- else if (TYPE_CODE(VALUE_TYPE(v2))==TYPE_CODE_FLT)
- return TYPE_CODE(VALUE_TYPE(v1)) == TYPE_CODE_FLT && l1 > l2 ?
+ else if (TYPE_CODE(t2)==TYPE_CODE_FLT)
+ return TYPE_CODE(t1)) == TYPE_CODE_FLT && l1 > l2 ?
VALUE_TYPE(v1) : VALUE_TYPE(v2);
- else if (TYPE_UNSIGNED(VALUE_TYPE(v1)) && l1 > l2)
+ else if (TYPE_UNSIGNED(t1) && l1 > l2)
return VALUE_TYPE(v1);
- else if (TYPE_UNSIGNED(VALUE_TYPE(v2)) && l2 > l1)
+ else if (TYPE_UNSIGNED(t2) && l2 > l1)
return VALUE_TYPE(v2);
else /* Both are signed. Result is the longer type */
return l1 > l2 ? VALUE_TYPE(v1) : VALUE_TYPE(v2);
return form;
}
\f
+#if 0
/* This page contains functions that are used in type/range checking.
They all return zero if the type/range check fails.
simple_type(type)
struct type *type;
{
+ CHECK_TYPEDEF (type);
switch (TYPE_CODE (type)) {
case TYPE_CODE_INT:
case TYPE_CODE_CHAR:
ordered_type (type)
struct type *type;
{
+ CHECK_TYPEDEF (type);
switch (TYPE_CODE (type)) {
case TYPE_CODE_INT:
case TYPE_CODE_CHAR:
same_type (arg1, arg2)
struct type *arg1, *arg2;
{
+ CHECK_TYPEDEF (type);
if (structured_type(arg1) ? !structured_type(arg2) : structured_type(arg2))
/* One is structured and one isn't */
return 0;
integral_type (type)
struct type *type;
{
+ CHECK_TYPEDEF (type);
switch(current_language->la_language)
{
case language_c:
numeric_type (type)
struct type *type;
{
+ CHECK_TYPEDEF (type);
switch (TYPE_CODE (type)) {
case TYPE_CODE_INT:
case TYPE_CODE_FLT:
character_type (type)
struct type *type;
{
- switch(current_language->la_language)
+ CHECK_TYPEDEF (type);
+ switch(current_language->la_language)
{
case language_chill:
case language_m2:
string_type (type)
struct type *type;
{
- switch(current_language->la_language)
+ CHECK_TYPEDEF (type);
+ switch(current_language->la_language)
{
case language_chill:
case language_m2:
boolean_type (type)
struct type *type;
{
+ CHECK_TYPEDEF (type);
if (TYPE_CODE (type) == TYPE_CODE_BOOL)
return 1;
switch(current_language->la_language)
float_type (type)
struct type *type;
{
- return TYPE_CODE(type) == TYPE_CODE_FLT;
+ CHECK_TYPEDEF (type);
+ return TYPE_CODE(type) == TYPE_CODE_FLT;
}
/* Returns non-zero if the value is a pointer type */
structured_type(type)
struct type *type;
{
+ CHECK_TYPEDEF (type);
switch(current_language->la_language)
{
case language_c:
return (0);
}
}
+#endif
\f
/* This page contains functions that return info about
(struct value) values used in GDB. */
int argno; /* current argument number */
int argbytes; /* current argument byte */
char tmp_buffer [50];
- value_ptr arg;
int f_argno = 0; /* current floating point argno */
+ value_ptr arg;
+ struct type *type;
CORE_ADDR saved_sp, pc;
for (argno=0, argbytes=0; argno < nargs && ii<8; ++ii) {
arg = args[argno];
- len = TYPE_LENGTH (VALUE_TYPE (arg));
+ type = check_typedef (VALUE_TYPE (arg);
+ len = TYPE_LENGTH (type);
- if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_FLT) {
+ if (TYPE_CODE (type) == TYPE_CODE_FLT) {
/* floating point arguments are passed in fpr's, as well as gpr's.
There are 13 fpr's reserved for passing parameters. At this point
if ((argno < nargs) || argbytes) {
int space = 0, jj;
- value_ptr val;
if (argbytes) {
space += ((len - argbytes + 3) & -4);
jj = argno;
for (; jj < nargs; ++jj) {
- val = args[jj];
+ value_ptr val = args[jj];
space += ((TYPE_LENGTH (VALUE_TYPE (val))) + 3) & -4;
}
for (; argno < nargs; ++argno) {
arg = args[argno];
- len = TYPE_LENGTH (VALUE_TYPE (arg));
+ type = check_typedef (VALUE_TYPE (arg));
+ len = TYPE_LENGTH (type);
/* float types should be passed in fpr's, as well as in the stack. */
- if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_FLT && f_argno < 13) {
+ if (TYPE_CODE (type) == TYPE_CODE_FLT && f_argno < 13) {
if (len > 8)
printf_unfiltered (
int n;
int count;
- check_stub_type (type);
+ CHECK_TYPEDEF (type);
count = TYPE_NFN_FIELDS_TOTAL (type);
for (n = 0; n < TYPE_N_BASECLASSES (type); n++)
(struct symtab **)NULL)))
{
int method_counter;
- /* FIXME: Shouldn't this just be check_stub_type (t)? */
+ /* FIXME: Shouldn't this just be CHECK_TYPEDEF (t)? */
t = SYMBOL_TYPE (sym_class);
for (method_counter = TYPE_NFN_FIELDS (t) - 1;
method_counter >= 0;
(struct symtab **)NULL);
if (sym_class &&
- ( TYPE_CODE (SYMBOL_TYPE (sym_class)) == TYPE_CODE_STRUCT
- || TYPE_CODE (SYMBOL_TYPE (sym_class)) == TYPE_CODE_UNION))
+ (t = check_typedef (SYMBOL_TYPE (sym_class)),
+ (TYPE_CODE (t) == TYPE_CODE_STRUCT
+ || TYPE_CODE (t) == TYPE_CODE_UNION)))
{
/* Arg token is not digits => try it as a function name
Find the next token(everything up to end or next blank). */
sym = 0;
i1 = 0; /* counter for the symbol array */
- t = SYMBOL_TYPE (sym_class);
sym_arr = (struct symbol **) alloca(total_number_of_methods (t)
* sizeof(struct symbol *));