Fix #18235 - Add offending member to "no size because of forward reference" error (#20557)

Co-authored-by: Nick Treleaven <ntrel002@gmail.com>
This commit is contained in:
Nicholas Wilson 2024-12-15 18:23:36 +08:00 committed by GitHub
parent 1fd2fdb84b
commit 13775eb2d1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 17 additions and 12 deletions

View file

@ -171,11 +171,12 @@ extern (C++) class StructDeclaration : AggregateDeclaration
{
Dsymbol s = (*members)[i];
s.setFieldOffset(this, &fieldState, isunion);
}
if (type.ty == Terror)
{
errors = true;
return;
if (type.ty == Terror)
{
errorSupplemental(s.loc, "error on member `%s`", s.toPrettyChars);
errors = true;
return;
}
}
if (structsize == 0)

View file

@ -1,8 +1,9 @@
/*
TEST_OUTPUT:
---
fail_compilation/ice14642.d(47): Error: undefined identifier `errorValue`
fail_compilation/ice14642.d(23): Error: template instance `ice14642.X.NA!()` error instantiating
fail_compilation/ice14642.d(48): Error: undefined identifier `errorValue`
fail_compilation/ice14642.d(52): error on member `ice14642.Z.v`
fail_compilation/ice14642.d(24): Error: template instance `ice14642.X.NA!()` error instantiating
---
*/

View file

@ -2,7 +2,8 @@
EXTRA_FILES: imports/ice9865b.d
TEST_OUTPUT:
---
fail_compilation/ice9865.d(9): Error: alias `ice9865.Baz` recursive alias declaration
fail_compilation/ice9865.d(10): Error: alias `ice9865.Baz` recursive alias declaration
fail_compilation/ice9865.d(11): error on member `ice9865.Foo.f`
---
*/

View file

@ -1,6 +1,7 @@
/* TEST_OUTPUT:
---
fail_compilation/test19473.d(14): Error: union `test19473.P` no size because of forward reference
fail_compilation/test19473.d(15): Error: union `test19473.P` no size because of forward reference
fail_compilation/test19473.d(31): error on member `test19473.P.p`
---
*/

View file

@ -1,8 +1,9 @@
/* TEST_OUTPUT:
---
fail_compilation/test20719.d(13): Error: struct `test20719.SumType` no size because of forward reference
fail_compilation/test20719.d(32): Error: variable `test20719.isCopyable!(SumType).__lambda_L32_C22.foo` - size of type `SumType` is invalid
fail_compilation/test20719.d(18): Error: template instance `test20719.isCopyable!(SumType)` error instantiating
fail_compilation/test20719.d(14): Error: struct `test20719.SumType` no size because of forward reference
fail_compilation/test20719.d(17): error on member `test20719.SumType.storage`
fail_compilation/test20719.d(33): Error: variable `test20719.isCopyable!(SumType).__lambda_L33_C22.foo` - size of type `SumType` is invalid
fail_compilation/test20719.d(19): Error: template instance `test20719.isCopyable!(SumType)` error instantiating
---
*/
struct SumType