diff options
author | Tom Tromey <tromey@adacore.com> | 2022-04-08 10:11:58 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2022-04-12 13:02:00 -0600 |
commit | 0349d33f1dfda8b831ad32c8dfe949e343dfcf0c (patch) | |
tree | 1fcbcf5b829a6bdc71702c1494211cf0f92130cd | |
parent | 81f81faa8f8391e234c31130978e57a4e9e79064 (diff) | |
download | binutils-gdb-0349d33f1dfda8b831ad32c8dfe949e343dfcf0c.tar.gz |
Fix bug in Ada number lexing
On irc, Pedro pointed out that Ada couldn't properly handle
0xffffffffffffffff. This used to work, but is a regression due to
some patches I wrote in the Ada lexer. This patch fixes the bug.
-rw-r--r-- | gdb/ada-lex.l | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/literals.exp | 3 |
2 files changed, 5 insertions, 2 deletions
diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l index 27470a75653..3900a839a8e 100644 --- a/gdb/ada-lex.l +++ b/gdb/ada-lex.l @@ -434,11 +434,11 @@ processInt (struct parser_state *par_state, const char *base0, return FLOAT; } - gdb_mpz maxval (ULONGEST_MAX / base); + gdb_mpz maxval (ULONGEST_MAX); if (mpz_cmp (result.val, maxval.val) > 0) error (_("Integer literal out of range")); - LONGEST value = result.as_integer<LONGEST> (); + ULONGEST value = result.as_integer<ULONGEST> (); if ((value >> (gdbarch_int_bit (par_state->gdbarch ())-1)) == 0) yylval.typed_val.type = type_int (par_state); else if ((value >> (gdbarch_long_bit (par_state->gdbarch ())-1)) == 0) diff --git a/gdb/testsuite/gdb.ada/literals.exp b/gdb/testsuite/gdb.ada/literals.exp index 92a9a1954fc..a6ac89b540f 100644 --- a/gdb/testsuite/gdb.ada/literals.exp +++ b/gdb/testsuite/gdb.ada/literals.exp @@ -34,3 +34,6 @@ gdb_test "print 2e1000" "Integer literal out of range" gdb_test "print 16#ffff#" " = 65535" gdb_test "print 16#f#e1" " = 240" gdb_test "print 16#1#e10" " = 1099511627776" + +gdb_test "print/x 16#7fffffffffffffff#" " = 0x7fffffffffffffff" +gdb_test "print 16#ffffffffffffffff#" " = -1" |