2013-11-15 13:47:47 +01:00
|
|
|
/* This testcase is part of GDB, the GNU debugger.
|
|
|
|
|
2018-01-01 05:43:02 +01:00
|
|
|
Copyright 2014-2018 Free Software Foundation, Inc.
|
2013-11-15 13:47:47 +01:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#define SIZE 5
|
|
|
|
|
|
|
|
struct foo
|
|
|
|
{
|
|
|
|
int a;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct bar
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
struct foo y;
|
|
|
|
} BAR;
|
|
|
|
|
|
|
|
void
|
|
|
|
vla_factory (int n)
|
|
|
|
{
|
|
|
|
int int_vla[n];
|
|
|
|
unsigned int unsigned_int_vla[n];
|
|
|
|
double double_vla[n];
|
|
|
|
float float_vla[n];
|
|
|
|
long long_vla[n];
|
|
|
|
unsigned long unsigned_long_vla[n];
|
|
|
|
char char_vla[n];
|
|
|
|
short short_vla[n];
|
|
|
|
unsigned short unsigned_short_vla[n];
|
|
|
|
unsigned char unsigned_char_vla[n];
|
|
|
|
struct foo foo_vla[n];
|
|
|
|
BAR bar_vla[n];
|
|
|
|
int i;
|
|
|
|
|
2014-05-08 19:26:44 +02:00
|
|
|
struct vla_struct
|
|
|
|
{
|
|
|
|
int something;
|
|
|
|
int vla_field[n];
|
|
|
|
} vla_struct_object;
|
|
|
|
|
|
|
|
struct inner_vla_struct
|
|
|
|
{
|
|
|
|
int something;
|
|
|
|
int vla_field[n];
|
|
|
|
int after;
|
|
|
|
} inner_vla_struct_object;
|
|
|
|
|
|
|
|
union vla_union
|
|
|
|
{
|
|
|
|
int vla_field[n];
|
|
|
|
} vla_union_object;
|
|
|
|
|
|
|
|
vla_struct_object.something = n;
|
|
|
|
inner_vla_struct_object.something = n;
|
|
|
|
inner_vla_struct_object.after = n;
|
2013-11-15 13:47:47 +01:00
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
{
|
|
|
|
int_vla[i] = i*2;
|
|
|
|
unsigned_int_vla[i] = i*2;
|
|
|
|
double_vla[i] = i/2.0;
|
|
|
|
float_vla[i] = i/2.0f;
|
|
|
|
long_vla[i] = i*2;
|
|
|
|
unsigned_long_vla[i] = i*2;
|
|
|
|
char_vla[i] = 'A';
|
|
|
|
short_vla[i] = i*2;
|
|
|
|
unsigned_short_vla[i] = i*2;
|
|
|
|
unsigned_char_vla[i] = 'A';
|
|
|
|
foo_vla[i].a = i*2;
|
|
|
|
bar_vla[i].x = i*2;
|
|
|
|
bar_vla[i].y.a = i*2;
|
2014-05-08 19:26:44 +02:00
|
|
|
vla_struct_object.vla_field[i] = i*2;
|
|
|
|
vla_union_object.vla_field[i] = i*2;
|
|
|
|
inner_vla_struct_object.vla_field[i] = i*2;
|
2013-11-15 13:47:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t int_size = sizeof(int_vla); /* vlas_filled */
|
|
|
|
size_t uint_size = sizeof(unsigned_int_vla);
|
|
|
|
size_t double_size = sizeof(double_vla);
|
|
|
|
size_t float_size = sizeof(float_vla);
|
|
|
|
size_t long_size = sizeof(long_vla);
|
|
|
|
size_t char_size = sizeof(char_vla);
|
|
|
|
size_t short_size = sizeof(short_vla);
|
|
|
|
size_t ushort_size = sizeof(unsigned_short_vla);
|
|
|
|
size_t uchar_size = sizeof(unsigned_char_vla);
|
|
|
|
size_t foo_size = sizeof(foo_vla);
|
|
|
|
size_t bar_size = sizeof(bar_vla);
|
2014-05-08 19:26:44 +02:00
|
|
|
size_t vla_struct_object_size = sizeof(vla_struct_object);
|
|
|
|
size_t vla_union_object_size = sizeof(vla_union_object);
|
2014-07-08 17:15:35 +02:00
|
|
|
size_t inner_vla_struct_object_size = sizeof(inner_vla_struct_object);
|
2013-11-15 13:47:47 +01:00
|
|
|
|
|
|
|
return; /* break_end_of_vla_factory */
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main (void)
|
|
|
|
{
|
|
|
|
vla_factory(SIZE);
|
|
|
|
return 0;
|
|
|
|
}
|