aboutsummaryrefslogtreecommitdiff
path: root/gdb/expread.y
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/expread.y')
-rwxr-xr-xgdb/expread.y70
1 files changed, 60 insertions, 10 deletions
diff --git a/gdb/expread.y b/gdb/expread.y
index 44b1b5c..6772d79 100755
--- a/gdb/expread.y
+++ b/gdb/expread.y
@@ -108,11 +108,18 @@ struct symtoken
An array should be preceded in the list by the size of the array. */
enum type_pieces
{tp_end = -1, tp_pointer, tp_reference, tp_array, tp_function};
-static enum type_pieces *type_stack;
+/* The stack can contain either an enum type_pieces or an int. */
+union type_stack_elt {
+ enum type_pieces piece;
+ int int_val;
+};
+static union type_stack_elt *type_stack;
static int type_stack_depth, type_stack_size;
static void push_type ();
+static void push_type_int ();
static enum type_pieces pop_type ();
+static int pop_type_int ();
/* Allow debugging of parsing. */
#define YYDEBUG 1
@@ -646,12 +653,33 @@ variable: name_not_typename
{
case LOC_REGISTER:
case LOC_ARG:
+ case LOC_REF_ARG:
+ case LOC_REGPARM:
case LOC_LOCAL:
case LOC_LOCAL_ARG:
if (innermost_block == 0 ||
contained_in (block_found,
innermost_block))
innermost_block = block_found;
+ case LOC_UNDEF:
+ case LOC_CONST:
+ case LOC_STATIC:
+ case LOC_TYPEDEF:
+ case LOC_LABEL:
+ case LOC_BLOCK:
+ case LOC_EXTERNAL:
+ case LOC_CONST_BYTES:
+
+ /* In this case the expression can
+ be evaluated regardless of what
+ frame we are in, so there is no
+ need to check for the
+ innermost_block. These cases are
+ listed so that gcc -Wall will
+ report types that may not have
+ been considered. */
+
+ break;
}
write_exp_elt_opcode (OP_VAR_VALUE);
write_exp_elt_sym (sym);
@@ -732,7 +760,7 @@ ptype : typebase
follow_type = lookup_reference_type (follow_type);
break;
case tp_array:
- array_size = (int) pop_type ();
+ array_size = pop_type_int ();
if (array_size != -1)
follow_type = create_array_type (follow_type,
array_size);
@@ -762,12 +790,12 @@ direct_abs_decl: '(' abs_decl ')'
{ $$ = $2; }
| direct_abs_decl array_mod
{
- push_type ((enum type_pieces) $2);
+ push_type_int ($2);
push_type (tp_array);
}
| array_mod
{
- push_type ((enum type_pieces) $1);
+ push_type_int ($1);
push_type (tp_array);
$$ = 0;
}
@@ -1915,25 +1943,47 @@ push_type (tp)
if (type_stack_depth == type_stack_size)
{
type_stack_size *= 2;
- type_stack = (enum type_pieces *)
- xrealloc (type_stack, type_stack_size * sizeof (enum type_pieces));
+ type_stack = (union type_stack_elt *)
+ xrealloc (type_stack, type_stack_size * sizeof (*type_stack));
+ }
+ type_stack[type_stack_depth++].piece = tp;
+}
+
+static void
+push_type_int (n)
+ int n;
+{
+ if (type_stack_depth == type_stack_size)
+ {
+ type_stack_size *= 2;
+ type_stack = (union type_stack_elt *)
+ xrealloc (type_stack, type_stack_size * sizeof (*type_stack));
}
- type_stack[type_stack_depth++] = tp;
+ type_stack[type_stack_depth++].int_val = n;
}
static enum type_pieces
pop_type ()
{
if (type_stack_depth)
- return type_stack[--type_stack_depth];
+ return type_stack[--type_stack_depth].piece;
return tp_end;
}
+static int
+pop_type_int ()
+{
+ if (type_stack_depth)
+ return type_stack[--type_stack_depth].int_val;
+ /* "Can't happen". */
+ return 0;
+}
+
void
_initialize_expread ()
{
type_stack_size = 80;
type_stack_depth = 0;
- type_stack = (enum type_pieces *)
- xmalloc (type_stack_size * sizeof (enum type_pieces));
+ type_stack = (union type_stack_elt *)
+ xmalloc (type_stack_size * sizeof (*type_stack));
}