]> git.lizzy.rs Git - rust.git/blob - tests/run-make-fulldeps/return-non-c-like-enum/test.c
Rollup merge of #106766 - GuillaumeGomez:rm-stripper-dead-code, r=notriddle
[rust.git] / tests / run-make-fulldeps / return-non-c-like-enum / test.c
1 #include <stdint.h>
2 #include <assert.h>
3
4 /* This is the code generated by cbindgen 0.12.1 for the `enum TT`
5  * type in nonclike.rs . */
6 enum TT_Tag {
7   AA,
8   BB,
9 };
10 typedef uint8_t TT_Tag;
11
12 typedef struct {
13   uint64_t _0;
14   uint64_t _1;
15 } AA_Body;
16
17 typedef struct {
18   TT_Tag tag;
19   union {
20     AA_Body aa;
21   };
22 } TT;
23
24 /* This is the code generated by cbindgen 0.12.1 for the `enum T` type
25  * in nonclike.rs . */
26 enum T_Tag {
27   A,
28   B,
29 };
30 typedef uint8_t T_Tag;
31
32 typedef struct {
33   uint64_t _0;
34 } A_Body;
35
36 typedef struct {
37   T_Tag tag;
38   union {
39     A_Body a;
40   };
41 } T;
42
43 /* These symbols are defined by the Rust staticlib built from
44  * nonclike.rs. */
45 extern TT tt_new(uint64_t a, uint64_t b);
46 extern T t_new(uint64_t v);
47
48 int main(int argc, char *argv[]) {
49   (void)argc; (void)argv;
50
51   /* This example works. */
52   TT tt = tt_new(10, 20);
53   assert(AA == tt.tag);
54   assert(10 == tt.aa._0);
55   assert(20 == tt.aa._1);
56
57   /* This one used to segfault (see issue #68190). */
58   T t = t_new(10);
59   assert(A == t.tag);
60   assert(10 == t.a._0);
61
62   return 0;
63 }