xref: /illumos-gate/usr/src/cmd/dtrace/test/tst/common/offsetof/tst.anon.c (revision 8b184c19c5f61fa8890900f7bab686bf19b543d3)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2025 Oxide Computer Company
14  */
15 
16 /*
17  * This contains a few anonymous structs and unions (nested), that test that the
18  * D language offsetof works correctly in these cases.
19  */
20 
21 struct foo {
22 	int a;
23 	union {
24 		int b;
25 		int c;
26 		struct {
27 			int d;
28 			int e;
29 			int f;
30 		};
31 		int g[3];
32 	};
33 	struct {
34 		int h;
35 		union {
36 			int i;
37 			struct {
38 				int j;
39 				union {
40 					int k;
41 					struct {
42 						int l;
43 						int m;
44 						union {
45 							int n;
46 							struct {
47 								int o;
48 							};
49 						};
50 						int p;
51 					};
52 					int q;
53 				};
54 				int r;
55 			};
56 			int s;
57 		};
58 		int t;
59 	};
60 };
61 
62 struct foo foo;
63 
64 int
main(void)65 main(void)
66 {
67 	return (0);
68 }
69