[gdbserver] Move malloc.h include to server.h.
[deliverable/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
76565097
DC
5// Test one.
6class gnu_obj_1
7{
8protected:
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
16public:
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
26const bool gnu_obj_1::test;
27const int gnu_obj_1::key1;
28long gnu_obj_1::key2 = 77;
29gnu_obj_1::antiquities gnu_obj_1::value = oriental;
258093ca
MC
30
31
76565097
DC
32// Test two.
33template<typename T>
34class gnu_obj_2: public virtual gnu_obj_1
35{
36public:
37 static antiquities value_derived;
258093ca 38
76565097
DC
39public:
40 gnu_obj_2(antiquities b): gnu_obj_1(oriental, 7) { }
41};
258093ca 42
76565097
DC
43template<typename T>
44typename gnu_obj_2<T>::antiquities gnu_obj_2<T>::value_derived = etruscan;
258093ca 45
76565097
DC
46// Test three.
47template<typename T>
48class gnu_obj_3
49{
50public:
51 typedef region antiquities;
52 static gnu_obj_2<int> data;
258093ca 53
76565097
DC
54public:
55 gnu_obj_3(antiquities b) { }
56};
258093ca 57
76565097
DC
58template<typename T>
59gnu_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
66template class gnu_obj_2<int>;
67template class gnu_obj_2<long>;
68template class gnu_obj_3<long>;
258093ca
MC
69
70int 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}
This page took 0.792496 seconds and 4 git commands to generate.