Retro68/gcc/libvtv/testsuite/libvtv.cc/bb_tests.cc

54 lines
806 B
C++
Raw Normal View History

2014-09-21 17:33:12 +00:00
// { dg-do run }
struct base
{
int total;
virtual void add (int i) { total += i; }
virtual void sub (int i) { total -= i; }
virtual void init (void) { total = 73; }
};
struct derived : public base
{
int total;
virtual void add (int i) { total += 10 * i; }
virtual void sub (int i) { total -= 2 * i; }
virtual void init (void) { total = 0; }
};
bool
get_cond_value (int x)
{
if ((x % 3) > 0)
return true;
else
return false;
return false;
}
int
main (int argc, char **argv)
{
base *a;
bool cond_value = get_cond_value (10);
int x;
if (cond_value)
a = new base ();
else
a = new derived ();
cond_value = get_cond_value (47);
x = 0;
if (!cond_value)
x = 17;
a->init ();
for ( ; x < 10; ++x)
{
a->add(50);
a->sub(25);
}
}