1/* This testcase is part of GDB, the GNU debugger.
2
3   Copyright 2014-2023 Free Software Foundation, Inc.
4
5   This program is free software; you can redistribute it and/or modify
6   it under the terms of the GNU General Public License as published by
7   the Free Software Foundation; either version 3 of the License, or
8   (at your option) any later version.
9
10   This program is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   GNU General Public License for more details.
14
15   You should have received a copy of the GNU General Public License
16   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
17
18#include <stddef.h>
19#define SIZE 5
20
21struct foo
22{
23  int a;
24};
25
26typedef struct bar
27{
28  int x;
29  struct foo y;
30} BAR;
31
32void
33vla_factory (int n)
34{
35  int             int_vla[n];
36  unsigned int    unsigned_int_vla[n];
37  double          double_vla[n];
38  float           float_vla[n];
39  long            long_vla[n];
40  unsigned long   unsigned_long_vla[n];
41  char            char_vla[n];
42  short           short_vla[n];
43  unsigned short  unsigned_short_vla[n];
44  unsigned char   unsigned_char_vla[n];
45  struct foo      foo_vla[n];
46  BAR             bar_vla[n];
47  int i;
48
49  for (i = 0; i < n; i++)
50    {
51      int_vla[i] = i*2;
52      unsigned_int_vla[i] = i*2;
53      double_vla[i] = i/2.0;
54      float_vla[i] = i/2.0f;
55      long_vla[i] = i*2;
56      unsigned_long_vla[i] = i*2;
57      char_vla[i] = 'A';
58      short_vla[i] = i*2;
59      unsigned_short_vla[i] = i*2;
60      unsigned_char_vla[i] = 'A';
61      foo_vla[i].a = i*2;
62      bar_vla[i].x = i*2;
63      bar_vla[i].y.a = i*2;
64    }
65
66  size_t int_size        = sizeof(int_vla);     /* vlas_filled */
67  size_t uint_size       = sizeof(unsigned_int_vla);
68  size_t double_size     = sizeof(double_vla);
69  size_t float_size      = sizeof(float_vla);
70  size_t long_size       = sizeof(long_vla);
71  size_t char_size       = sizeof(char_vla);
72  size_t short_size      = sizeof(short_vla);
73  size_t ushort_size     = sizeof(unsigned_short_vla);
74  size_t uchar_size      = sizeof(unsigned_char_vla);
75  size_t foo_size        = sizeof(foo_vla);
76  size_t bar_size        = sizeof(bar_vla);
77
78  return;                                 /* break_end_of_vla_factory */
79}
80
81int
82main (void)
83{
84  vla_factory(SIZE);
85  return 0;
86}
87