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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [pr20100-1.c] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 jlechner
/* PR tree-optimization/20100
2
   Pure function being treated as const.
3
   Author: Hans-Peter Nilsson.  */
4
 
5
static unsigned short g = 0;
6
static unsigned short p = 0;
7
unsigned char e;
8
 
9
static unsigned short
10
next_g (void)
11
{
12
  return g == e - 1 ? 0 : g + 1;
13
}
14
 
15
static unsigned short
16
curr_p (void)
17
{
18
  return p;
19
}
20
 
21
static unsigned short
22
inc_g (void)
23
{
24
  return g = next_g ();
25
}
26
 
27
static unsigned short
28
curr_g (void)
29
{
30
  return g;
31
}
32
 
33
static char
34
ring_empty (void)
35
{
36
  if (curr_p () == curr_g ())
37
    return 1;
38
  else
39
    return 0;
40
}
41
 
42
char
43
frob (unsigned short a, unsigned short b)
44
{
45
  g = a;
46
  p = b;
47
  inc_g ();
48
  return ring_empty ();
49
}
50
 
51
unsigned short
52
get_n (void)
53
{
54
  unsigned short n = 0;
55
  unsigned short org_g;
56
  org_g = curr_g ();
57
  while (!ring_empty () && n < 5)
58
    {
59
      inc_g ();
60
      n++;
61
    }
62
 
63
  return n;
64
}
65
 
66
void abort (void);
67
void exit (int);
68
int main (void)
69
{
70
  e = 3;
71
  if (frob (0, 2) != 0 || g != 1 || p != 2 || e != 3
72
      || get_n () != 1
73
      || g != 2 || p != 2)
74
    abort ();
75
  exit (0);
76
}

powered by: WebSVN 2.1.0

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