1// 2002-05-13
2
3enum region { oriental, egyptian, greek, etruscan, roman };
4
5void keepalive(bool *var) { }
6void keepalive_int (int *var) { }
7
8// Test one.
9class gnu_obj_1
10{
11protected:
12  typedef region antiquities;
13  static const bool 	test = true;
14  static const int 	key1 = 5;
15  static long       	key2;
16
17  static antiquities 	value;
18
19public:
20  gnu_obj_1(antiquities a, long l) {}
21  ~gnu_obj_1() {}
22
23  long method ()
24  {
25    static int sintvar = 4;
26    static bool svar = true;
27
28    keepalive (&svar);
29    keepalive_int (&sintvar);
30    return key2;
31  }
32};
33
34// An object with a single constructor.
35class single_constructor
36{
37public:
38  single_constructor () { }
39  ~single_constructor () { }
40};
41
42const bool gnu_obj_1::test;
43const int gnu_obj_1::key1;
44long gnu_obj_1::key2 = 77;
45gnu_obj_1::antiquities gnu_obj_1::value = oriental;
46
47
48// Test two.
49template<typename T>
50class gnu_obj_2: public virtual gnu_obj_1
51{
52public:
53  static antiquities	value_derived;
54
55public:
56  gnu_obj_2(antiquities b): gnu_obj_1(oriental, 7) { }
57};
58
59template<typename T>
60typename gnu_obj_2<T>::antiquities gnu_obj_2<T>::value_derived = etruscan;
61
62// Test three.
63template<typename T>
64class gnu_obj_3
65{
66public:
67  typedef region antiquities;
68  static gnu_obj_2<int> data;
69
70public:
71  gnu_obj_3(antiquities b) { }
72};
73
74template<typename T>
75gnu_obj_2<int> gnu_obj_3<T>::data(etruscan);
76
77// 2002-08-16
78// Test four.
79#include "m-static.h"
80
81// instantiate templates explicitly so their static members will exist
82template class gnu_obj_2<int>;
83template class gnu_obj_2<long>;
84template class gnu_obj_3<long>;
85
86int main()
87{
88  gnu_obj_1		test1(egyptian, 4589);
89  gnu_obj_2<long>	test2(roman);
90  gnu_obj_3<long>	test3(greek);
91  gnu_obj_4		test4;
92  single_constructor	test5;
93
94  test4.dummy = test4.elsewhere;
95  test4.dummy = 0;
96
97  test1.method (); // breakpoint: constructs-done
98
99  return test4.dummy;
100}
101