diff options
Diffstat (limited to 'gcc/testsuite/g++.old-deja/g++.brendan/operators5.C')
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.brendan/operators5.C | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/operators5.C b/gcc/testsuite/g++.old-deja/g++.brendan/operators5.C new file mode 100644 index 00000000000..84c09a2a4b2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/operators5.C @@ -0,0 +1,52 @@ +// GROUPS passed operators +// Check that operators may be (directly) recursive. + +extern "C" void printf (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"); + else + printf ("PASS\n"); + + return 0; +} |