changeset 469:d0dad1fe0f45

Fixed constant expression taking address of function.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Mon, 04 Aug 2008 03:38:23 +0200
parents 45a67b6f1310
children 5e9883a7f9a5
files gen/toir.cpp
diffstat 1 files changed, 21 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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<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();
+    }
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////