mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-04-18 01:39:03 +02:00
Prevent two function with same mangled name but different types from being declared.
Previously, LDC would crash in the backend due to the fact that the IR is typed in such cases (we recently had such an instance with Tango, where an extern( C ) function was declared once with int and once with size_t).
This commit is contained in:
@@ -474,8 +474,11 @@ void DtoDeclareFunction(FuncDeclaration* fdecl)
|
||||
// construct function
|
||||
const llvm::FunctionType* functype = DtoFunctionType(fdecl);
|
||||
llvm::Function* func = vafunc ? vafunc : gIR->module->getFunction(mangled_name);
|
||||
if (!func)
|
||||
if (!func) {
|
||||
func = llvm::Function::Create(functype, DtoLinkage(fdecl), mangled_name, gIR->module);
|
||||
} else if (func->getFunctionType() != functype) {
|
||||
error(fdecl->loc, "Function type does not match previously declared function with the same mangled name: %s", fdecl->mangle());
|
||||
}
|
||||
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "func = " << *func << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user