OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [ftrapv-2.c] - Blame information for rev 378

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 298 jeremybenn
/* Copyright (C) 2004 Free Software Foundation.
2
 
3
   PR other/18665
4
   Verify that -ftrapv doesn't produce bogus results
5
   on 64-bit platforms.
6
 
7
   Written by Eric Botcazou  */
8
 
9
/* { dg-do run } */
10
/* { dg-options "-ftrapv" } */
11
 
12
extern void abort(void);
13
extern long labs(long);
14
 
15
int __attribute__((noinline))
16
iabsv(int a)
17
{
18
  return abs(a);
19
}
20
 
21
int __attribute__((noinline))
22
iaddv(int a, int b)
23
{
24
  return a + b;
25
}
26
 
27
int __attribute__((noinline))
28
isubv(int a, int b)
29
{
30
  return a - b;
31
}
32
 
33
int __attribute__((noinline))
34
imulv(int a, int b)
35
{
36
  return a * b;
37
}
38
 
39
int __attribute__((noinline))
40
inegv(int a)
41
{
42
  return -a;
43
}
44
 
45
long __attribute__((noinline))
46
labsv(long a)
47
{
48
  return labs(a);
49
}
50
 
51
long __attribute__((noinline))
52
laddv(long a, long b)
53
{
54
  return a + b;
55
}
56
 
57
long __attribute__((noinline))
58
lsubv(long a, long b)
59
{
60
  return a - b;
61
}
62
 
63
long __attribute__((noinline))
64
lmulv(long a, long b)
65
{
66
  return a * b;
67
}
68
 
69
long __attribute__((noinline))
70
lnegv(long a)
71
{
72
  return -a;
73
}
74
 
75
int main(void)
76
{
77
  if (iabsv (-1) != 1)
78
    abort ();
79
 
80
  if (iaddv (2,-3) != -1)
81
    abort ();
82
 
83
  if (isubv (2,3) != -1)
84
    abort ();
85
 
86
  if (imulv (-2,3) != -6)
87
    abort ();
88
 
89
  if (inegv (-1) != 1)
90
    abort ();
91
 
92
  if (labsv (-1L) != 1L)
93
    abort ();
94
 
95
  if (laddv (2L,-3L) != -1L)
96
    abort ();
97
 
98
  if (lsubv (2L,3L) != -1L)
99
    abort ();
100
 
101
  if (lmulv (-2L,3L) != -6L)
102
    abort ();
103
 
104
  if (lnegv (-1L) != 1L)
105
    abort ();
106
 
107
  return 0;
108
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.