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