mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-04 17:11:44 +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
|
@ -834,8 +834,7 @@ ldc::DISubprogram ldc::DIBuilder::EmitSubProgram(FuncDeclaration *fd) {
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
#if LDC_LLVM_VER >= 308
|
#if LDC_LLVM_VER >= 308
|
||||||
if (fd->fbody)
|
DtoFunction(fd)->setSubprogram(SP);
|
||||||
DtoFunction(fd)->setSubprogram(SP);
|
|
||||||
#endif
|
#endif
|
||||||
return SP;
|
return SP;
|
||||||
}
|
}
|
||||||
|
|
|
@ -921,15 +921,24 @@ void DtoDefineFunction(FuncDeclaration *fd, bool linkageAvailableExternally) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IrFunction *irFunc = getIrFunc(fd);
|
IrFunction *const irFunc = getIrFunc(fd);
|
||||||
|
llvm::Function *const func = irFunc->getLLVMFunc();
|
||||||
|
|
||||||
// debug info
|
if (!func->empty()) {
|
||||||
irFunc->diSubprogram = gIR->DBuilder.EmitSubProgram(fd);
|
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) {
|
if (!fd->fbody) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// debug info
|
||||||
|
irFunc->diSubprogram = gIR->DBuilder.EmitSubProgram(fd);
|
||||||
|
|
||||||
IF_LOG Logger::println("Doing function body for: %s", fd->toChars());
|
IF_LOG Logger::println("Doing function body for: %s", fd->toChars());
|
||||||
gIR->funcGenStates.emplace_back(new FuncGenState(*irFunc, *gIR));
|
gIR->funcGenStates.emplace_back(new FuncGenState(*irFunc, *gIR));
|
||||||
auto &funcGen = gIR->funcGen();
|
auto &funcGen = gIR->funcGen();
|
||||||
|
@ -940,7 +949,6 @@ void DtoDefineFunction(FuncDeclaration *fd, bool linkageAvailableExternally) {
|
||||||
|
|
||||||
const auto f = static_cast<TypeFunction *>(fd->type->toBasetype());
|
const auto f = static_cast<TypeFunction *>(fd->type->toBasetype());
|
||||||
IrFuncTy &irFty = irFunc->irFty;
|
IrFuncTy &irFty = irFunc->irFty;
|
||||||
llvm::Function *func = irFunc->getLLVMFunc();
|
|
||||||
|
|
||||||
const auto lwc = lowerFuncLinkage(fd);
|
const auto lwc = lowerFuncLinkage(fd);
|
||||||
if (linkageAvailableExternally) {
|
if (linkageAvailableExternally) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue