mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-02 08:01:11 +03:00
Handle multiple function definitions with same mangled name
By discarding (and warning about) all but the first definition. compilable/test17352.d tests that the compiler accepts 2 distinct but equivalent templated function instantiations (with an alias to a different local of the same type and name) ending up with a common mangled name. See https://issues.dlang.org/show_bug.cgi?id=17352.
This commit is contained in:
parent
1fa90a0381
commit
610a1c37e4
2 changed files with 13 additions and 6 deletions
|
@ -921,15 +921,24 @@ void DtoDefineFunction(FuncDeclaration *fd, bool linkageAvailableExternally) {
|
|||
return;
|
||||
}
|
||||
|
||||
IrFunction *irFunc = getIrFunc(fd);
|
||||
IrFunction *const irFunc = getIrFunc(fd);
|
||||
llvm::Function *const func = irFunc->getLLVMFunc();
|
||||
|
||||
// debug info
|
||||
irFunc->diSubprogram = gIR->DBuilder.EmitSubProgram(fd);
|
||||
if (!func->empty()) {
|
||||
warning(fd->loc,
|
||||
"skipping definition of function `%s` due to previous definition "
|
||||
"for the same mangled name: %s",
|
||||
fd->toPrettyChars(), mangleExact(fd));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!fd->fbody) {
|
||||
return;
|
||||
}
|
||||
|
||||
// debug info
|
||||
irFunc->diSubprogram = gIR->DBuilder.EmitSubProgram(fd);
|
||||
|
||||
IF_LOG Logger::println("Doing function body for: %s", fd->toChars());
|
||||
gIR->funcGenStates.emplace_back(new FuncGenState(*irFunc, *gIR));
|
||||
auto &funcGen = gIR->funcGen();
|
||||
|
@ -940,7 +949,6 @@ void DtoDefineFunction(FuncDeclaration *fd, bool linkageAvailableExternally) {
|
|||
|
||||
const auto f = static_cast<TypeFunction *>(fd->type->toBasetype());
|
||||
IrFuncTy &irFty = irFunc->irFty;
|
||||
llvm::Function *func = irFunc->getLLVMFunc();
|
||||
|
||||
const auto lwc = lowerFuncLinkage(fd);
|
||||
if (linkageAvailableExternally) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue