gdb/doc/
[external/binutils.git] / gdb / testsuite / gdb.base / constvars.c
1 void marker1 (void)
2 {
3 }
4
5 /* misc. function params */
6
7 int
8 qux1 (const char cc, const char /*&*/ccr, const char *ccp, char *const cpc)
9 {
10   return 33;
11 }
12
13 int
14 qux2 (volatile unsigned char vuc, const volatile int cvi,
15       volatile short /*&*/vsr, volatile long *vlp, float *volatile fpv,
16       const volatile signed char *const volatile cvscpcv)
17 {
18   return 400;
19 }
20
21 int
22 main (void)
23 {
24   char lave = 'B';
25   unsigned char lavish = 10;
26   short lax = 20;
27   unsigned short lecherous = 30;
28   long lechery = 40;
29   unsigned long lectern = 50;
30   float leeway = 60;
31   double legacy = 70;
32   signed char lemonade = 35;
33
34   const char            laconic = 'A';
35   const unsigned char   laggard = 1;
36   const short           lagoon = 2;
37   const unsigned short  laity = 3;
38   const long            lambent = 4;
39   const unsigned long   laminated = 5;
40   const float           lampoon = 6;
41   const double          languid = 7;
42
43   /* pointers to constant variables */
44
45   const char           *legend      = &lave;
46   const unsigned char  *legerdemain = &lavish;
47   const short          *leniency    = &lax;
48   const unsigned short *leonine     = &lecherous;
49   const long           *lesion      = &lechery;
50   const unsigned long  *lethal      = &lectern;
51   const float          *lethargic   = &leeway;
52   const double         *levity      = &legacy;
53
54   /* constant pointers to constant variables */
55
56   const char           *const lewd          = &laconic;
57   const unsigned char  *const lexicographer = &laggard;
58   const short          *const lexicon       = &lagoon;
59   const unsigned short *const liaison       = &laity;
60   const long           *const libation      = &lambent;
61   const unsigned long  *const libelous      = &laminated;
62   const float          *const libertine     = &lampoon;
63   const double         *const libidinous    = &languid;
64
65   /* this is the same as const char * legend .... */
66
67   char           const *languish   = &laconic;
68   unsigned char  const *languor    = &laggard;
69   short          const *lank       = &lagoon;
70   unsigned short const *lapidary   = &laity;
71   long           const *larceny    = &lambent;
72   unsigned long  const *largess    = &laminated;
73   float          const *lascivious = &lampoon;
74   double         const *lassitude  = &languid;
75
76   /* constant pointers to variable */
77
78   char           *const   lamprey   = &lave;
79   unsigned char  *const   lariat    = &lavish;
80   short          *const   laudanum  = &lax;
81   unsigned short *const   lecithin  = &lecherous;
82   long           *const   leviathan = &lechery;
83   unsigned long  *const   libretto  = &lectern;
84   float          *const   lissome   = &leeway;
85   double         *const   locust    = &legacy;
86
87   /* constant arrays */
88   const char logical[2] = {laconic, laconic};
89   const unsigned char lugged[2] = {laggard, laggard};
90   const short luck[2] = {lagoon, lagoon};
91   const unsigned short lunar[2] = {laity, laity};
92   const long lumen[2] = {lambent, lambent};
93   const unsigned long lurk[2] = {laminated, laminated};
94   const float lush[2] = {lampoon, lampoon};
95   const double lynx[2] = {languid, languid};
96
97   /* volatile variables */
98
99   volatile char vox = 'X';
100   volatile unsigned char victuals = 13;
101   volatile short vixen = 200;
102   volatile unsigned short vitriol = 300;
103   volatile long vellum = 1000;
104   volatile unsigned long valve = 2000;
105   volatile float vacuity = 3.0;
106   volatile double vertigo = 10.3;
107     
108   /* pointers to volatile variables */
109
110   volatile char           * vampire = &vox;
111   volatile unsigned char  * viper  = &victuals;
112   volatile short          * vigour = &vixen;
113   volatile unsigned short * vapour = &vitriol;
114   volatile long           * ventricle = &vellum;
115   volatile unsigned long  * vigintillion = &valve;
116   volatile float          * vocation = &vacuity;
117   volatile double         * veracity = &vertigo;
118
119   /* volatile pointers to volatile variables */
120
121   volatile char           * volatile vapidity = &vox;
122   volatile unsigned char  * volatile velocity = &victuals;
123   volatile short          * volatile veneer = &vixen;
124   volatile unsigned short * volatile video = &vitriol;
125   volatile long           * volatile vacuum = &vellum;
126   volatile unsigned long  * volatile veniality = &valve;
127   volatile float          * volatile vitality = &vacuity;
128   volatile double         * volatile voracity = &vertigo;
129
130   /* const volatile vars */
131
132   const volatile char           victor = 'Y';
133   const volatile unsigned char  vicar = 11;
134
135   /* pointers to const volatiles */
136
137   const volatile char              * victory = &victor;
138   const volatile unsigned char     * vicarage = &vicar;
139
140   /* const pointers to volatile vars */
141
142   volatile char                    * const vein = &vox;
143   volatile unsigned char           * const vogue = &victuals;
144
145   /* const pointers to const volatile vars */
146
147   const volatile char              * const cavern = &victor;
148   const volatile unsigned char     * const coverlet = &vicar;
149
150   /* volatile pointers to const vars */
151
152   const char                       * volatile caveat = &laconic;
153   const unsigned char              * volatile covenant = &laggard;
154
155   /* volatile pointers to const volatile vars */
156
157   const volatile char              * volatile vizier = &victor;
158   const volatile unsigned char     * volatile vanadium = &vicar;
159
160   /* const volatile pointers */
161
162   char                             * const volatile vane = &lave;
163   unsigned char                    * const volatile veldt = &lavish;
164
165   /* const volatile pointers to const vars */
166
167   const char                       * const volatile cove = &laconic;
168   const unsigned char              * const volatile cavity = &laggard;
169     
170   /* const volatile pointers to volatile vars */
171
172   volatile char                    * const volatile vagus = &vox;
173   volatile unsigned char           * const volatile vagrancy = &victuals;
174     
175   /* const volatile pointers to const volatile */
176
177   const volatile char              * const volatile vagary = &victor;
178   const volatile unsigned char     * const volatile vendor = &vicar;
179   
180   /* various structs with const members */
181
182   struct crass { char * const ptr; } crass = { lamprey };
183   struct crisp { char * const *ptr; } crisp = { &lamprey };
184
185   /* Reference the structs so that they are not discarded.  */
186   struct crass *creed = &crass;
187   struct crisp *crow = &crisp;
188
189   /* misc. references */
190   /*
191   const char           & radiation = laconic;
192   volatile signed char & remuneration = lemonade;
193   */
194   marker1 ();
195     
196
197   return 0;
198 }