# HG changeset patch # User Tomas Lindquist Olsen # Date 1217813903 -7200 # Node ID d0dad1fe0f45029d57f8cdf3fcd7d3e152162100 # Parent 45a67b6f1310eab6af367194d44f43e07f9c01ab Fixed constant expression taking address of function. diff -r 45a67b6f1310 -r d0dad1fe0f45 gen/toir.cpp --- a/gen/toir.cpp Mon Aug 04 02:59:34 2008 +0200 +++ b/gen/toir.cpp Mon Aug 04 03:38:23 2008 +0200 @@ -843,11 +843,27 @@ { assert(e1->op == TOKvar); VarExp* vexp = (VarExp*)e1; - VarDeclaration* vd = vexp->var->isVarDeclaration(); - assert(vd); - LLConstant* llc = llvm::dyn_cast(vd->ir.getIrValue()); - assert(llc); - return llc; + + // global variable + if (VarDeclaration* vd = vexp->var->isVarDeclaration()) + { + LLConstant* llc = llvm::dyn_cast(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(); + } } //////////////////////////////////////////////////////////////////////////////////////////