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.
This commit is contained in:
Tom Tromey
2022-02-22 12:02:10 -07:00
parent c3f2a3738a
commit 45016746f1
2 changed files with 15 additions and 8 deletions

View File

@ -227,7 +227,7 @@ false { return FALSEKEYWORD; }
/* ATTRIBUTES */ /* ATTRIBUTES */
{TICK}[a-z][a-z_]+ { BEGIN INITIAL; return processAttribute (yytext+1); } {TICK}[a-z][a-z_]+ { BEGIN INITIAL; return processAttribute (yytext); }
/* PUNCTUATION */ /* PUNCTUATION */
@ -663,6 +663,11 @@ attributes[] = {
static int static int
processAttribute (const char *str) processAttribute (const char *str)
{ {
gdb_assert (*str == '\'');
++str;
while (isspace (*str))
++str;
for (const auto &item : attributes) for (const auto &item : attributes)
if (strcasecmp (str, item.name) == 0) if (strcasecmp (str, item.name) == 0)
return item.code; return item.code;

View File

@ -70,7 +70,8 @@ proc test_p_x_addr { var addr } {
global gdb_prompt global gdb_prompt
foreach attr {access unchecked_access unrestricted_access} { foreach attr {access unchecked_access unrestricted_access} {
set test "print/x $var'$attr" foreach space {"" " "} {
set test "print/x $var'$space$attr"
gdb_test_multiple $test $test { gdb_test_multiple $test $test {
-re "\\$\[0-9\]+ = $addr.*$gdb_prompt $" { -re "\\$\[0-9\]+ = $addr.*$gdb_prompt $" {
pass $test pass $test
@ -80,6 +81,7 @@ proc test_p_x_addr { var addr } {
} }
} }
} }
}
return 0 return 0
} }