mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-25 00:53:14 +01:00
Error instead of assert on delegate literals as constant expressions.
Make function literal linkage internal inside functions and external otherwise.
This commit is contained in:
@@ -2297,7 +2297,11 @@ LLConstant* FuncExp::toConstElem(IRState* p)
|
||||
LOG_SCOPE;
|
||||
|
||||
assert(fd);
|
||||
assert(fd->tok == TOKfunction);
|
||||
if (fd->tok != TOKfunction)
|
||||
{
|
||||
assert(fd->tok == TOKdelegate);
|
||||
error("delegate literals as constant expressions are not yet allowed");
|
||||
}
|
||||
|
||||
fd->codegen(Type::sir);
|
||||
assert(fd->ir.irFunc->func);
|
||||
|
||||
@@ -265,9 +265,6 @@ LLGlobalValue::LinkageTypes DtoLinkage(Dsymbol* sym)
|
||||
// extern(C) functions are always external
|
||||
else if (ft->linkage == LINKc)
|
||||
return llvm::GlobalValue::ExternalLinkage;
|
||||
// Function & delegate literals, foreach bodies and lazy parameters: internal linkage
|
||||
else if (fdecl->isFuncLiteralDeclaration())
|
||||
return llvm::GlobalValue::InternalLinkage;
|
||||
}
|
||||
// class
|
||||
else if (ClassDeclaration* cd = sym->isClassDeclaration())
|
||||
|
||||
Reference in New Issue
Block a user