From 100c42bca37ea3a3cf55fbbac4b2c4c310e45704 Mon Sep 17 00:00:00 2001 From: Tomas Lindquist Olsen Date: Wed, 23 Jul 2008 20:21:18 +0200 Subject: [PATCH] Fixed segfault when using va_arg. Fixed segfault when accessing function symbols from inline asm. --- gen/d-asm-i386.h | 4 +++- gen/toir.cpp | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gen/d-asm-i386.h b/gen/d-asm-i386.h index be611119..bead7d3f 100644 --- a/gen/d-asm-i386.h +++ b/gen/d-asm-i386.h @@ -2036,7 +2036,9 @@ struct AsmProcessor } } else if (exp->op == TOKvar) { VarDeclaration * v = ((VarExp *) exp)->var->isVarDeclaration(); - v->needsStorage = true; + if (v) { + v->needsStorage = true; + } if (v && v->storage_class & STCfield) { operand->constDisplacement += v->offset; diff --git a/gen/toir.cpp b/gen/toir.cpp index 362c3687..58964a63 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -254,10 +254,12 @@ DValue* VarExp::toElem(IRState* p) else if (FuncDeclaration* fdecl = var->isFuncDeclaration()) { Logger::println("FuncDeclaration"); - if (fdecl->llvmInternal != LLVMva_arg) {// && fdecl->llvmValue == 0) + LLValue* func = 0; + if (fdecl->llvmInternal != LLVMva_arg) { DtoForceDeclareDsymbol(fdecl); + func = fdecl->ir.irFunc->func; } - return new DFuncValue(fdecl, fdecl->ir.irFunc->func); + return new DFuncValue(fdecl, func); } else if (SymbolDeclaration* sdecl = var->isSymbolDeclaration()) {