]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.cp/cpsizeof.cc
384c0a433dbd18868f8cca33d0246e907487fb68
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.cp / cpsizeof.cc
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 struct Class
19 {
20 int a;
21 char b;
22 long c;
23
24 Class () : a (1), b ('2'), c (3) { }
25 };
26
27 union Union
28 {
29 Class *kp;
30 char a;
31 int b;
32 long c;
33 };
34
35 enum Enum { A, B, C, D };
36
37 typedef unsigned char a4[4];
38 typedef unsigned char a8[8];
39 typedef unsigned char a12[12];
40 typedef Class c4[4];
41 typedef Union u8[8];
42 typedef Enum e12[12];
43
44 #define T(N) \
45 N N ## obj; \
46 N& N ## _ref = N ## obj; \
47 N* N ## p = &(N ## obj); \
48 N*& N ## p_ref = N ## p; \
49 int size_ ## N = sizeof (N ## _ref); \
50 int size_ ## N ## p = sizeof (N ## p_ref); \
51
52 int
53 main (void)
54 {
55 T (char);
56 T (int);
57 T (long);
58 T (float);
59 T (double);
60 T (a4);
61 T (a8);
62 T (a12);
63 T (Class);
64 T (Union);
65 T (Enum);
66 T (c4);
67 T (u8);
68 T (e12);
69
70 return 0; /* break here */
71 }