blob: dedec90456803b842b44d6ed032cb5998faaff1c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
// { dg-do run }
// GROUPS passed operators
// Check that operators may be (directly) recursive.
extern "C" int printf (const char *, ...);
struct base {
int i;
};
base base_variable;
base operator+ (const base& left, const base& right)
{
base ret_val;
ret_val.i = left.i + right.i;
return ret_val;
}
base operator- (const base& left, int right)
{
base ret_val;
ret_val.i = left.i - right;
return ret_val;
}
// Define the unary ! operator for class base to be the fibonachi
// operator.
base operator! (const base& right)
{
if (right.i < 2)
return right;
else
return ((!(right-1)) + (!(right-2)));
}
int main ()
{
base k;
k.i = 15;
k = !k; // fib it!
if (k.i != 610)
{ printf ("FAIL\n"); return 1; }
else
printf ("PASS\n");
return 0;
}
|