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