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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [pure-1.c] - Blame information for rev 298

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

Line No. Rev Author Line
1 297 jeremybenn
 
2
/* Origin: Kaveh Ghazi <ghazi@caip.rutgers.edu> 2002-05-27.  */
3
 
4
/* Use a different function for each test so the link failures
5
   indicate which one is broken.  */
6
extern void link_error0 (void);
7
extern void link_error1 (void);
8
extern void link_error2 (void);
9
extern void link_error3 (void);
10
extern void link_error4 (void);
11
extern void link_error5 (void);
12
extern void link_error6 (void);
13
extern void link_error7 (void);
14
 
15
extern int i;
16
 
17
extern int func0 (int) __attribute__ ((__pure__));
18
extern int func1 (int) __attribute__ ((__const__));
19
 
20
/* GCC should automatically detect attributes for these functions.
21
   At -O3 They'll be inlined, but that's ok.  */
22
static int func2 (int a) { return i + a; } /* pure */
23
static int func3 (int a) { return a * 3; } /* const */
24
static int func4 (int a) { return func0(a) + a; } /* pure */
25
static int func5 (int a) { return a + func1(a); } /* const */
26
static int func6 (int a) { return func2(a) + a; } /* pure */
27
static int func7 (int a) { return a + func3(a); } /* const */
28
 
29
int main ()
30
{
31
  int i[10], r;
32
 
33
  i[0] = 0;
34
  r = func0(0);
35
  if (i[0])
36
    link_error0();
37
 
38
  i[1] = 0;
39
  r = func1(0);
40
  if (i[1])
41
    link_error1();
42
 
43
  i[2] = 0;
44
  r = func2(0);
45
  if (i[2])
46
    link_error2();
47
 
48
  i[3] = 0;
49
  r = func3(0);
50
  if (i[3])
51
    link_error3();
52
 
53
  i[4] = 0;
54
  r = func4(0);
55
  if (i[4])
56
    link_error4();
57
 
58
  i[5] = 0;
59
  r = func5(0);
60
  if (i[5])
61
    link_error5();
62
 
63
  i[6] = 0;
64
  r = func6(0);
65
  if (i[6])
66
    link_error6();
67
 
68
  i[7] = 0;
69
  r = func7(0);
70
  if (i[7])
71
    link_error7();
72
 
73
  return r;
74
}
75
 
76
int func0 (int a) { return a - i; } /* pure */
77
int func1 (int a) { return a - a; } /* const */
78
 
79
int i = 2;
80
 
81
#ifndef __OPTIMIZE__
82
/* Avoid link failures when not optimizing. */
83
void link_error0() {}
84
void link_error1() {}
85
void link_error2() {}
86
void link_error3() {}
87
void link_error4() {}
88
void link_error5() {}
89
void link_error6() {}
90
void link_error7() {}
91
#endif /* ! __OPTIMIZE__ */

powered by: WebSVN 2.1.0

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