Debian Codegraph @

gcc/testsuite/g++.old-deja/g++.law/arm15.C

raw
1 // { dg-do run }
2 // GROUPS passed ARM-compliance
3 // arm file
4 // From: Johan Bengtsson <[email protected]>
5 // Date: Thu, 21 Oct 93 16:10:25 +0100
6 // Subject: gcc 2.4.5 initializes base classes in mem-initializer order
7 // Message-ID: <[email protected]>
8
9 #include <stdio.h>
10 #include <stdlib.h>
11
12 int state = 0;
13
14 class A { public:
15 A() {
16 if (state == 0)
17 state = 1;
18 else {
19 printf ("FAIL\n");
20 exit (1);
21 }
22 }
23 };
24
25 class B { public:
26 B() {
27 if (state == 1)
28 state = 2;
29 else {
30 printf ("FAIL\n");
31 exit (1);
32 }
33 }
34 };
35
36 class AB : public A, public B { public:
37 AB() : B(), A() {
38 if (state == 2)
39 state = 3;
40 else {
41 printf ("FAIL\n");
42 exit (1);
43 }
44 }
45 };
46
47 int main()
48 {
49 AB ab;
50 if (state == 3)
51 printf("PASS\n");
52 else
53 printf("FAIL\n");
54 exit (state != 3);
55 }