OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [20020510-1.c] - Blame information for rev 774

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

Line No. Rev Author Line
1 688 jeremybenn
/* Copyright (C) 2002  Free Software Foundation.
2
 
3
   Test that optimizing ((c>=1) && (c<=127)) into (signed char)c < 0
4
   doesn't cause any problems for the compiler and behaves correctly.
5
 
6
   Written by Roger Sayle, 8th May 2002.  */
7
 
8
#include <limits.h>
9
 
10
extern void abort (void);
11
 
12
void
13
testc (unsigned char c, int ok)
14
{
15
  if ((c>=1) && (c<=SCHAR_MAX))
16
    {
17
      if (!ok) abort ();
18
    }
19
  else
20
    if (ok) abort ();
21
}
22
 
23
void
24
tests (unsigned short s, int ok)
25
{
26
  if ((s>=1) && (s<=SHRT_MAX))
27
    {
28
      if (!ok) abort ();
29
    }
30
  else
31
    if (ok) abort ();
32
}
33
 
34
void
35
testi (unsigned int i, int ok)
36
{
37
  if ((i>=1) && (i<=INT_MAX))
38
    {
39
      if (!ok) abort ();
40
    }
41
  else
42
    if (ok) abort ();
43
}
44
 
45
void
46
testl (unsigned long l, int ok)
47
{
48
  if ((l>=1) && (l<=LONG_MAX))
49
    {
50
      if (!ok) abort ();
51
    }
52
  else
53
    if (ok) abort ();
54
}
55
 
56
int
57
main ()
58
{
59
  testc (0, 0);
60
  testc (1, 1);
61
  testc (SCHAR_MAX, 1);
62
  testc (SCHAR_MAX+1, 0);
63
  testc (UCHAR_MAX, 0);
64
 
65
  tests (0, 0);
66
  tests (1, 1);
67
  tests (SHRT_MAX, 1);
68
  tests (SHRT_MAX+1, 0);
69
  tests (USHRT_MAX, 0);
70
 
71
  testi (0, 0);
72
  testi (1, 1);
73
  testi (INT_MAX, 1);
74
  testi (INT_MAX+1U, 0);
75
  testi (UINT_MAX, 0);
76
 
77
  testl (0, 0);
78
  testl (1, 1);
79
  testl (LONG_MAX, 1);
80
  testl (LONG_MAX+1UL, 0);
81
  testl (ULONG_MAX, 0);
82
 
83
  return 0;
84
}
85
 

powered by: WebSVN 2.1.0

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