Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions compiler/src/dmd/funcsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -4023,25 +4023,22 @@ private void checkPrintfScanfSignature(FuncDeclaration funcdecl, TypeFunction f,
const p = (funcdecl.printf ? Id.printf : Id.scanf).toChars();
if (!(f.linkage == LINK.c || f.linkage == LINK.cpp))
{
.error(funcdecl.loc, "`pragma(%s)` function `%s` must have `extern(C)` or `extern(C++)` linkage,"
~" not `extern(%s)`",
.error(funcdecl.loc, "`pragma(%s)` function `%s` must have `extern(C)` or `extern(C++)` linkage, not `extern(%s)`",
p, funcdecl.toChars(), f.linkage.linkageToChars());
}
if (f.parameterList.varargs == VarArg.variadic)
{
if (!(nparams >= 1 && isPointerToChar(f.parameterList[nparams - 1])))
{
.error(funcdecl.loc, "`pragma(%s)` function `%s` must have"
~ " signature `%s %s([parameters...], const(char)*, ...)` not `%s`",
.error(funcdecl.loc, "`pragma(%s)` function `%s` must have signature `%s %s([parameters...], const(char)*, ...)` not `%s`",
p, funcdecl.toChars(), f.next.toChars(), funcdecl.toChars(), funcdecl.type.toChars());
}
}
else if (f.parameterList.varargs == VarArg.none)
{
if(!(nparams >= 2 && isPointerToChar(f.parameterList[nparams - 2]) &&
isVa_list(f.parameterList[nparams - 1])))
.error(funcdecl.loc, "`pragma(%s)` function `%s` must have"~
" signature `%s %s([parameters...], const(char)*, va_list)`",
.error(funcdecl.loc, "`pragma(%s)` function `%s` must have signature `%s %s([parameters...], const(char)*, va_list)`",
p, funcdecl.toChars(), f.next.toChars(), funcdecl.toChars());
}
else
Expand Down
22 changes: 22 additions & 0 deletions compiler/src/dmd/sideeffect.d
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ module dmd.sideeffect;
import dmd.astenums;
import dmd.declaration;
import dmd.dscope;
import dmd.dsymbol;
import dmd.dtemplate;
import dmd.errors;
import dmd.expression;
import dmd.expressionsem;
Expand All @@ -26,6 +28,7 @@ import dmd.init;
import dmd.mtype;
import dmd.tokens;
import dmd.typesem;
import dmd.root.string : toDString;
import dmd.visitor;
import dmd.visitor.postorder;

Expand Down Expand Up @@ -294,6 +297,25 @@ bool discardValue(Expression e)
// Assumption that error => no side effect
case EXP.error:
return true;
case EXP.overloadSet:
{
OverExp oe = cast(OverExp)e;
.error(e.loc, "`%s` matches multiple overloads", oe.vars.ident.toChars());
return false;
}
case EXP.scope_:
{
ScopeExp se = cast(ScopeExp)e;
if (auto ti = se.sds.isTemplateInstance())
{
if (ti.tempdecl && ti.tempdecl.isOverloadSet())
{
.error(e.loc, "`%s` matches multiple overloads", ti.toChars());
return false;
}
}
break;
}
case EXP.variable:
{
VarDeclaration v = (cast(VarExp)e).var.isVarDeclaration();
Expand Down
15 changes: 15 additions & 0 deletions compiler/test/fail_compilation/issue21622.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
REQUIRED_ARGS:
TEST_OUTPUT:
---
fail_compilation/issue21622.d(14): Error: `issue21622.foo!0` matches multiple overloads
---
*/

void foo(int i)() {}
void foo(int i)() {}

void main()
{
foo!0;
}
Loading