This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 2/2] Fix invalid left shift of negative value.
- From: Dominik Vogt <vogt at linux dot vnet dot ibm dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Andreas Arnez <arnez at linux dot vnet dot ibm dot com>, Andreas Krebbel <krebbel at linux dot vnet dot ibm dot com>
- Date: Tue, 10 Nov 2015 12:14:30 +0100
- Subject: Re: [PATCH 2/2] Fix invalid left shift of negative value.
- Authentication-results: sourceware.org; auth=none
- References: <20151110111123 dot GA16951 at linux dot vnet dot ibm dot com>
- Reply-to: vogt at linux dot vnet dot ibm dot com
On Tue, Nov 10, 2015 at 12:11:23PM +0100, Dominik Vogt wrote:
> The following series of patches fixes all occurences of
> left-shifting negative constants in C code which is undefined by
> the C standard. The patches have been tested on s390x, covering
> only a small subset of the changes.
Changes in gdb/testsuite/. I'm not sure whether these are good or
not.
Ciao
Dominik ^_^ ^_^
--
Dominik Vogt
IBM Germany
>From d1cbc6f371e2720fe4bf4975d8ad9c81a9f01351 Mon Sep 17 00:00:00 2001
From: Dominik Vogt <vogt@linux.vnet.ibm.com>
Date: Fri, 30 Oct 2015 15:18:06 +0100
Subject: [PATCH 2/2] gdb/testsuite: Fix left shift of negative value.
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/gdb.trace/trace-condition.exp | 2 +-
gdb/testsuite/lib/dwarf.exp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/gdb/testsuite/gdb.trace/trace-condition.exp b/gdb/testsuite/gdb.trace/trace-condition.exp
index aec0401..46fa5ed 100644
--- a/gdb/testsuite/gdb.trace/trace-condition.exp
+++ b/gdb/testsuite/gdb.trace/trace-condition.exp
@@ -152,7 +152,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
diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp
index 9716795..c87da87 100644
--- a/gdb/testsuite/lib/dwarf.exp
+++ b/gdb/testsuite/lib/dwarf.exp
@@ -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
}
--
2.3.0