Skip to content

Commit

Permalink
fix Issue 23402 - importc function definitions from includes can caus…
Browse files Browse the repository at this point in the history
…e D name conflicts
  • Loading branch information
WalterBright committed Apr 13, 2023
1 parent 1ab73ce commit 4941cac
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
11 changes: 9 additions & 2 deletions compiler/src/dmd/expressionsem.d
Expand Up @@ -4852,10 +4852,17 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
return null;
if (f)
{
/* Error if match in more than one overload set,
/* Match in more than one overload set,
* even if one is a 'better' match than the other.
*/
ScopeDsymbol.multiplyDefined(loc, f, f2);
if (f.isCsymbol() && f2.isCsymbol())
{
/* C has global name space, so just pick one, such as f.
* If f and f2 are not compatible, that's how C rolls.
*/
}
else
ScopeDsymbol.multiplyDefined(loc, f, f2); // issue error
}
else
f = f2;
Expand Down
1 change: 1 addition & 0 deletions compiler/test/runnable/imports/imp23402a.c
@@ -0,0 +1 @@
#include <stdio.h>
1 change: 1 addition & 0 deletions compiler/test/runnable/imports/imp23402b.c
@@ -0,0 +1 @@
#include <stdio.h>
10 changes: 10 additions & 0 deletions compiler/test/runnable/test23402.d
@@ -0,0 +1,10 @@
// https://issues.dlang.org/show_bug.cgi?id=23402

import imp23402a;
import imp23402b;

int main()
{
printf("hello world\n");
return 0;
}

0 comments on commit 4941cac

Please sign in to comment.