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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [testsuite/] [g++.old-deja/] [g++.mike/] [p646.C] - Blame information for rev 154

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
// { dg-do assemble  }
2
// { dg-options "-Wno-deprecated -Wreturn-type" }
3
// GROUPS passed i960
4
/*
5
  Bug Id: bnr
6
  PMRS Id: p0000646
7
  Bug is: Urgent Code Generation Problem in gcc-i960 V 1.95
8
*/
9
 
10
 
11
 
12
extern "C"
13
{
14
  int printf (const char *, ...);
15
  void abort ();
16
}
17
 
18
struct foo
19
{
20
  static int si;
21
  int i;
22
  foo ();
23
  foo (const foo&);
24
  ~foo ();
25
};
26
 
27
int
28
foo_parm_returns_i (foo foo_arg)
29
{
30
  return foo_arg.i;
31
}
32
 
33
int foo::si = 0;
34
 
35
foo::foo ()
36
{
37
  si++;
38
  printf ("new foo @ 0x%x; now %d foos\n", this, si);
39
}
40
 
41
foo::foo (const foo &other)
42
{
43
  si++;
44
  printf ("another foo @ 0x%x; now %d foos\n", this, si);
45
  *this = other;
46
}
47
 
48
foo::~foo ()
49
{
50
  si--;
51
  printf ("deleted foo @ 0x%x; now %d foos\n", this, si);
52
}
53
 
54
int
55
return_1 ()
56
{
57
  foo f;
58
  printf ("returning 1\n");
59
  return 1;
60
}
61
 
62
int
63
return_arg (int arg)
64
{
65
  foo f;
66
  printf ("returning %d\n", arg);
67
  return arg;
68
}
69
 
70
int
71
return_sum (int x, int y)
72
{
73
  foo f;
74
  printf ("returning %d+%d\n", x, y);
75
  return x + y;
76
}
77
 
78
foo
79
return_foo ()
80
{
81
  foo f;
82
  printf ("returning foo\n");
83
  return f;
84
}
85
 
86
foo
87
foo_parm_returns_foo (foo f)
88
{
89
  return f;
90
}
91
 
92
void
93
abort_because (const char *str)
94
{
95
  printf ("aborting because %s\n", str);
96
  abort ();
97
}
98
 
99
int
100
warn_return_1 ()
101
{
102
  foo f;
103
  printf ("returning 1\n");
104
}                              // { dg-warning "" } control reaches end
105
 
106
int
107
warn_return_arg (int arg)
108
{
109
  foo f;
110
  printf ("returning %d\n", arg);
111
  arg;
112
}                              // { dg-warning "" } control reaches end
113
 
114
int
115
warn_return_sum (int x, int y)
116
{
117
  foo f;
118
  printf ("returning %d+%d\n", x, y);
119
  x + y;
120
}                              // { dg-warning "" } control reaches end
121
 
122
foo
123
warn_return_foo ()
124
{
125
  foo f;
126
  printf ("returning foo\n");
127
}                              // { dg-warning "" } control reaches end
128
 
129
foo
130
warn_foo_parm_returns_foo (foo f)
131
{
132
  f;
133
}                              // { dg-warning "" } control reaches end
134
 
135
main ()                        // { dg-warning "" } no type
136
{
137
  int ii = return_1 ();
138
  if (ii != 1)
139
    abort_because ("wrong value returned");
140
  int j = return_arg (42);
141
  if (j != 42)
142
    abort_because ("wrong value returned");
143
  int k = return_sum (-69, 69);
144
  if (k != 0)
145
    abort_because ("wrong value returned");
146
  foo f1 = return_foo ();
147
  if (foo::si != 1)
148
    abort_because ("wrong number of foos");
149
  f1.i = 5;
150
  int l = foo_parm_returns_i (f1);
151
  if (l != 5)
152
    abort_because ("l != 5");
153
  foo f2 = foo_parm_returns_foo (f1);
154
  if (foo::si != 2)
155
    abort_because ("wrong number of foos");
156
  if (f2.i != 5)
157
    abort_because ("f2.i != 5");
158
  foo f3 = return_foo ();
159
  if (foo::si != 3)
160
    abort_because ("wrong number of foos");
161
  printf("PASS\n");
162
  return 0;
163
}

powered by: WebSVN 2.1.0

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