Initial revision
[openwrt.git] / toolchain / gcc / 3.4.2 / 300-pr15526.patch
1 # DP: 2004-09-26  Roger Sayle  <roger@eyesopen.com>
2 # DP: 
3 # DP:   PR other/15526
4 # DP:   Backport from mainline
5 # DP:   2004-05-20  Falk Hueffner  <falk@debian.org>
6 # DP:   * libgcc2.c (__mulvsi3): Fix overflow test.
7
8 diff -u -r1.170.6.1 -r1.170.6.2
9 --- gcc/gcc/libgcc2.c   2004/07/17 21:18:47     1.170.6.1
10 +++ gcc/gcc/libgcc2.c   2004/09/26 20:47:14     1.170.6.2
11 @@ -130,9 +130,7 @@
12  {
13    const DWtype w = (DWtype) a * (DWtype) b;
14  
15 -  if (((a >= 0) == (b >= 0))
16 -      ? (UDWtype) w > (UDWtype) (((DWtype) 1 << (WORD_SIZE - 1)) - 1)
17 -      : (UDWtype) w < (UDWtype) ((DWtype) -1 << (WORD_SIZE - 1)))
18 +  if ((Wtype) (w >> WORD_SIZE) != (Wtype) w >> (WORD_SIZE - 1))
19      abort ();
20  
21    return w;
22
23 /cvs/gcc/gcc/gcc/testsuite/gcc.dg/ftrapv-1.c,v  -->  standard output
24 revision 1.1.22.1
25 --- gcc/gcc/testsuite/gcc.dg/ftrapv-1.c
26 +++ /dev/null   2004-10-15 06:22:06.980596000 +0000
27 @@ -0,0 +1,25 @@
28 +/* Copyright (C) 2004 Free Software Foundation.
29 +
30 +   PR other/15526
31 +   Verify correct overflow checking with -ftrapv.
32 +
33 +   Written by Falk Hueffner, 20th May 2004.  */
34 +
35 +/* { dg-do run } */
36 +/* { dg-options "-ftrapv" } */
37 +
38 +__attribute__((noinline)) int
39 +mulv(int a, int b)
40 +{
41 +  return a * b;
42 +}
43 +
44 +int
45 +main()
46 +{
47 +  mulv( 0,  0);
48 +  mulv( 0, -1);
49 +  mulv(-1,  0);
50 +  mulv(-1, -1);
51 +  return 0;
52 +}
53