diff --git a/gen/runtime.cpp b/gen/runtime.cpp index 60b748f1..57d76ad8 100644 --- a/gen/runtime.cpp +++ b/gen/runtime.cpp @@ -168,6 +168,18 @@ static LLType* rt_dg2() return LLStructType::get(gIR->context(), types, false); } +template +static void ensureDecl(DECL *decl, const char *msg) +{ + if (!decl || !decl->type) + { + Logger::println("Missing class declaration: %s\n", msg); + error(Loc(), "Missing class declaration: %s", msg); + errorSupplemental(Loc(), "Please check that object.di is included and valid"); + fatal(); + } +} + static void LLVM_D_BuildRuntimeModule() { Logger::println("building runtime module"); @@ -187,10 +199,16 @@ static void LLVM_D_BuildRuntimeModule() LLType* wstringTy = DtoType(Type::twchar->arrayOf()); LLType* dstringTy = DtoType(Type::tdchar->arrayOf()); + ensureDecl(ClassDeclaration::object, "Object"); LLType* objectTy = DtoType(ClassDeclaration::object->type); + ensureDecl(ClassDeclaration::classinfo, "ClassInfo"); LLType* classInfoTy = DtoType(ClassDeclaration::classinfo->type); + ensureDecl(Type::typeinfo, "TypeInfo"); LLType* typeInfoTy = DtoType(Type::typeinfo->type); + ensureDecl(Type::typeinfoassociativearray, "TypeInfo_AssociativeArray"); LLType* aaTypeInfoTy = DtoType(Type::typeinfoassociativearray->type); + ensureDecl(Module::moduleinfo, "ModuleInfo"); + LLType* moduleInfoPtr = getPtrToType(DtoType(Module::moduleinfo->type)); LLType* aaTy = rt_ptr(LLStructType::get(gIR->context())); @@ -306,7 +324,7 @@ static void LLVM_D_BuildRuntimeModule() llvm::StringRef fname("_d_array_bounds"); llvm::StringRef fname2("_d_switch_error"); LLType *types[] = { - getPtrToType(DtoType(Module::moduleinfo->type)), + moduleInfoPtr, intTy }; LLFunctionType* fty = llvm::FunctionType::get(voidTy, types, false);