gdb/testsuite: Fix left shift of negative value.
authorDominik Vogt <vogt@linux.vnet.ibm.com>
Tue, 17 Nov 2015 09:56:32 +0000 (10:56 +0100)
committerAndreas Krebbel <krebbel@linux.vnet.ibm.com>
Tue, 17 Nov 2015 09:56:32 +0000 (10:56 +0100)
This patch fixes all occurences of left-shifting negative constants in C cod
which is undefined by the C standard.

gdb/testsuite/ChangeLog:

        * lib/dwarf.exp (_note): Fix left shift of negative value.
        * gdb.trace/trace-condition.exp: Likewise.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.trace/trace-condition.exp
gdb/testsuite/lib/dwarf.exp

index 44ebf4402dcb7a0cee1d6b86e681bb9bbb527222..14c4b41b37033879d772e47439c933b91bda7d59 100644 (file)
@@ -1,3 +1,8 @@
+2015-11-17  Dominik Vogt  <vogt@linux.vnet.ibm.com>
+
+       * lib/dwarf.exp (_note): Fix left shift of negative value.
+       * gdb.trace/trace-condition.exp: Likewise.
+
 2015-11-13  Yao Qi  <yao.qi@linaro.org>
 
        * gdb.base/call-sc.exp (test_scalar_returns): Remove the
index 15efb68fe945fe6455519fe90ac8dd7694f38399..fb1a568f5331658481d6cefb846a1d5fc26d6872 100644 (file)
@@ -142,7 +142,7 @@ foreach trace_command { "trace" "ftrace" } {
     test_tracepoints $trace_command "21 * 2 == 42" 10
     test_tracepoints $trace_command "21 << 1 == 42" 10
     test_tracepoints $trace_command "42 >> 1 == 21" 10
-    test_tracepoints $trace_command "-21 << 1 == -42" 10
+    test_tracepoints $trace_command "-(21 << 1) == -42" 10
     test_tracepoints $trace_command "-42 >> 1 == -21" 10
     test_tracepoints $trace_command "(0xabababab & 0x0000ffff) == 0xabab" 10
     test_tracepoints $trace_command "(0xabababab | 0x0000ffff) == 0xababffff" 10
index 97167955579955221bfc0c3a4dfc384959de1416..c87da87715a8d9c712b4e7e6f7400b3d6b84d2d6 100644 (file)
@@ -1289,7 +1289,7 @@ namespace eval Dwarf {
        _op .ascii [_quote $name]
        # Alignment.
        set align 2
-       set total [expr {($namelen + (1 << $align) - 1) & (-1 << $align)}]
+       set total [expr {($namelen + (1 << $align) - 1) & -(1 << $align)}]
        for {set i $namelen} {$i < $total} {incr i} {
            _op .byte 0
        }