diff options
Diffstat (limited to 'gdb/c-exp.y')
-rw-r--r-- | gdb/c-exp.y | 105 |
1 files changed, 55 insertions, 50 deletions
diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 3ea544d8efa..59cecb5f3ff 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -923,8 +923,8 @@ exp : FALSEKEYWORD block : BLOCKNAME { - if ($1.sym) - $$ = SYMBOL_BLOCK_VALUE ($1.sym); + if ($1.sym.symbol) + $$ = SYMBOL_BLOCK_VALUE ($1.sym.symbol); else error (_("No file or function \"%s\"."), copy_name ($1.stoken)); @@ -938,7 +938,8 @@ block : BLOCKNAME block : block COLONCOLON name { struct symbol *tem = lookup_symbol (copy_name ($3), $1, - VAR_DOMAIN, NULL); + VAR_DOMAIN, NULL).symbol; + if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK) error (_("No function \"%s\" in specified context."), copy_name ($3)); @@ -946,7 +947,7 @@ block : block COLONCOLON name ; variable: name_not_typename ENTRY - { struct symbol *sym = $1.sym; + { struct symbol *sym = $1.sym.symbol; if (sym == NULL || !SYMBOL_IS_ARGUMENT (sym) || !symbol_read_needs_frame (sym)) @@ -961,24 +962,24 @@ variable: name_not_typename ENTRY ; variable: block COLONCOLON name - { struct symbol *sym; - sym = lookup_symbol (copy_name ($3), $1, - VAR_DOMAIN, NULL); - if (sym == 0) + { struct block_symbol sym + = lookup_symbol (copy_name ($3), $1, + VAR_DOMAIN, NULL); + + if (sym.symbol == 0) error (_("No symbol \"%s\" in specified context."), copy_name ($3)); - if (symbol_read_needs_frame (sym)) + if (symbol_read_needs_frame (sym.symbol)) { if (innermost_block == 0 - || contained_in (block_found, + || contained_in (sym.block, innermost_block)) - innermost_block = block_found; + innermost_block = sym.block; } write_exp_elt_opcode (pstate, OP_VAR_VALUE); - /* block_found is set by lookup_symbol. */ - write_exp_elt_block (pstate, block_found); - write_exp_elt_sym (pstate, sym); + write_exp_elt_block (pstate, sym.block); + write_exp_elt_sym (pstate, sym.symbol); write_exp_elt_opcode (pstate, OP_VAR_VALUE); } ; @@ -1035,9 +1036,9 @@ variable: qualified_name struct symbol *sym; struct bound_minimal_symbol msymbol; - sym = - lookup_symbol (name, (const struct block *) NULL, - VAR_DOMAIN, NULL); + sym + = lookup_symbol (name, (const struct block *) NULL, + VAR_DOMAIN, NULL).symbol; if (sym) { write_exp_elt_opcode (pstate, OP_VAR_VALUE); @@ -1058,16 +1059,16 @@ variable: qualified_name ; variable: name_not_typename - { struct symbol *sym = $1.sym; + { struct block_symbol sym = $1.sym; - if (sym) + if (sym.symbol) { - if (symbol_read_needs_frame (sym)) + if (symbol_read_needs_frame (sym.symbol)) { if (innermost_block == 0 - || contained_in (block_found, + || contained_in (sym.block, innermost_block)) - innermost_block = block_found; + innermost_block = sym.block; } write_exp_elt_opcode (pstate, OP_VAR_VALUE); @@ -1075,7 +1076,7 @@ variable: name_not_typename another more inner frame which happens to be in the same block. */ write_exp_elt_block (pstate, NULL); - write_exp_elt_sym (pstate, sym); + write_exp_elt_sym (pstate, sym.symbol); write_exp_elt_opcode (pstate, OP_VAR_VALUE); } else if ($1.is_a_field_of_this) @@ -1084,9 +1085,9 @@ variable: name_not_typename not inadvertently convert from a method call to data ref. */ if (innermost_block == 0 - || contained_in (block_found, + || contained_in (sym.block, innermost_block)) - innermost_block = block_found; + innermost_block = sym.block; write_exp_elt_opcode (pstate, OP_THIS); write_exp_elt_opcode (pstate, OP_THIS); write_exp_elt_opcode (pstate, STRUCTOP_PTR); @@ -2817,7 +2818,7 @@ lex_one_token (struct parser_state *par_state, int *is_quoted_name) VAR_DOMAIN, (parse_language (par_state)->la_language == language_cplus ? &is_a_field_of_this - : NULL)) + : NULL)).symbol != NULL) { /* The keyword is shadowed. */ @@ -2838,7 +2839,8 @@ lex_one_token (struct parser_state *par_state, int *is_quoted_name) saw_name_at_eof = 1; yylval.ssym.stoken = yylval.sval; - yylval.ssym.sym = NULL; + yylval.ssym.sym.symbol = NULL; + yylval.ssym.sym.block = NULL; yylval.ssym.is_a_field_of_this = 0; return NAME; } @@ -2873,7 +2875,7 @@ static int classify_name (struct parser_state *par_state, const struct block *block, int is_quoted_name) { - struct symbol *sym; + struct block_symbol bsym; char *copy; struct field_of_this_result is_a_field_of_this; @@ -2883,17 +2885,17 @@ classify_name (struct parser_state *par_state, const struct block *block, we can refer to it unconditionally below. */ memset (&is_a_field_of_this, 0, sizeof (is_a_field_of_this)); - sym = lookup_symbol (copy, block, VAR_DOMAIN, - parse_language (par_state)->la_name_of_this - ? &is_a_field_of_this : NULL); + bsym = lookup_symbol (copy, block, VAR_DOMAIN, + parse_language (par_state)->la_name_of_this + ? &is_a_field_of_this : NULL); - if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK) + if (bsym.symbol && SYMBOL_CLASS (bsym.symbol) == LOC_BLOCK) { - yylval.ssym.sym = sym; + yylval.ssym.sym = bsym; yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL; return BLOCKNAME; } - else if (!sym) + else if (!bsym.symbol) { /* If we found a field of 'this', we might have erroneously found a constructor where we wanted a type name. Handle this @@ -2906,11 +2908,11 @@ classify_name (struct parser_state *par_state, const struct block *block, { struct field_of_this_result inner_is_a_field_of_this; - sym = lookup_symbol (copy, block, STRUCT_DOMAIN, - &inner_is_a_field_of_this); - if (sym != NULL) + bsym = lookup_symbol (copy, block, STRUCT_DOMAIN, + &inner_is_a_field_of_this); + if (bsym.symbol != NULL) { - yylval.tsym.type = SYMBOL_TYPE (sym); + yylval.tsym.type = SYMBOL_TYPE (bsym.symbol); return TYPENAME; } } @@ -2934,18 +2936,20 @@ classify_name (struct parser_state *par_state, const struct block *block, } } - if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF) + if (bsym.symbol && SYMBOL_CLASS (bsym.symbol) == LOC_TYPEDEF) { - yylval.tsym.type = SYMBOL_TYPE (sym); + yylval.tsym.type = SYMBOL_TYPE (bsym.symbol); return TYPENAME; } /* See if it's an ObjC classname. */ - if (parse_language (par_state)->la_language == language_objc && !sym) + if (parse_language (par_state)->la_language == language_objc && !bsym.symbol) { CORE_ADDR Class = lookup_objc_class (parse_gdbarch (par_state), copy); if (Class) { + struct symbol *sym; + yylval.theclass.theclass = Class; sym = lookup_struct_typedef (copy, expression_context_block, 1); if (sym) @@ -2957,26 +2961,27 @@ classify_name (struct parser_state *par_state, const struct block *block, /* Input names that aren't symbols but ARE valid hex numbers, when the input radix permits them, can be names or numbers depending on the parse. Note we support radixes > 16 here. */ - if (!sym + if (!bsym.symbol && ((copy[0] >= 'a' && copy[0] < 'a' + input_radix - 10) || (copy[0] >= 'A' && copy[0] < 'A' + input_radix - 10))) { YYSTYPE newlval; /* Its value is ignored. */ int hextype = parse_number (par_state, copy, yylval.sval.length, 0, &newlval); + if (hextype == INT) { - yylval.ssym.sym = sym; + yylval.ssym.sym = bsym; yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL; return NAME_OR_INT; } } /* Any other kind of symbol */ - yylval.ssym.sym = sym; + yylval.ssym.sym = bsym; yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL; - if (sym == NULL + if (bsym.symbol == NULL && parse_language (par_state)->la_language == language_cplus && is_a_field_of_this.type == NULL && lookup_minimal_symbol (copy, NULL, NULL).minsym == NULL) @@ -3010,7 +3015,7 @@ classify_inner_name (struct parser_state *par_state, /* If no symbol was found, search for a matching base class named COPY. This will allow users to enter qualified names of class members relative to the `this' pointer. */ - if (yylval.ssym.sym == NULL) + if (yylval.ssym.sym.symbol == NULL) { struct type *base_type = cp_find_type_baseclass_by_name (type, copy); @@ -3023,7 +3028,7 @@ classify_inner_name (struct parser_state *par_state, return ERROR; } - switch (SYMBOL_CLASS (yylval.ssym.sym)) + switch (SYMBOL_CLASS (yylval.ssym.sym.symbol)) { case LOC_BLOCK: case LOC_LABEL: @@ -3042,7 +3047,7 @@ classify_inner_name (struct parser_state *par_state, return ERROR; case LOC_TYPEDEF: - yylval.tsym.type = SYMBOL_TYPE (yylval.ssym.sym); + yylval.tsym.type = SYMBOL_TYPE (yylval.ssym.sym.symbol); return TYPENAME; default: @@ -3302,8 +3307,8 @@ c_print_token (FILE *file, int type, YYSTYPE value) case BLOCKNAME: fprintf (file, "ssym<name=%s, sym=%s, field_of_this=%d>", copy_name (value.ssym.stoken), - (value.ssym.sym == NULL - ? "(null)" : SYMBOL_PRINT_NAME (value.ssym.sym)), + (value.ssym.sym.symbol == NULL + ? "(null)" : SYMBOL_PRINT_NAME (value.ssym.sym.symbol)), value.ssym.is_a_field_of_this); break; |