]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.cp/m-static.cc
PR symtab/11464:
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.cp / m-static.cc
CommitLineData
258093ca
MC
1// 2002-05-13
2
76565097 3enum region { oriental, egyptian, greek, etruscan, roman };
258093ca 4
e910f0b6
TT
5void keepalive(bool *var) { }
6
76565097
DC
7// Test one.
8class gnu_obj_1
9{
10protected:
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
18public:
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
30const bool gnu_obj_1::test;
31const int gnu_obj_1::key1;
32long gnu_obj_1::key2 = 77;
33gnu_obj_1::antiquities gnu_obj_1::value = oriental;
258093ca
MC
34
35
76565097
DC
36// Test two.
37template<typename T>
38class gnu_obj_2: public virtual gnu_obj_1
39{
40public:
41 static antiquities value_derived;
258093ca 42
76565097
DC
43public:
44 gnu_obj_2(antiquities b): gnu_obj_1(oriental, 7) { }
45};
258093ca 46
76565097
DC
47template<typename T>
48typename gnu_obj_2<T>::antiquities gnu_obj_2<T>::value_derived = etruscan;
258093ca 49
76565097
DC
50// Test three.
51template<typename T>
52class gnu_obj_3
53{
54public:
55 typedef region antiquities;
56 static gnu_obj_2<int> data;
258093ca 57
76565097
DC
58public:
59 gnu_obj_3(antiquities b) { }
60};
258093ca 61
76565097
DC
62template<typename T>
63gnu_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
70template class gnu_obj_2<int>;
71template class gnu_obj_2<long>;
72template class gnu_obj_3<long>;
258093ca
MC
73
74int 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}