mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-02-26 16:43:13 +01:00
Give error for overloaded function addresses
This commit is contained in:
@@ -1263,6 +1263,14 @@ Expression *AddrExp::castTo(Scope *sc, Type *t)
|
||||
|
||||
e = Expression::castTo(sc, t);
|
||||
}
|
||||
#if IN_LLVM
|
||||
else if (e1->op == TOKvar)
|
||||
{
|
||||
VarExp *ve = (VarExp*)e1->copy();
|
||||
ve->hasOverloads = 0;
|
||||
e1 = ve;
|
||||
}
|
||||
#endif
|
||||
e->type = t;
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -780,6 +780,23 @@ Type *functionParameters(Loc loc, Scope *sc, TypeFunction *tf,
|
||||
#endif
|
||||
|
||||
// Give error for overloaded function addresses
|
||||
#if IN_LLVM
|
||||
if (arg->op == TOKaddress)
|
||||
{ AddrExp *ae = (AddrExp *)arg;
|
||||
if (ae->e1->op == TOKvar) {
|
||||
VarExp *ve = (VarExp*)ae->e1;
|
||||
FuncDeclaration *fd = ve->var->isFuncDeclaration();
|
||||
if (fd &&
|
||||
#if DMDV2
|
||||
ve->hasOverloads &&
|
||||
#endif
|
||||
!fd->isUnique())
|
||||
{
|
||||
arg->error("function %s is overloaded", arg->toChars());
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (arg->op == TOKsymoff)
|
||||
{ SymOffExp *se = (SymOffExp *)arg;
|
||||
if (
|
||||
@@ -789,6 +806,7 @@ Type *functionParameters(Loc loc, Scope *sc, TypeFunction *tf,
|
||||
!se->var->isFuncDeclaration()->isUnique())
|
||||
arg->error("function %s is overloaded", arg->toChars());
|
||||
}
|
||||
#endif
|
||||
arg->rvalue();
|
||||
}
|
||||
arg = arg->optimize(WANTvalue);
|
||||
|
||||
Reference in New Issue
Block a user