X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=gdb%2Fada-lex.l;h=8c0e76798325db4ab3915fc4cc2ab0293ec3b82b;hb=3bfdcabbc20d56ce25629b464262928a4f90c042;hp=69fc14f7107256cc2eb79cb60493ff664c8d7924;hpb=302273ca843fc3ddbe8210e6d30459316bf04f0e;p=binutils-gdb.git diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l index 69fc14f7107..8c0e7679832 100644 --- a/gdb/ada-lex.l +++ b/gdb/ada-lex.l @@ -179,15 +179,15 @@ static int paren_depth; } "'"({GRAPHIC}|\")"'" { - yylval.typed_val.val = yytext[1]; - yylval.typed_val.type = type_for_char (pstate, yytext[1]); + yylval.typed_char.val = yytext[1]; + yylval.typed_char.type = type_for_char (pstate, yytext[1]); return CHARLIT; } "'[\""{HEXDIG}{2,}"\"]'" { ULONGEST v = strtoulst (yytext+3, nullptr, 16); - yylval.typed_val.val = v; - yylval.typed_val.type = type_for_char (pstate, v); + yylval.typed_char.val = v; + yylval.typed_char.type = type_for_char (pstate, v); return CHARLIT; } @@ -371,7 +371,7 @@ canonicalizeNumeral (char *s1, const char *s2) /* Interprets the prefix of NUM that consists of digits of the given BASE as an integer of that BASE, with the string EXP as an exponent. Puts value in yylval, and returns INT, if the string is valid. Causes - an error if the number is improperly formated. BASE, if NULL, defaults + an error if the number is improperly formatted. BASE, if NULL, defaults to "10", and EXP to "1". The EXP does not contain a leading 'e' or 'E'. */ @@ -462,52 +462,35 @@ processInt (struct parser_state *par_state, const char *base0, return FLOAT; } - if (result > gdb_mpz (ULONGEST_MAX)) - error (_("Integer literal out of range")); + int_storage.emplace_back (new gdb_mpz (std::move (result))); + const gdb_mpz *value = int_storage.back ().get (); int int_bits = gdbarch_int_bit (par_state->gdbarch ()); int long_bits = gdbarch_long_bit (par_state->gdbarch ()); int long_long_bits = gdbarch_long_long_bit (par_state->gdbarch ()); - ULONGEST value = result.as_integer (); - if (fits_in_type (1, value, int_bits, true)) - yylval.typed_val.type = type_int (par_state); - else if (fits_in_type (1, value, long_bits, true)) - yylval.typed_val.type = type_long (par_state); - else if (fits_in_type (1, value, long_bits, false)) - { - /* We have a number representable as an unsigned integer quantity. - For consistency with the C treatment, we will treat it as an - anonymous modular (unsigned) quantity. Alas, the types are such - that we need to store .val as a signed quantity. Sorry - for the mess, but C doesn't officially guarantee that a simple - assignment does the trick (no, it doesn't; read the reference manual). - */ - yylval.typed_val.type - = builtin_type (par_state->gdbarch ())->builtin_unsigned_long; - if (value & LONGEST_SIGN) - yylval.typed_val.val = - (LONGEST) (value & ~LONGEST_SIGN) - - (LONGEST_SIGN>>1) - (LONGEST_SIGN>>1); - else - yylval.typed_val.val = (LONGEST) value; - return INT; - } - else if (fits_in_type (1, value, long_long_bits, true)) - yylval.typed_val.type = type_long_long (par_state); - else if (fits_in_type (1, value, long_long_bits, false)) - { - yylval.typed_val.type - = builtin_type (par_state->gdbarch ())->builtin_unsigned_long_long; - /* See unsigned long case above. */ - if (value & LONGEST_SIGN) - yylval.typed_val.val = - (LONGEST) (value & ~LONGEST_SIGN) - - (LONGEST_SIGN>>1) - (LONGEST_SIGN>>1); - else - yylval.typed_val.val = (LONGEST) value; - return INT; - } + if (fits_in_type (1, *value, int_bits, true)) + yylval.typed_val.type = parse_type (par_state)->builtin_int; + else if (fits_in_type (1, *value, long_bits, true)) + yylval.typed_val.type = parse_type (par_state)->builtin_long; + else if (fits_in_type (1, *value, long_bits, false)) + yylval.typed_val.type + = builtin_type (par_state->gdbarch ())->builtin_unsigned_long; + else if (fits_in_type (1, *value, long_long_bits, true)) + yylval.typed_val.type = parse_type (par_state)->builtin_long_long; + else if (fits_in_type (1, *value, long_long_bits, false)) + yylval.typed_val.type + = builtin_type (par_state->gdbarch ())->builtin_unsigned_long_long; + else if (fits_in_type (1, *value, 128, true)) + yylval.typed_val.type + = language_lookup_primitive_type (par_state->language (), + par_state->gdbarch (), + "long_long_long_integer"); + else if (fits_in_type (1, *value, 128, false)) + yylval.typed_val.type + = language_lookup_primitive_type (par_state->language (), + par_state->gdbarch (), + "unsigned_long_long_long_integer"); else error (_("Integer literal out of range")); @@ -518,7 +501,7 @@ processInt (struct parser_state *par_state, const char *base0, static int processReal (struct parser_state *par_state, const char *num0) { - yylval.typed_val_float.type = type_long_double (par_state); + yylval.typed_val_float.type = parse_type (par_state)->builtin_long_double; bool parsed = parse_float (num0, strlen (num0), yylval.typed_val_float.type,