aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base/constvars.c
blob: 42288223d99b09df378b71e5ab3cd7996538fcdc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
void marker1 (void)
{
}

/* misc. function params */

int
qux1 (const char cc, const char /*&*/ccr, const char *ccp, char *const cpc)
{
  return 33;
}

int
qux2 (volatile unsigned char vuc, const volatile int cvi,
      volatile short /*&*/vsr, volatile long *vlp, float *volatile fpv,
      const volatile signed char *const volatile cvscpcv)
{
  return 400;
}

int
main (void)
{
  char lave = 'B';
  unsigned char lavish = 10;
  short lax = 20;
  unsigned short lecherous = 30;
  long lechery = 40;
  unsigned long lectern = 50;
  float leeway = 60;
  double legacy = 70;
  signed char lemonade = 35;

  const char            laconic = 'A';
  const unsigned char   laggard = 1;
  const short           lagoon = 2;
  const unsigned short  laity = 3;
  const long            lambent = 4;
  const unsigned long   laminated = 5;
  const float           lampoon = 6;
  const double          languid = 7;

  /* pointers to constant variables */

  const char           *legend      = &lave;
  const unsigned char  *legerdemain = &lavish;
  const short          *leniency    = &lax;
  const unsigned short *leonine     = &lecherous;
  const long           *lesion      = &lechery;
  const unsigned long  *lethal      = &lectern;
  const float          *lethargic   = &leeway;
  const double         *levity      = &legacy;

  /* constant pointers to constant variables */

  const char           *const lewd          = &laconic;
  const unsigned char  *const lexicographer = &laggard;
  const short          *const lexicon       = &lagoon;
  const unsigned short *const liaison       = &laity;
  const long           *const libation      = &lambent;
  const unsigned long  *const libelous      = &laminated;
  const float          *const libertine     = &lampoon;
  const double         *const libidinous    = &languid;

  /* this is the same as const char * legend .... */

  char           const *languish   = &laconic;
  unsigned char  const *languor    = &laggard;
  short          const *lank       = &lagoon;
  unsigned short const *lapidary   = &laity;
  long           const *larceny    = &lambent;
  unsigned long  const *largess    = &laminated;
  float          const *lascivious = &lampoon;
  double         const *lassitude  = &languid;

  /* constant pointers to variable */

  char           *const   lamprey   = &lave;
  unsigned char  *const   lariat    = &lavish;
  short          *const   laudanum  = &lax;
  unsigned short *const   lecithin  = &lecherous;
  long           *const   leviathan = &lechery;
  unsigned long  *const   libretto  = &lectern;
  float          *const   lissome   = &leeway;
  double         *const   locust    = &legacy;

  /* constant arrays */
  const char logical[2] = {laconic, laconic};
  const unsigned char lugged[2] = {laggard, laggard};
  const short luck[2] = {lagoon, lagoon};
  const unsigned short lunar[2] = {laity, laity};
  const long lumen[2] = {lambent, lambent};
  const unsigned long lurk[2] = {laminated, laminated};
  const float lush[2] = {lampoon, lampoon};
  const double lynx[2] = {languid, languid};

  /* volatile variables */

  volatile char vox = 'X';
  volatile unsigned char victuals = 13;
  volatile short vixen = 200;
  volatile unsigned short vitriol = 300;
  volatile long vellum = 1000;
  volatile unsigned long valve = 2000;
  volatile float vacuity = 3.0;
  volatile double vertigo = 10.3;
    
  /* pointers to volatile variables */

  volatile char           * vampire = &vox;
  volatile unsigned char  * viper  = &victuals;
  volatile short          * vigour = &vixen;
  volatile unsigned short * vapour = &vitriol;
  volatile long           * ventricle = &vellum;
  volatile unsigned long  * vigintillion = &valve;
  volatile float          * vocation = &vacuity;
  volatile double         * veracity = &vertigo;

  /* volatile pointers to volatile variables */

  volatile char           * volatile vapidity = &vox;
  volatile unsigned char  * volatile velocity = &victuals;
  volatile short          * volatile veneer = &vixen;
  volatile unsigned short * volatile video = &vitriol;
  volatile long           * volatile vacuum = &vellum;
  volatile unsigned long  * volatile veniality = &valve;
  volatile float          * volatile vitality = &vacuity;
  volatile double         * volatile voracity = &vertigo;

  /* const volatile vars */

  const volatile char           victor = 'Y';
  const volatile unsigned char  vicar = 11;

  /* pointers to const volatiles */

  const volatile char              * victory = &victor;
  const volatile unsigned char     * vicarage = &vicar;

  /* const pointers to volatile vars */

  volatile char                    * const vein = &vox;
  volatile unsigned char           * const vogue = &victuals;

  /* const pointers to const volatile vars */

  const volatile char              * const cavern = &victor;
  const volatile unsigned char     * const coverlet = &vicar;

  /* volatile pointers to const vars */

  const char                       * volatile caveat = &laconic;
  const unsigned char              * volatile covenant = &laggard;

  /* volatile pointers to const volatile vars */

  const volatile char              * volatile vizier = &victor;
  const volatile unsigned char     * volatile vanadium = &vicar;

  /* const volatile pointers */

  char                             * const volatile vane = &lave;
  unsigned char                    * const volatile veldt = &lavish;

  /* const volatile pointers to const vars */

  const char                       * const volatile cove = &laconic;
  const unsigned char              * const volatile cavity = &laggard;
    
  /* const volatile pointers to volatile vars */

  volatile char                    * const volatile vagus = &vox;
  volatile unsigned char           * const volatile vagrancy = &victuals;
    
  /* const volatile pointers to const volatile */

  const volatile char              * const volatile vagary = &victor;
  const volatile unsigned char     * const volatile vendor = &vicar;
  
  /* various structs with const members */

  struct crass { char * const ptr; } crass = { lamprey };
  struct crisp { char * const *ptr; } crisp = { &lamprey };

  /* Reference the structs so that they are not discarded.  */
  struct crass *creed = &crass;
  struct crisp *crow = &crisp;

  /* misc. references */
  /*
  const char           & radiation = laconic;
  volatile signed char & remuneration = lemonade;
  */
  marker1 ();
    

  return 0;
}