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