From: Sergio Durigan Junior <sergiodj@redhat.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / m-static.cc
1 // 2002-05-13
2
3 enum region { oriental, egyptian, greek, etruscan, roman };
4
5 void keepalive(bool *var) { }
6 void keepalive_int (int *var) { }
7
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;
16
17 static antiquities value;
18
19 public:
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 const bool gnu_obj_1::test;
35 const int gnu_obj_1::key1;
36 long gnu_obj_1::key2 = 77;
37 gnu_obj_1::antiquities gnu_obj_1::value = oriental;
38
39
40 // Test two.
41 template<typename T>
42 class gnu_obj_2: public virtual gnu_obj_1
43 {
44 public:
45 static antiquities value_derived;
46
47 public:
48 gnu_obj_2(antiquities b): gnu_obj_1(oriental, 7) { }
49 };
50
51 template<typename T>
52 typename gnu_obj_2<T>::antiquities gnu_obj_2<T>::value_derived = etruscan;
53
54 // Test three.
55 template<typename T>
56 class gnu_obj_3
57 {
58 public:
59 typedef region antiquities;
60 static gnu_obj_2<int> data;
61
62 public:
63 gnu_obj_3(antiquities b) { }
64 };
65
66 template<typename T>
67 gnu_obj_2<int> gnu_obj_3<T>::data(etruscan);
68
69 // 2002-08-16
70 // Test four.
71 #include "m-static.h"
72
73 // instantiate templates explicitly so their static members will exist
74 template class gnu_obj_2<int>;
75 template class gnu_obj_2<long>;
76 template class gnu_obj_3<long>;
77
78 int main()
79 {
80 gnu_obj_1 test1(egyptian, 4589);
81 gnu_obj_2<long> test2(roman);
82 gnu_obj_3<long> test3(greek);
83 gnu_obj_4 test4;
84
85 test4.dummy = test4.elsewhere;
86 test4.dummy = 0;
87
88 test1.method (); // breakpoint: constructs-done
89
90 return test4.dummy;
91 }
This page took 0.046256 seconds and 4 git commands to generate.