Debian Codegraph @

libvtv/testsuite/libvtv.cc/bb_tests.cc

raw
1 // { dg-do run }
2 struct base
3 {
4 int total;
5 virtual void add (int i) { total += i; }
6 virtual void sub (int i) { total -= i; }
7 virtual void init (void) { total = 73; }
8 };
9
10 struct derived : public base
11 {
12 int total;
13 virtual void add (int i) { total += 10 * i; }
14 virtual void sub (int i) { total -= 2 * i; }
15 virtual void init (void) { total = 0; }
16 };
17
18 bool
19 get_cond_value (int x)
20 {
21 if ((x % 3) > 0)
22 return true;
23 else
24 return false;
25
26 return false;
27 }
28
29 int
30 main (int argc, char **argv)
31 {
32 base *a;
33 bool cond_value = get_cond_value (10);
34 int x;
35
36 if (cond_value)
37 a = new base ();
38 else
39 a = new derived ();
40
41 cond_value = get_cond_value (47);
42 x = 0;
43 if (!cond_value)
44 x = 17;
45
46 a->init ();
47
48 for ( ; x < 10; ++x)
49 {
50 a->add(50);
51 a->sub(25);
52 }
53 }