mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 05:00:16 +03:00

Fixes https://github.com/dlang/dmd/issues/20499 Fixes https://github.com/dlang/dmd/issues/20963 ImportC deferred declaring "tagged" types (structs/unions/enums) until after it saw a possible typedef so that the identifier for a typedef declaration like: typedef struct { int x; } Foo; would give the struct the name Foo. In several circumstances, this led to tagged types not being declared. Resolve this by chasing down those circumstances. Also, there were other circumstances where types weren't being correctly declared which caused other issues. Lock those down.
61 lines
1.3 KiB
C
61 lines
1.3 KiB
C
// https://github.com/dlang/dmd/issues/20499
|
|
|
|
|
|
struct Outer {
|
|
struct __attribute__((aligned(8))) {
|
|
int x;
|
|
} n;
|
|
enum {A};
|
|
enum {B} b;
|
|
};
|
|
|
|
struct Outer2 {
|
|
struct __attribute__((aligned(8))) Nested {
|
|
int x;
|
|
} n;
|
|
};
|
|
|
|
const int x = A;
|
|
const int y = B;
|
|
|
|
struct Outer o = {3};
|
|
_Static_assert(_Alignof(typeof(o.n)) == 8, "");
|
|
_Static_assert(_Alignof(struct Outer) == 8, "");
|
|
_Static_assert(_Alignof(struct Outer2) == 8, "");
|
|
_Static_assert(_Alignof(struct Nested) == 8, "");
|
|
|
|
void test(void){
|
|
struct Outer {
|
|
struct __attribute__((aligned(16))) {
|
|
int x;
|
|
} n;
|
|
enum {A=2};
|
|
enum {B=3} b;
|
|
};
|
|
|
|
struct Outer2 {
|
|
struct __attribute__((aligned(16))) Nested {
|
|
int x;
|
|
} n;
|
|
};
|
|
|
|
const int x = A;
|
|
const int y = B;
|
|
|
|
struct Outer o = {3};
|
|
_Static_assert(_Alignof(typeof(o.n)) == 16, "");
|
|
_Static_assert(_Alignof(struct Outer) == 16, "");
|
|
_Static_assert(_Alignof(struct Outer2) == 16, "");
|
|
_Static_assert(_Alignof(struct Nested) == 16, "");
|
|
}
|
|
|
|
void test2(void){
|
|
const int x = A;
|
|
const int y = B;
|
|
|
|
struct Outer o = {3};
|
|
_Static_assert(_Alignof(typeof(o.n)) == 8, "");
|
|
_Static_assert(_Alignof(struct Outer) == 8, "");
|
|
_Static_assert(_Alignof(struct Outer2) == 8, "");
|
|
_Static_assert(_Alignof(struct Nested) == 8, "");
|
|
}
|