diff options
author | Tom Tromey <tom@tromey.com> | 2020-12-11 09:59:15 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2020-12-11 10:10:53 -0700 |
commit | 02c727013cc3ae08b86ad360429f9a0dbdc0ec92 (patch) | |
tree | a2ab1ef9c1f3d7c441e615f01fd671c135742827 /gdb/m2-exp.y | |
parent | 14a772212b8e8e19b45a23e2dacb61ceff0d4979 (diff) | |
download | fsf-binutils-gdb-02c727013cc3ae08b86ad360429f9a0dbdc0ec92.zip fsf-binutils-gdb-02c727013cc3ae08b86ad360429f9a0dbdc0ec92.tar.gz fsf-binutils-gdb-02c727013cc3ae08b86ad360429f9a0dbdc0ec92.tar.bz2 |
Avoid side effects in expression lexers
I noticed that some of the lexers were calling write_dollar_variable
from the lexer. This seems like a bad practice, so this patch moves
the side effects into the parsers.
I tested this by re-running gdb.fortran and gdb.modula2; the Pascal
compiler on my machine seems not to work, so I couldn't test
gdb.pascal.
I note that the type-tracking in the Pascal is also incorrect, in that
a convenience variable's type may change between parsing and
evaluation (or even during the course of evaluation).
gdb/ChangeLog
2020-12-11 Tom Tromey <tom@tromey.com>
* p-exp.y (intvar): Remove global.
(DOLLAR_VARIABLE): Change type.
(start): Update.
(exp): Call write_dollar_variable here...
(yylex): ... not here.
* m2-exp.y (DOLLAR_VARIABLE): Change type.
(variable): Call write_dollar_variable here...
(yylex): ... not here.
* f-exp.y (DOLLAR_VARIABLE): Change type.
(exp): Call write_dollar_variable here...
(yylex): ... not here.
Diffstat (limited to 'gdb/m2-exp.y')
-rw-r--r-- | gdb/m2-exp.y | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y index f6f1112..d4f3c2c 100644 --- a/gdb/m2-exp.y +++ b/gdb/m2-exp.y @@ -125,7 +125,7 @@ static int number_sign = 1; /* The GDB scope operator */ %token COLONCOLON -%token <voidval> DOLLAR_VARIABLE +%token <sval> DOLLAR_VARIABLE /* M2 tokens */ %left ',' @@ -535,6 +535,7 @@ variable: fblock /* GDB internal ($foo) variable */ variable: DOLLAR_VARIABLE + { write_dollar_variable (pstate, $1); } ; /* GDB scope operator */ @@ -952,10 +953,7 @@ yylex (void) yylval.sval.length = namelen; if (*tokstart == '$') - { - write_dollar_variable (pstate, yylval.sval); - return DOLLAR_VARIABLE; - } + return DOLLAR_VARIABLE; /* Use token-type BLOCKNAME for symbols that happen to be defined as functions. If this is not so, then ... |