URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Go to most recent revision |
Only display areas with differences |
Details |
Blame |
View Log
Rev 305 |
Rev 338 |
// { dg-do run }
|
// { dg-do run }
|
// GROUPS passed operators
|
// GROUPS passed operators
|
// Check that operators may be (directly) recursive.
|
// Check that operators may be (directly) recursive.
|
|
|
extern "C" int printf (const char *, ...);
|
extern "C" int printf (const char *, ...);
|
|
|
struct base {
|
struct base {
|
int i;
|
int i;
|
};
|
};
|
|
|
base base_variable;
|
base base_variable;
|
|
|
base operator+ (const base& left, const base& right)
|
base operator+ (const base& left, const base& right)
|
{
|
{
|
base ret_val;
|
base ret_val;
|
|
|
ret_val.i = left.i + right.i;
|
ret_val.i = left.i + right.i;
|
return ret_val;
|
return ret_val;
|
}
|
}
|
|
|
base operator- (const base& left, int right)
|
base operator- (const base& left, int right)
|
{
|
{
|
base ret_val;
|
base ret_val;
|
|
|
ret_val.i = left.i - right;
|
ret_val.i = left.i - right;
|
return ret_val;
|
return ret_val;
|
}
|
}
|
|
|
// Define the unary ! operator for class base to be the fibonachi
|
// Define the unary ! operator for class base to be the fibonachi
|
// operator.
|
// operator.
|
|
|
base operator! (const base& right)
|
base operator! (const base& right)
|
{
|
{
|
if (right.i < 2)
|
if (right.i < 2)
|
return right;
|
return right;
|
else
|
else
|
return ((!(right-1)) + (!(right-2)));
|
return ((!(right-1)) + (!(right-2)));
|
}
|
}
|
|
|
int main ()
|
int main ()
|
{
|
{
|
base k;
|
base k;
|
|
|
k.i = 15;
|
k.i = 15;
|
k = !k; // fib it!
|
k = !k; // fib it!
|
|
|
if (k.i != 610)
|
if (k.i != 610)
|
{ printf ("FAIL\n"); return 1; }
|
{ printf ("FAIL\n"); return 1; }
|
else
|
else
|
printf ("PASS\n");
|
printf ("PASS\n");
|
|
|
return 0;
|
return 0;
|
}
|
}
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.