diff options
author | Tom Tromey <tromey@adacore.com> | 2022-02-22 12:02:10 -0700 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2022-04-04 12:46:08 -0600 |
commit | 45016746f1a992e7300cae74761c681a8a3f4fe7 (patch) | |
tree | a609743440e8e2a6494e03d7db223853ba16eaad /gdb/ada-lex.l | |
parent | c3f2a3738a3603f51e3621504d8207767526add9 (diff) | |
download | gdb-45016746f1a992e7300cae74761c681a8a3f4fe7.zip gdb-45016746f1a992e7300cae74761c681a8a3f4fe7.tar.gz gdb-45016746f1a992e7300cae74761c681a8a3f4fe7.tar.bz2 |
Fix bug in Ada attributes lexing
The Ada lexer allows whitespace between the apostrophe and the
attribute text, but processAttribute does not handle this. This patch
fixes the problem and introduces a regression test.
Diffstat (limited to 'gdb/ada-lex.l')
-rw-r--r-- | gdb/ada-lex.l | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l index a0c9816..c6ce1ae 100644 --- a/gdb/ada-lex.l +++ b/gdb/ada-lex.l @@ -227,7 +227,7 @@ false { return FALSEKEYWORD; } /* ATTRIBUTES */ -{TICK}[a-z][a-z_]+ { BEGIN INITIAL; return processAttribute (yytext+1); } +{TICK}[a-z][a-z_]+ { BEGIN INITIAL; return processAttribute (yytext); } /* PUNCTUATION */ @@ -663,6 +663,11 @@ attributes[] = { static int processAttribute (const char *str) { + gdb_assert (*str == '\''); + ++str; + while (isspace (*str)) + ++str; + for (const auto &item : attributes) if (strcasecmp (str, item.name) == 0) return item.code; |