]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix cast types for opencl
authorHannes Domani <ssbssa@yahoo.de>
Tue, 11 Jun 2024 19:30:45 +0000 (21:30 +0200)
committerHannes Domani <ssbssa@yahoo.de>
Tue, 11 Jun 2024 19:30:45 +0000 (21:30 +0200)
The bitshift tests for opencl have these failures:

print /x (signed char) 0x0f << 8
No type named signed char.
(gdb) FAIL: gdb.base/bitshift.exp: lang=opencl: 8-bit, promoted: print /x (signed char) 0x0f << 8
print (signed char) 0x0f << 8
No type named signed char.
(gdb) FAIL: gdb.base/bitshift.exp: lang=opencl: 8-bit, promoted: print (signed char) 0x0f << 8

Apparently opencl doesn't have the 'signed' modifier for types, only
the 'unsigned' modifier.
Even 'char' is guaranteed to be signed if no modifier is used, so
this changes the casts to match this logic.

Approved-By: Tom Tromey <tom@tromey.com>
gdb/testsuite/gdb.base/bitshift.exp

index cab82e1971e14fea8b0c9295057c3d4e50415044..dccc36b20ad353d50de094227b85231e37553b83 100644 (file)
@@ -123,10 +123,12 @@ proc make_val_cast {lang signed bits val} {
        return "$val as ${sign_prefix}$bits"
     } else {
        # C-like cast.
-       if {$signed} {
+       if {!$signed} {
+           set sign_prefix "unsigned "
+       } elseif {$lang == "opencl"} {
            set sign_prefix ""
        } else {
-           set sign_prefix "un"
+           set sign_prefix "signed "
        }
        if {$bits == 8} {
            set type "char"
@@ -143,7 +145,7 @@ proc make_val_cast {lang signed bits val} {
        } else {
            error "$lang: unsupported bits"
        }
-       return "(${sign_prefix}signed $type) $val"
+       return "(${sign_prefix}$type) $val"
     }
 }