Give error for overloaded function addresses

This commit is contained in:
Alexey Prokhin
2011-01-04 20:03:33 +03:00
parent 02b307c0e9
commit 8e9a623880
2 changed files with 26 additions and 0 deletions

View File

@@ -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;
}

View File

@@ -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);