gcc/testsuite/gdc.test/compilable/dtoh_UnionDeclaration.d
raw| 1 | /+ |
| 2 | REQUIRED_ARGS: -o- -HC |
| 3 | |
| 4 | TEST_OUTPUT: |
| 5 | --- |
| 6 | // Automatically generated by Digital Mars D Compiler |
| 7 | |
| 8 | #pragma once |
| 9 | |
| 10 | #include <assert.h> |
| 11 | #include <math.h> |
| 12 | #include <stddef.h> |
| 13 | #include <stdint.h> |
| 14 | |
| 15 | union U1 |
| 16 | { |
| 17 | int32_t a; |
| 18 | double d; |
| 19 | }; |
| 20 | |
| 21 | union U2 |
| 22 | { |
| 23 | double d; |
| 24 | char* ptr; |
| 25 | }; |
| 26 | |
| 27 | struct S final |
| 28 | { |
| 29 | int32_t i; |
| 30 | U1 u1; |
| 31 | U2 u2; |
| 32 | S() : |
| 33 | i(), |
| 34 | u1(), |
| 35 | u2() |
| 36 | { |
| 37 | } |
| 38 | S(int32_t i, U1 u1 = U1(0), U2 u2 = U2(NAN)) : |
| 39 | i(i), |
| 40 | u1(u1), |
| 41 | u2(u2) |
| 42 | {} |
| 43 | }; |
| 44 | --- |
| 45 | +/ |
| 46 | |
| 47 | extern (C++): |
| 48 | |
| 49 | union U1 |
| 50 | { |
| 51 | int a; |
| 52 | double d; |
| 53 | } |
| 54 | |
| 55 | union U2 |
| 56 | { |
| 57 | double d; |
| 58 | char* ptr; |
| 59 | } |
| 60 | |
| 61 | struct S |
| 62 | { |
| 63 | int i; |
| 64 | U1 u1; |
| 65 | U2 u2; |
| 66 | } |