diff --git a/compiler/src/dmd/expressionsem.d b/compiler/src/dmd/expressionsem.d index cfa6d8d34394..b48500450839 100644 --- a/compiler/src/dmd/expressionsem.d +++ b/compiler/src/dmd/expressionsem.d @@ -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; diff --git a/compiler/test/runnable/imports/imp23402a.c b/compiler/test/runnable/imports/imp23402a.c new file mode 100644 index 000000000000..53c5fdf17996 --- /dev/null +++ b/compiler/test/runnable/imports/imp23402a.c @@ -0,0 +1 @@ +#include diff --git a/compiler/test/runnable/imports/imp23402b.c b/compiler/test/runnable/imports/imp23402b.c new file mode 100644 index 000000000000..53c5fdf17996 --- /dev/null +++ b/compiler/test/runnable/imports/imp23402b.c @@ -0,0 +1 @@ +#include diff --git a/compiler/test/runnable/test23402.d b/compiler/test/runnable/test23402.d new file mode 100644 index 000000000000..22fd21a71708 --- /dev/null +++ b/compiler/test/runnable/test23402.d @@ -0,0 +1,10 @@ +// https://issues.dlang.org/show_bug.cgi?id=23402 + +import imports.imp23402a; +import imports.imp23402b; + +int main() +{ + printf("hello world\n"); + return 0; +}