diff --git a/compiler/src/dmd/importc.d b/compiler/src/dmd/importc.d index dcd6bb1d40..d3381dc858 100644 --- a/compiler/src/dmd/importc.d +++ b/compiler/src/dmd/importc.d @@ -548,7 +548,7 @@ Dsymbol handleSymbolRedeclarations(ref Scope sc, Dsymbol s, Dsymbol s2, ScopeDsy auto vd2 = s2.isVarDeclaration(); // existing declaration if (vd && vd.isCmacro()) - return vd2; + return s2; assert(!(vd2 && vd2.isCmacro())); diff --git a/compiler/test/compilable/test21225.c b/compiler/test/compilable/test21225.c new file mode 100644 index 0000000000..45eb5cd92f --- /dev/null +++ b/compiler/test/compilable/test21225.c @@ -0,0 +1,7 @@ +// https://github.com/dlang/dmd/issues/21225 +void x(void){ +} +#define x 3 + +typedef struct Foo {int y; } foo; +#define foo 3