aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-02-28 07:03:55 -0700
committerTom Tromey <tromey@adacore.com>2023-03-27 08:20:29 -0600
commiteb52a49702abe3d279cf9eba9291e08bc6b2d9dc (patch)
treefa64f2b15ceb651b28c0a0b888bdbf71414cfaae
parent4db6e7aa6ae167bc8e45829fa711f565c69a46bf (diff)
downloadgdb-eb52a49702abe3d279cf9eba9291e08bc6b2d9dc.zip
gdb-eb52a49702abe3d279cf9eba9291e08bc6b2d9dc.tar.gz
gdb-eb52a49702abe3d279cf9eba9291e08bc6b2d9dc.tar.bz2
Simplify binop_promote
binop_promote currently only handles integer sizes up to builtin_long_long. However, this may not handle 128-bit types. Simplify this code, unify the C and non-C (but not OpenCL, as I don't know how to test this) cases, and handle 128-bit integers as well. This still doesn't exactly follow C or C++ rules. This could be implemented, but if so, I think it makes more sense as a C-specific expression node.
-rw-r--r--gdb/eval.c55
1 files changed, 19 insertions, 36 deletions
diff --git a/gdb/eval.c b/gdb/eval.c
index f8bbb9e..6b362f4 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -371,29 +371,6 @@ binop_promote (const struct language_defn *language, struct gdbarch *gdbarch,
switch (language->la_language)
{
- case language_c:
- case language_cplus:
- case language_asm:
- case language_objc:
- if (result_len <= builtin->builtin_int->length ())
- {
- promoted_type = (unsigned_operation
- ? builtin->builtin_unsigned_int
- : builtin->builtin_int);
- }
- else if (result_len <= builtin->builtin_long->length ())
- {
- promoted_type = (unsigned_operation
- ? builtin->builtin_unsigned_long
- : builtin->builtin_long);
- }
- else
- {
- promoted_type = (unsigned_operation
- ? builtin->builtin_unsigned_long_long
- : builtin->builtin_long_long);
- }
- break;
case language_opencl:
if (result_len
<= lookup_signed_typename (language, "int")->length())
@@ -413,23 +390,29 @@ binop_promote (const struct language_defn *language, struct gdbarch *gdbarch,
}
break;
default:
- /* For other languages the result type is unchanged from gdb
- version 6.7 for backward compatibility.
- If either arg was long long, make sure that value is also long
- long. Otherwise use long. */
- if (unsigned_operation)
+ if (result_len <= builtin->builtin_int->length ())
{
- if (result_len > gdbarch_long_bit (gdbarch) / HOST_CHAR_BIT)
- promoted_type = builtin->builtin_unsigned_long_long;
- else
- promoted_type = builtin->builtin_unsigned_long;
+ promoted_type = (unsigned_operation
+ ? builtin->builtin_unsigned_int
+ : builtin->builtin_int);
+ }
+ else if (result_len <= builtin->builtin_long->length ())
+ {
+ promoted_type = (unsigned_operation
+ ? builtin->builtin_unsigned_long
+ : builtin->builtin_long);
+ }
+ else if (result_len <= builtin->builtin_long_long->length ())
+ {
+ promoted_type = (unsigned_operation
+ ? builtin->builtin_unsigned_long_long
+ : builtin->builtin_long_long);
}
else
{
- if (result_len > gdbarch_long_bit (gdbarch) / HOST_CHAR_BIT)
- promoted_type = builtin->builtin_long_long;
- else
- promoted_type = builtin->builtin_long;
+ promoted_type = (unsigned_operation
+ ? builtin->builtin_uint128
+ : builtin->builtin_int128);
}
break;
}