From 0f5d3f636a606e307d8d8634415cc1e313a38273 Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Mon, 17 Dec 2018 13:51:05 +0000 Subject: [PATCH] gdb: Add new parser rule for structure field names Introduces a new rule in c-exp.y for matching structure field names. This is a restructure in preparation for the next commit, this commit shouldn't result in any user visible changes. gdb/ChangeLog: * c-exp.y (field_name): New %token, and new rule. (exp): Replace uses of 'name' with 'field_name' where appropriate. --- gdb/ChangeLog | 5 +++++ gdb/c-exp.y | 13 ++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ced5180..5c5699e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2018-12-24 Andrew Burgess + * c-exp.y (field_name): New %token, and new rule. + (exp): Replace uses of 'name' with 'field_name' where appropriate. + +2018-12-24 Andrew Burgess + PR gdb/13368 * c-exp.y (typebase): Extend the comment. (ident_tokens): Likewise. diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 447ac78..98a0df3 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -156,7 +156,7 @@ static void c_print_token (FILE *file, int type, YYSTYPE value); %token COMPLETE %token TYPENAME %token CLASSNAME /* ObjC Class name */ -%type name +%type name field_name %type string_exp %type name_not_typename %type type_name @@ -312,13 +312,13 @@ exp : ALIGNOF '(' type_exp ')' %prec UNARY { write_exp_elt_opcode (pstate, UNOP_ALIGNOF); } ; -exp : exp ARROW name +exp : exp ARROW field_name { write_exp_elt_opcode (pstate, STRUCTOP_PTR); write_exp_string (pstate, $3); write_exp_elt_opcode (pstate, STRUCTOP_PTR); } ; -exp : exp ARROW name COMPLETE +exp : exp ARROW field_name COMPLETE { mark_struct_expression (pstate); write_exp_elt_opcode (pstate, STRUCTOP_PTR); write_exp_string (pstate, $3); @@ -360,13 +360,13 @@ exp : exp ARROW_STAR exp { write_exp_elt_opcode (pstate, STRUCTOP_MPTR); } ; -exp : exp '.' name +exp : exp '.' field_name { write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); write_exp_string (pstate, $3); write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); } ; -exp : exp '.' name COMPLETE +exp : exp '.' field_name COMPLETE { mark_struct_expression (pstate); write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); write_exp_string (pstate, $3); @@ -1646,6 +1646,9 @@ oper: OPERATOR NEW ; +field_name + : name + ; name : NAME { $$ = $1.stoken; } | BLOCKNAME { $$ = $1.stoken; } -- 2.7.4