mirror of
https://github.com/dlang/dmd.git
synced 2025-04-27 05:30:13 +03:00
Fix #20499 - [ImportC] typedef struct with name as a pointer cannot be used with struct name (#21232)
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.
This commit is contained in:
parent
c30def82bd
commit
f4ca164257
8 changed files with 456 additions and 68 deletions
61
compiler/test/compilable/nested_struct_20499.c
Normal file
61
compiler/test/compilable/nested_struct_20499.c
Normal file
|
@ -0,0 +1,61 @@
|
|||
// 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, "");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue