diff --git a/compiler/src/dmd/importc.d b/compiler/src/dmd/importc.d index 72808a67f7..dcd6bb1d40 100644 --- a/compiler/src/dmd/importc.d +++ b/compiler/src/dmd/importc.d @@ -126,6 +126,12 @@ Expression fieldLookup(Expression e, Scope* sc, Identifier id, bool arrow) e = e.expressionSemantic(sc); if (e.isErrorExp()) return e; + if (arrow) + { + e = arrayFuncConv(e, sc); + if (e.isErrorExp()) + return e; + } auto t = e.type; if (t.isTypePointer()) diff --git a/compiler/test/compilable/test20472.c b/compiler/test/compilable/test20472.c new file mode 100644 index 0000000000..aae7e07380 --- /dev/null +++ b/compiler/test/compilable/test20472.c @@ -0,0 +1,12 @@ +// https://github.com/dlang/dmd/issues/20472 +typedef struct { + char c; +} stuff; + +char test20472(void) +{ + stuff s[1]; + s->c = 1; + return s->c; +} +_Static_assert(test20472() == 1, "1"); diff --git a/compiler/test/compilable/testcstuff1.c b/compiler/test/compilable/testcstuff1.c index d57ae9d81d..db0f59058f 100644 --- a/compiler/test/compilable/testcstuff1.c +++ b/compiler/test/compilable/testcstuff1.c @@ -398,8 +398,9 @@ void* tests3() int tests4() { - struct S { int b; } a, *p; - a.b = 3; + struct S { int b; } a, *p, b[1]; + b->b = 3; + a.b = b->b; p = &a; return p->b; }