diff options
author | Tom Tromey <tromey@redhat.com> | 2012-06-19 19:49:42 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2012-06-19 19:49:42 +0000 |
commit | 95c391b64aafe6d8868a99dd476e6f110011dd2d (patch) | |
tree | 10fb350b0855dab2a352174353005d4775911086 /gdb/c-exp.y | |
parent | e910f0b61f40b0fcbbba3607dbe3e153f45e00d4 (diff) | |
download | gdb-95c391b64aafe6d8868a99dd476e6f110011dd2d.zip gdb-95c391b64aafe6d8868a99dd476e6f110011dd2d.tar.gz gdb-95c391b64aafe6d8868a99dd476e6f110011dd2d.tar.bz2 |
PR exp/9514:
* parser-defs.h (insert_type, insert_type_address_space): Declare.
(push_type_address_space): Remove.
* parse.c (insert_into_type_stack): New function.
(insert_type): Likewise.
(insert_type_address_space): Rename from push_type_address_space.
Insert tp_space_identifier.
* c-exp.y (ptr_operator): New production.
(abs_decl): Use ptr_operator.
(space_identifier): Call insert_type_address_space.
(ptype): Don't use const_or_volatile_or_space_identifier.
(const_or_volatile_noopt): Call insert_type.
(conversion_type_id, conversion_declarator): New productions.
(operator): Use conversion_type_id.
testsuite
* gdb.base/whatis.exp: Add tests.
Diffstat (limited to 'gdb/c-exp.y')
-rw-r--r-- | gdb/c-exp.y | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/gdb/c-exp.y b/gdb/c-exp.y index bf53fbc..7afce77 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -172,9 +172,10 @@ static struct stoken operator_stoken (const char *); /* %type <bval> block */ /* Fancy type parsing. */ -%type <voidval> func_mod direct_abs_decl abs_decl +%type <voidval> func_mod direct_abs_decl abs_decl ptr_operator %type <tval> ptype %type <lval> array_mod +%type <tval> conversion_type_id %token <typed_val_int> INT %token <typed_val_float> FLOAT @@ -931,9 +932,7 @@ variable: name_not_typename ; space_identifier : '@' NAME - { push_type_address_space (copy_name ($2.stoken)); - push_type (tp_space_identifier); - } + { insert_type_address_space (copy_name ($2.stoken)); } ; const_or_volatile: const_or_volatile_noopt @@ -952,14 +951,23 @@ const_or_volatile_or_space_identifier: | ; -abs_decl: '*' - { push_type (tp_pointer); $$ = 0; } - | '*' abs_decl - { push_type (tp_pointer); $$ = $2; } +ptr_operator: + ptr_operator '*' + { insert_type (tp_pointer); } + const_or_volatile_or_space_identifier + { $$ = 0; } + | '*' + { insert_type (tp_pointer); } + const_or_volatile_or_space_identifier + { $$ = 0; } | '&' - { push_type (tp_reference); $$ = 0; } - | '&' abs_decl - { push_type (tp_reference); $$ = $2; } + { insert_type (tp_reference); $$ = 0; } + | '&' ptr_operator + { insert_type (tp_reference); $$ = 0; } + ; + +abs_decl: ptr_operator direct_abs_decl + | ptr_operator | direct_abs_decl ; @@ -1203,22 +1211,30 @@ nonempty_typelist ; ptype : typebase - | ptype const_or_volatile_or_space_identifier abs_decl const_or_volatile_or_space_identifier + | ptype abs_decl { $$ = follow_types ($1); } ; +conversion_type_id: typebase conversion_declarator + { $$ = follow_types ($1); } + ; + +conversion_declarator: /* Nothing. */ + | ptr_operator conversion_declarator + ; + const_and_volatile: CONST_KEYWORD VOLATILE_KEYWORD | VOLATILE_KEYWORD CONST_KEYWORD ; const_or_volatile_noopt: const_and_volatile - { push_type (tp_const); - push_type (tp_volatile); + { insert_type (tp_const); + insert_type (tp_volatile); } | CONST_KEYWORD - { push_type (tp_const); } + { insert_type (tp_const); } | VOLATILE_KEYWORD - { push_type (tp_volatile); } + { insert_type (tp_volatile); } ; operator: OPERATOR NEW @@ -1325,7 +1341,7 @@ operator: OPERATOR NEW { $$ = operator_stoken ("()"); } | OPERATOR '[' ']' { $$ = operator_stoken ("[]"); } - | OPERATOR ptype + | OPERATOR conversion_type_id { char *name; long length; struct ui_file *buf = mem_fileopen (); |