aboutsummaryrefslogtreecommitdiff
path: root/gdb/c-exp.y
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2012-07-06 14:44:22 +0000
committerTom Tromey <tromey@redhat.com>2012-07-06 14:44:22 +0000
commitfcde5961ebacc85a85adcf858c751dc9c11f8d58 (patch)
treeaa3300bf1a72493745909459933cefb0256899f8 /gdb/c-exp.y
parent1a7d0ce4eb4d724a3853500b45b379e746d7077a (diff)
downloadgdb-fcde5961ebacc85a85adcf858c751dc9c11f8d58.zip
gdb-fcde5961ebacc85a85adcf858c751dc9c11f8d58.tar.gz
gdb-fcde5961ebacc85a85adcf858c751dc9c11f8d58.tar.bz2
* c-exp.y (%union) <type_stack>: New field.
(abs_decl, direct_abs_decl): Use <type_stack> type. Update. (ptr_operator_ts): New production. (ptype): Update. * parse.c (type_stack_reserve): New function. (check_type_stack_depth): Use it. (pop_type_stack, append_type_stack, push_type_stack) (get_type_stack, type_stack_cleanup): New functions. (follow_types): Handle tp_type_stack. (_initialize_parse): Simplify initialization. * parser-defs.h (enum type_pieces) <tp_type_stack>: New constant. (union type_stack_elt) <stack_val>: New field. (get_type_stack, append_type_stack, push_type_stack) (type_stack_cleanup): Declare. testsuite * gdb.base/whatis.exp: Add tests.
Diffstat (limited to 'gdb/c-exp.y')
-rw-r--r--gdb/c-exp.y38
1 files changed, 33 insertions, 5 deletions
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index f86f76f..5ea5704 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -157,6 +157,8 @@ void yyerror (char *);
struct stoken_vector svec;
struct type **tvec;
int *ivec;
+
+ struct type_stack *type_stack;
}
%{
@@ -176,6 +178,8 @@ static struct stoken operator_stoken (const char *);
%type <lval> array_mod
%type <tval> conversion_type_id
+%type <type_stack> ptr_operator_ts abs_decl direct_abs_decl
+
%token <typed_val_int> INT
%token <typed_val_float> FLOAT
%token <typed_val_decfloat> DECFLOAT
@@ -963,27 +967,48 @@ ptr_operator:
{ insert_type (tp_reference); }
;
-abs_decl: ptr_operator direct_abs_decl
- | ptr_operator
+ptr_operator_ts: ptr_operator
+ {
+ $$ = get_type_stack ();
+ /* This cleanup is eventually run by
+ c_parse. */
+ make_cleanup (type_stack_cleanup, $$);
+ }
+ ;
+
+abs_decl: ptr_operator_ts direct_abs_decl
+ { $$ = append_type_stack ($2, $1); }
+ | ptr_operator_ts
| direct_abs_decl
;
direct_abs_decl: '(' abs_decl ')'
+ { $$ = $2; }
| direct_abs_decl array_mod
{
+ push_type_stack ($1);
push_type_int ($2);
push_type (tp_array);
+ $$ = get_type_stack ();
}
| array_mod
{
push_type_int ($1);
push_type (tp_array);
+ $$ = get_type_stack ();
}
| direct_abs_decl func_mod
- { push_type (tp_function); }
+ {
+ push_type_stack ($1);
+ push_type (tp_function);
+ $$ = get_type_stack ();
+ }
| func_mod
- { push_type (tp_function); }
+ {
+ push_type (tp_function);
+ $$ = get_type_stack ();
+ }
;
array_mod: '[' ']'
@@ -1206,7 +1231,10 @@ nonempty_typelist
ptype : typebase
| ptype abs_decl
- { $$ = follow_types ($1); }
+ {
+ push_type_stack ($2);
+ $$ = follow_types ($1);
+ }
;
conversion_type_id: typebase conversion_declarator