Fix: Null pointer dereference in ldlex.l
[binutils-gdb.git] / gdb / testsuite / gdb.base / pointers.c
blob96f2b52f5e8825b58ae5a8b9419c938d9938b794
2 #if !defined (__STDC__) && !defined (_AIX)
3 #define signed /**/
4 #endif
6 char v_char;
7 signed char v_signed_char;
8 unsigned char v_unsigned_char;
10 short v_short;
11 signed short v_signed_short;
12 unsigned short v_unsigned_short;
14 int v_int;
15 signed int v_signed_int;
16 unsigned int v_unsigned_int;
18 long v_long;
19 signed long v_signed_long;
20 unsigned long v_unsigned_long;
22 float v_float;
23 double v_double;
27 char *v_char_pointer;
28 signed char *v_signed_char_pointer;
29 unsigned char *v_unsigned_char_pointer;
31 short *v_short_pointer;
32 signed short *v_signed_short_pointer;
33 unsigned short *v_unsigned_short_pointer;
35 int *v_int_pointer;
36 int *v_int_pointer2;
37 signed int *v_signed_int_pointer;
38 unsigned int *v_unsigned_int_pointer;
40 long *v_long_pointer;
41 signed long *v_signed_long_pointer;
42 unsigned long *v_unsigned_long_pointer;
44 float *v_float_pointer;
45 double *v_double_pointer;
48 char v_char_array[2];
49 signed char v_signed_char_array[2];
50 unsigned char v_unsigned_char_array[2];
52 short v_short_array[2];
53 signed short v_signed_short_array[2];
54 unsigned short v_unsigned_short_array[2];
56 int v_int_array[2];
57 signed int v_signed_int_array[2];
58 unsigned int v_unsigned_int_array[2];
60 long v_long_array[2];
61 signed long v_signed_long_array[2];
62 unsigned long v_unsigned_long_array[2];
64 float v_float_array[2];
65 double v_double_array[2];
67 int matrix[2][3] = { { 0, 1, 2}, {3, 4, 5}};
68 int (*rptr)[3] = matrix;
70 float ** ptr_to_ptr_to_float;
72 int y;
75 typedef long k[5];
77 typedef struct {
78 k array_variable;
79 } S;
81 S instance;
83 /* Do nothing function used for forcing some of the above variables to
84 be referenced by the program source. If the variables are not
85 referenced, some linkers will remove the symbol from the symbol
86 table making it impossible to refer to the variable in gdb. */
87 void usevar (void *var) {}
89 int main ()
91 void dummy();
92 int more_code();
94 dummy();
96 more_code ();
98 usevar (&v_int_pointer2);
99 usevar (&rptr);
100 usevar (&y);
102 return 0;
106 void dummy()
110 v_char = 0;
111 v_signed_char = 1;
112 v_unsigned_char = 2;
114 v_short = 3;
115 v_signed_short = 4;
116 v_unsigned_short = 5;
118 v_int = 6;
119 v_signed_int = 7;
120 v_unsigned_int = 8;
122 v_long = 9;
123 v_signed_long = 10;
124 v_unsigned_long = 11;
126 v_float = 100.0;
127 v_double = 200.0;
131 v_char_pointer = &v_char;
132 v_signed_char_pointer = &v_signed_char;
133 v_unsigned_char_pointer = &v_unsigned_char;
135 v_short_pointer = &v_short;
136 v_signed_short_pointer = &v_signed_short;
137 v_unsigned_short_pointer = &v_unsigned_short;
139 v_int_pointer = &v_int;
140 v_signed_int_pointer = &v_signed_int;
141 v_unsigned_int_pointer = &v_unsigned_int;
143 v_long_pointer = &v_long;
144 v_signed_long_pointer = &v_signed_long;
145 v_unsigned_long_pointer = &v_unsigned_long;
147 v_float_pointer = &v_float;
148 v_double_pointer = &v_double;
150 ptr_to_ptr_to_float = &v_float_pointer;
153 v_char_array[0] = v_char;
154 v_signed_char_array[0] = v_signed_char;
155 v_unsigned_char_array[0] = v_unsigned_char;
157 v_short_array[0] = v_short;
158 v_signed_short_array[0] = v_signed_short;
159 v_unsigned_short_array[0] = v_unsigned_short;
161 v_int_array[0] = v_int;
162 v_int_array[1] = v_int * 3;
164 v_signed_int_array[0] = v_signed_int;
165 v_unsigned_int_array[0] = v_unsigned_int;
167 v_long_array[0] = v_long;
168 v_signed_long_array[0] = v_signed_long;
169 v_unsigned_long_array[0] = v_unsigned_long;
171 v_float_array[0] = v_float;
172 v_double_array[0] = v_double;
176 void marker1 ()
180 int more_code()
182 char C, *pC, **ppC, ***pppC, ****ppppC, *****pppppC, ******ppppppC;
183 unsigned char UC, *pUC;
184 short S, *pS;
185 unsigned short US, *pUS;
186 int I, *pI;
187 unsigned int UI, *pUI;
188 long L, *pL;
189 unsigned long UL, *pUL;
190 float F, *pF;
191 double D, *pD;
193 C = 'A';
194 UC = 21;
195 S = -14;
196 US = 7;
197 I = 102;
198 UI = 1002;
199 L = -234;
200 UL = 234;
201 F = 1.25E10;
202 D = -1.25E-37;
203 pC = &C;
204 ppC = &pC;
205 pppC = &ppC;
206 ppppC = &pppC;
207 pppppC = &ppppC;
208 ppppppC = &pppppC;
209 pUC = &UC;
210 pS = &S;
211 pUS = &US;
212 pI = &I;
213 pUI = &UI;
214 pL = &L;
215 pUL = &UL;
216 pF = &F;
217 pD = &D;
219 marker1();
220 return 0;