Skip to content

Commit 2920193

Browse files
authored
Fix 21225: ImportC: macro interpreted as an enum conflicts with function (dlang#21228)
Fixes dlang#21225 Don't let C macro variable declarations shadow any symbol.
1 parent d657667 commit 2920193

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

compiler/src/dmd/importc.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ Dsymbol handleSymbolRedeclarations(ref Scope sc, Dsymbol s, Dsymbol s2, ScopeDsy
548548
auto vd2 = s2.isVarDeclaration(); // existing declaration
549549

550550
if (vd && vd.isCmacro())
551-
return vd2;
551+
return s2;
552552

553553
assert(!(vd2 && vd2.isCmacro()));
554554

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// https://github.com/dlang/dmd/issues/21225
2+
void x(void){
3+
}
4+
#define x 3
5+
6+
typedef struct Foo {int y; } foo;
7+
#define foo 3

0 commit comments

Comments
 (0)