xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.base/pointers.c (revision a5a4af3bd380a7b58b758d9b311cef9f7c34aeb4)
1*a5a4af3bSchristos 
2*a5a4af3bSchristos #if !defined (__STDC__) && !defined (_AIX)
3*a5a4af3bSchristos #define signed  /**/
4*a5a4af3bSchristos #endif
5*a5a4af3bSchristos 
6*a5a4af3bSchristos char		v_char;
7*a5a4af3bSchristos signed char	v_signed_char;
8*a5a4af3bSchristos unsigned char	v_unsigned_char;
9*a5a4af3bSchristos 
10*a5a4af3bSchristos short		v_short;
11*a5a4af3bSchristos signed short	v_signed_short;
12*a5a4af3bSchristos unsigned short	v_unsigned_short;
13*a5a4af3bSchristos 
14*a5a4af3bSchristos int		v_int;
15*a5a4af3bSchristos signed int	v_signed_int;
16*a5a4af3bSchristos unsigned int	v_unsigned_int;
17*a5a4af3bSchristos 
18*a5a4af3bSchristos long		v_long;
19*a5a4af3bSchristos signed long	v_signed_long;
20*a5a4af3bSchristos unsigned long	v_unsigned_long;
21*a5a4af3bSchristos 
22*a5a4af3bSchristos float		v_float;
23*a5a4af3bSchristos double		v_double;
24*a5a4af3bSchristos 
25*a5a4af3bSchristos 
26*a5a4af3bSchristos 
27*a5a4af3bSchristos char		*v_char_pointer;
28*a5a4af3bSchristos signed char	*v_signed_char_pointer;
29*a5a4af3bSchristos unsigned char	*v_unsigned_char_pointer;
30*a5a4af3bSchristos 
31*a5a4af3bSchristos short		*v_short_pointer;
32*a5a4af3bSchristos signed short	*v_signed_short_pointer;
33*a5a4af3bSchristos unsigned short	*v_unsigned_short_pointer;
34*a5a4af3bSchristos 
35*a5a4af3bSchristos int		*v_int_pointer;
36*a5a4af3bSchristos int             *v_int_pointer2;
37*a5a4af3bSchristos signed int	*v_signed_int_pointer;
38*a5a4af3bSchristos unsigned int	*v_unsigned_int_pointer;
39*a5a4af3bSchristos 
40*a5a4af3bSchristos long		*v_long_pointer;
41*a5a4af3bSchristos signed long	*v_signed_long_pointer;
42*a5a4af3bSchristos unsigned long	*v_unsigned_long_pointer;
43*a5a4af3bSchristos 
44*a5a4af3bSchristos float		*v_float_pointer;
45*a5a4af3bSchristos double		*v_double_pointer;
46*a5a4af3bSchristos 
47*a5a4af3bSchristos 
48*a5a4af3bSchristos char		v_char_array[2];
49*a5a4af3bSchristos signed char	v_signed_char_array[2];
50*a5a4af3bSchristos unsigned char	v_unsigned_char_array[2];
51*a5a4af3bSchristos 
52*a5a4af3bSchristos short		v_short_array[2];
53*a5a4af3bSchristos signed short	v_signed_short_array[2];
54*a5a4af3bSchristos unsigned short	v_unsigned_short_array[2];
55*a5a4af3bSchristos 
56*a5a4af3bSchristos int		v_int_array[2];
57*a5a4af3bSchristos signed int	v_signed_int_array[2];
58*a5a4af3bSchristos unsigned int	v_unsigned_int_array[2];
59*a5a4af3bSchristos 
60*a5a4af3bSchristos long		v_long_array[2];
61*a5a4af3bSchristos signed long	v_signed_long_array[2];
62*a5a4af3bSchristos unsigned long	v_unsigned_long_array[2];
63*a5a4af3bSchristos 
64*a5a4af3bSchristos float		v_float_array[2];
65*a5a4af3bSchristos double		v_double_array[2];
66*a5a4af3bSchristos 
67*a5a4af3bSchristos int matrix[2][3] = { { 0, 1, 2}, {3, 4, 5}};
68*a5a4af3bSchristos int (*rptr)[3] = matrix;
69*a5a4af3bSchristos 
70*a5a4af3bSchristos float ** ptr_to_ptr_to_float;
71*a5a4af3bSchristos 
72*a5a4af3bSchristos int y;
73*a5a4af3bSchristos 
74*a5a4af3bSchristos 
75*a5a4af3bSchristos typedef long k[5];
76*a5a4af3bSchristos 
77*a5a4af3bSchristos typedef struct {
78*a5a4af3bSchristos   k array_variable;
79*a5a4af3bSchristos } S;
80*a5a4af3bSchristos 
81*a5a4af3bSchristos S instance;
82*a5a4af3bSchristos 
83*a5a4af3bSchristos /* Do nothing function used for forcing some of the above variables to
84*a5a4af3bSchristos    be referenced by the program source.  If the variables are not
85*a5a4af3bSchristos    referenced, some linkers will remove the symbol from the symbol
86*a5a4af3bSchristos    table making it impossible to refer to the variable in gdb.  */
usevar(void * var)87*a5a4af3bSchristos void usevar (void *var) {}
88*a5a4af3bSchristos 
main()89*a5a4af3bSchristos int main ()
90*a5a4af3bSchristos {
91*a5a4af3bSchristos   void dummy();
92*a5a4af3bSchristos   int more_code();
93*a5a4af3bSchristos 
94*a5a4af3bSchristos   dummy();
95*a5a4af3bSchristos 
96*a5a4af3bSchristos   more_code ();
97*a5a4af3bSchristos 
98*a5a4af3bSchristos   usevar (&v_int_pointer2);
99*a5a4af3bSchristos   usevar (&rptr);
100*a5a4af3bSchristos   usevar (&y);
101*a5a4af3bSchristos 
102*a5a4af3bSchristos   return 0;
103*a5a4af3bSchristos 
104*a5a4af3bSchristos }
105*a5a4af3bSchristos 
dummy()106*a5a4af3bSchristos void dummy()
107*a5a4af3bSchristos {
108*a5a4af3bSchristos 
109*a5a4af3bSchristos 
110*a5a4af3bSchristos   v_char = 0;
111*a5a4af3bSchristos   v_signed_char = 1;
112*a5a4af3bSchristos   v_unsigned_char = 2;
113*a5a4af3bSchristos 
114*a5a4af3bSchristos   v_short = 3;
115*a5a4af3bSchristos   v_signed_short = 4;
116*a5a4af3bSchristos   v_unsigned_short = 5;
117*a5a4af3bSchristos 
118*a5a4af3bSchristos   v_int = 6;
119*a5a4af3bSchristos   v_signed_int = 7;
120*a5a4af3bSchristos   v_unsigned_int = 8;
121*a5a4af3bSchristos 
122*a5a4af3bSchristos   v_long = 9;
123*a5a4af3bSchristos   v_signed_long = 10;
124*a5a4af3bSchristos   v_unsigned_long = 11;
125*a5a4af3bSchristos 
126*a5a4af3bSchristos   v_float = 100.0;
127*a5a4af3bSchristos   v_double = 200.0;
128*a5a4af3bSchristos 
129*a5a4af3bSchristos 
130*a5a4af3bSchristos 
131*a5a4af3bSchristos   v_char_pointer = &v_char;
132*a5a4af3bSchristos   v_signed_char_pointer = &v_signed_char;
133*a5a4af3bSchristos   v_unsigned_char_pointer = &v_unsigned_char;
134*a5a4af3bSchristos 
135*a5a4af3bSchristos   v_short_pointer = &v_short;
136*a5a4af3bSchristos   v_signed_short_pointer = &v_signed_short;
137*a5a4af3bSchristos   v_unsigned_short_pointer = &v_unsigned_short;
138*a5a4af3bSchristos 
139*a5a4af3bSchristos   v_int_pointer = &v_int;
140*a5a4af3bSchristos   v_signed_int_pointer = &v_signed_int;
141*a5a4af3bSchristos   v_unsigned_int_pointer = &v_unsigned_int;
142*a5a4af3bSchristos 
143*a5a4af3bSchristos   v_long_pointer = &v_long;
144*a5a4af3bSchristos   v_signed_long_pointer = &v_signed_long;
145*a5a4af3bSchristos   v_unsigned_long_pointer = &v_unsigned_long;
146*a5a4af3bSchristos 
147*a5a4af3bSchristos   v_float_pointer = &v_float;
148*a5a4af3bSchristos   v_double_pointer = &v_double;
149*a5a4af3bSchristos 
150*a5a4af3bSchristos   ptr_to_ptr_to_float = &v_float_pointer;
151*a5a4af3bSchristos 
152*a5a4af3bSchristos 
153*a5a4af3bSchristos   v_char_array[0] = v_char;
154*a5a4af3bSchristos   v_signed_char_array[0] = v_signed_char;
155*a5a4af3bSchristos   v_unsigned_char_array[0] = v_unsigned_char;
156*a5a4af3bSchristos 
157*a5a4af3bSchristos   v_short_array[0] = v_short;
158*a5a4af3bSchristos   v_signed_short_array[0] = v_signed_short;
159*a5a4af3bSchristos   v_unsigned_short_array[0] = v_unsigned_short;
160*a5a4af3bSchristos 
161*a5a4af3bSchristos   v_int_array[0] = v_int;
162*a5a4af3bSchristos   v_int_array[1] = v_int * 3;
163*a5a4af3bSchristos 
164*a5a4af3bSchristos   v_signed_int_array[0] = v_signed_int;
165*a5a4af3bSchristos   v_unsigned_int_array[0] = v_unsigned_int;
166*a5a4af3bSchristos 
167*a5a4af3bSchristos   v_long_array[0] = v_long;
168*a5a4af3bSchristos   v_signed_long_array[0] = v_signed_long;
169*a5a4af3bSchristos   v_unsigned_long_array[0] = v_unsigned_long;
170*a5a4af3bSchristos 
171*a5a4af3bSchristos   v_float_array[0] = v_float;
172*a5a4af3bSchristos   v_double_array[0] = v_double;
173*a5a4af3bSchristos 
174*a5a4af3bSchristos }
175*a5a4af3bSchristos 
marker1()176*a5a4af3bSchristos void marker1 ()
177*a5a4af3bSchristos {
178*a5a4af3bSchristos }
179*a5a4af3bSchristos 
more_code()180*a5a4af3bSchristos int more_code()
181*a5a4af3bSchristos {
182*a5a4af3bSchristos     char C, *pC, **ppC, ***pppC, ****ppppC, *****pppppC, ******ppppppC;
183*a5a4af3bSchristos     unsigned char UC, *pUC;
184*a5a4af3bSchristos     short S, *pS;
185*a5a4af3bSchristos     unsigned short US, *pUS;
186*a5a4af3bSchristos     int I, *pI;
187*a5a4af3bSchristos     unsigned int UI, *pUI;
188*a5a4af3bSchristos     long L, *pL;
189*a5a4af3bSchristos     unsigned long UL, *pUL;
190*a5a4af3bSchristos     float F, *pF;
191*a5a4af3bSchristos     double D, *pD;
192*a5a4af3bSchristos 
193*a5a4af3bSchristos     C = 'A';
194*a5a4af3bSchristos     UC = 21;
195*a5a4af3bSchristos     S = -14;
196*a5a4af3bSchristos     US = 7;
197*a5a4af3bSchristos     I = 102;
198*a5a4af3bSchristos     UI = 1002;
199*a5a4af3bSchristos     L = -234;
200*a5a4af3bSchristos     UL = 234;
201*a5a4af3bSchristos     F = 1.25E10;
202*a5a4af3bSchristos     D = -1.25E-37;
203*a5a4af3bSchristos     pC = &C;
204*a5a4af3bSchristos     ppC = &pC;
205*a5a4af3bSchristos     pppC = &ppC;
206*a5a4af3bSchristos     ppppC = &pppC;
207*a5a4af3bSchristos     pppppC = &ppppC;
208*a5a4af3bSchristos     ppppppC = &pppppC;
209*a5a4af3bSchristos     pUC = &UC;
210*a5a4af3bSchristos     pS = &S;
211*a5a4af3bSchristos     pUS = &US;
212*a5a4af3bSchristos     pI = &I;
213*a5a4af3bSchristos     pUI = &UI;
214*a5a4af3bSchristos     pL = &L;
215*a5a4af3bSchristos     pUL = &UL;
216*a5a4af3bSchristos     pF = &F;
217*a5a4af3bSchristos     pD = &D;
218*a5a4af3bSchristos 
219*a5a4af3bSchristos     marker1();
220*a5a4af3bSchristos     return 0;
221*a5a4af3bSchristos }
222