mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-20 23:03:14 +01:00
Fixed constant expression taking address of function.
This commit is contained in:
26
gen/toir.cpp
26
gen/toir.cpp
@@ -843,11 +843,27 @@ LLConstant* AddrExp::toConstElem(IRState* p)
|
||||
{
|
||||
assert(e1->op == TOKvar);
|
||||
VarExp* vexp = (VarExp*)e1;
|
||||
VarDeclaration* vd = vexp->var->isVarDeclaration();
|
||||
assert(vd);
|
||||
LLConstant* llc = llvm::dyn_cast<LLConstant>(vd->ir.getIrValue());
|
||||
assert(llc);
|
||||
return llc;
|
||||
|
||||
// global variable
|
||||
if (VarDeclaration* vd = vexp->var->isVarDeclaration())
|
||||
{
|
||||
LLConstant* llc = llvm::dyn_cast<LLConstant>(vd->ir.getIrValue());
|
||||
assert(llc);
|
||||
return llc;
|
||||
}
|
||||
// static function
|
||||
else if (FuncDeclaration* fd = vexp->var->isFuncDeclaration())
|
||||
{
|
||||
IrFunction* irfunc = fd->ir.irFunc;
|
||||
assert(irfunc);
|
||||
return irfunc->func;
|
||||
}
|
||||
// not yet supported
|
||||
else
|
||||
{
|
||||
error("constant expression '%s' not yet implemented", toChars());
|
||||
fatal();
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user