binutils-gdb/gdb/testsuite/gdb.base/constvars.c
Mark Wielaard cf363f183d Handle volatile array types in dwarf2read.c.
read_tag_const_type propagates the cv-qualifier to the array element type,
but read_tag_volatile_type didn't. Make sure that both cv-qualifiers that
apply to array types are handled the same.

gdb/ChangeLog

	* dwarf2read.c (add_array_cv_type): New function.
	(read_tag_const_type): Call add_array_cv_type for TYPE_CODE_ARRAY.
	(read_tag_volatile_type): Likewise.

gdb/testsuite/ChangeLog

	* gdb.base/constvars.c (violent, violet, vips, virgen, vulgar,
	vulture, vilify, villar): New volatile array constants.
	(vindictive, vegetation): New const volatile array constants.
	* gdb.base/volatile.exp: Test volatile and const volatile array
	types.
2014-07-01 22:11:53 +02:00

213 lines
6.9 KiB
C

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;
/* volatile arrays */
volatile char violent[2] = {vox, vox};
volatile unsigned char violet[2] = {victuals, victuals};
volatile short vips[2] = {vixen, vixen};
volatile unsigned short virgen[2] = {vitriol, vitriol};
volatile long vulgar[2] = {vellum, vellum};
volatile unsigned long vulture[2] = {valve, valve};
volatile float vilify[2] = {vacuity, vacuity};
volatile double villar[2] = {vertigo, 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;
/* const volatile arrays */
const volatile char vindictive[2] = {victor, victor};
const volatile unsigned char vegetation[2] = {vicar, 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;
}