Handle void * conversions in FreeBSD/x86 native code to fix C++ build.
[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
e910f0b6 5void keepalive(bool *var) { }
bb869963 6void keepalive_int (int *var) { }
e910f0b6 7
76565097
DC
8// Test one.
9class gnu_obj_1
10{
11protected:
12 typedef region antiquities;
13 static const bool test = true;
14 static const int key1 = 5;
15 static long key2;
258093ca 16
76565097 17 static antiquities value;
258093ca 18
76565097
DC
19public:
20 gnu_obj_1(antiquities a, long l) {}
e234dfaf 21 ~gnu_obj_1() {}
1c809c68
TT
22
23 long method ()
24 {
bb869963 25 static int sintvar = 4;
1c809c68 26 static bool svar = true;
bb869963 27
e910f0b6 28 keepalive (&svar);
bb869963 29 keepalive_int (&sintvar);
1c809c68
TT
30 return key2;
31 }
76565097 32};
258093ca 33
fce632b6
TT
34// An object with a single constructor.
35class single_constructor
36{
37public:
38 single_constructor () { }
39 ~single_constructor () { }
40};
41
76565097
DC
42const bool gnu_obj_1::test;
43const int gnu_obj_1::key1;
44long gnu_obj_1::key2 = 77;
45gnu_obj_1::antiquities gnu_obj_1::value = oriental;
258093ca
MC
46
47
76565097
DC
48// Test two.
49template<typename T>
50class gnu_obj_2: public virtual gnu_obj_1
51{
52public:
53 static antiquities value_derived;
258093ca 54
76565097
DC
55public:
56 gnu_obj_2(antiquities b): gnu_obj_1(oriental, 7) { }
57};
258093ca 58
76565097
DC
59template<typename T>
60typename gnu_obj_2<T>::antiquities gnu_obj_2<T>::value_derived = etruscan;
258093ca 61
76565097
DC
62// Test three.
63template<typename T>
64class gnu_obj_3
65{
66public:
67 typedef region antiquities;
68 static gnu_obj_2<int> data;
258093ca 69
76565097
DC
70public:
71 gnu_obj_3(antiquities b) { }
72};
258093ca 73
76565097
DC
74template<typename T>
75gnu_obj_2<int> gnu_obj_3<T>::data(etruscan);
e70d6e3f 76
76565097
DC
77// 2002-08-16
78// Test four.
e70d6e3f 79#include "m-static.h"
258093ca
MC
80
81// instantiate templates explicitly so their static members will exist
76565097
DC
82template class gnu_obj_2<int>;
83template class gnu_obj_2<long>;
84template class gnu_obj_3<long>;
258093ca
MC
85
86int main()
87{
258093ca
MC
88 gnu_obj_1 test1(egyptian, 4589);
89 gnu_obj_2<long> test2(roman);
90 gnu_obj_3<long> test3(greek);
e70d6e3f 91 gnu_obj_4 test4;
fce632b6 92 single_constructor test5;
258093ca 93
0219b378 94 test4.dummy = test4.elsewhere;
c7e64c9a 95 test4.dummy = 0;
1c809c68
TT
96
97 test1.method (); // breakpoint: constructs-done
98
99 return test4.dummy;
258093ca 100}
This page took 1.374381 seconds and 4 git commands to generate.