X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Ff-exp.y;h=5ef16125f5dad844820d2c3280b1d57b6247879a;hb=da658607ed24bc5a4dcfcfb56b6e1440ccab33d2;hp=a791d2caf9fdacd6e4269c1e72b3a7ec8e402237;hpb=61baf725eca99af2569262d10aca03dcde2698f6;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/f-exp.y b/gdb/f-exp.y index a791d2caf9..5ef16125f5 100644 --- a/gdb/f-exp.y +++ b/gdb/f-exp.y @@ -1,6 +1,6 @@ /* YACC parser for Fortran expressions, for GDB. - Copyright (C) 1986-2017 Free Software Foundation, Inc. + Copyright (C) 1986-2018 Free Software Foundation, Inc. Contributed by Motorola. Adapted from the C parser by Farooq Butt (fmbutt@engage.sps.mot.com). @@ -72,7 +72,7 @@ int yyparse (void); static int yylex (void); -void yyerror (char *); +static void yyerror (const char *); static void growbuf_by_size (int); @@ -91,7 +91,10 @@ static int match_string_literal (void); LONGEST val; struct type *type; } typed_val; - DOUBLEST dval; + struct { + gdb_byte val[16]; + struct type *type; + } typed_val_float; struct symbol *sym; struct type *tval; struct stoken sval; @@ -122,7 +125,7 @@ static int parse_number (struct parser_state *, const char *, int, %type ptype %token INT -%token FLOAT +%token FLOAT /* Both NAME and TYPENAME tokens represent symbols in the input, and both convey their data as strings. @@ -414,12 +417,10 @@ exp : NAME_OR_INT ; exp : FLOAT - { write_exp_elt_opcode (pstate, OP_DOUBLE); - write_exp_elt_type (pstate, - parse_f_type (pstate) - ->builtin_real_s8); - write_exp_elt_dblcst (pstate, $1); - write_exp_elt_opcode (pstate, OP_DOUBLE); } + { write_exp_elt_opcode (pstate, OP_FLOAT); + write_exp_elt_type (pstate, $1.type); + write_exp_elt_floatcst (pstate, $1.val); + write_exp_elt_opcode (pstate, OP_FLOAT); } ; exp : variable @@ -460,12 +461,7 @@ variable: name_not_typename if (sym.symbol) { if (symbol_read_needs_frame (sym.symbol)) - { - if (innermost_block == 0 - || contained_in (sym.block, - innermost_block)) - innermost_block = sym.block; - } + innermost_block.update (sym); write_exp_elt_opcode (pstate, OP_VAR_VALUE); write_exp_elt_block (pstate, sym.block); write_exp_elt_sym (pstate, sym.symbol); @@ -513,7 +509,7 @@ ptype : typebase follow_type = lookup_pointer_type (follow_type); break; case tp_reference: - follow_type = lookup_reference_type (follow_type); + follow_type = lookup_lvalue_reference_type (follow_type); break; case tp_array: array_size = pop_type_int (); @@ -647,16 +643,22 @@ parse_number (struct parser_state *par_state, if (parsed_float) { /* It's a float since it contains a point or an exponent. */ - /* [dD] is not understood as an exponent by atof, change it to 'e'. */ + /* [dD] is not understood as an exponent by parse_float, + change it to 'e'. */ char *tmp, *tmp2; tmp = xstrdup (p); for (tmp2 = tmp; *tmp2; ++tmp2) if (*tmp2 == 'd' || *tmp2 == 'D') *tmp2 = 'e'; - putithere->dval = atof (tmp); + + /* FIXME: Should this use different types? */ + putithere->typed_val_float.type = parse_f_type (pstate)->builtin_real_s8; + bool parsed = parse_float (tmp, len, + putithere->typed_val_float.type, + putithere->typed_val_float.val); free (tmp); - return FLOAT; + return parsed? FLOAT : ERROR; } /* Handle base-switching prefixes 0x, 0t, 0d, 0 */ @@ -773,7 +775,7 @@ parse_number (struct parser_state *par_state, struct token { - char *oper; + const char *oper; int token; enum exp_opcode opcode; }; @@ -807,7 +809,7 @@ static const struct token dot_ops[] = struct f77_boolean_val { - char *name; + const char *name; int value; }; @@ -1006,7 +1008,7 @@ yylex (void) /* Might be a floating point number. */ if (lexptr[1] < '0' || lexptr[1] > '9') goto symbol; /* Nope, must be a symbol. */ - /* FALL THRU into number case. */ + /* FALL THRU. */ case '0': case '1': @@ -1206,23 +1208,19 @@ yylex (void) int f_parse (struct parser_state *par_state) { - int result; - struct cleanup *c = make_cleanup_clear_parser_state (&pstate); - /* Setting up the parser state. */ + scoped_restore pstate_restore = make_scoped_restore (&pstate); gdb_assert (par_state != NULL); pstate = par_state; - result = yyparse (); - do_cleanups (c); - return result; + return yyparse (); } -void -yyerror (char *msg) +static void +yyerror (const char *msg) { if (prev_lexptr) lexptr = prev_lexptr; - error (_("A %s in expression, near `%s'."), (msg ? msg : "error"), lexptr); + error (_("A %s in expression, near `%s'."), msg, lexptr); }