From 6118643232600e86d30982b54058c62a1d0114f4 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Mon, 4 Jun 2012 09:07:13 -0700 Subject: [PATCH] Handle more error cases if the user tries to declare a method. --- ctx.cpp | 6 +++++- type.cpp | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ctx.cpp b/ctx.cpp index 11957ae2..8def00c9 100644 --- a/ctx.cpp +++ b/ctx.cpp @@ -2653,10 +2653,14 @@ FunctionEmitContext::maskedStore(llvm::Value *value, llvm::Value *ptr, // individually with what turns into a recursive call to // makedStore() for (int i = 0; i < collectionType->GetElementCount(); ++i) { + const Type *eltType = collectionType->GetElementType(i); + if (eltType == NULL) { + Assert(m->errorCount > 0); + continue; + } llvm::Value *eltValue = ExtractInst(value, i, "value_member"); llvm::Value *eltPtr = AddElementOffset(ptr, i, ptrType, "struct_ptr_ptr"); - const Type *eltType = collectionType->GetElementType(i); const Type *eltPtrType = PointerType::GetUniform(eltType); StoreInst(eltValue, eltPtr, mask, eltType, eltPtrType); } diff --git a/type.cpp b/type.cpp index e4cf6cc4..7ea49422 100644 --- a/type.cpp +++ b/type.cpp @@ -1820,6 +1820,7 @@ StructType::StructType(const std::string &n, const llvm::SmallVector(type) != NULL) { Error(elementPositions[i], "Method declarations are not " "supported."); + return; } else elementTypes.push_back(type->LLVMType(g->ctx)); @@ -2904,7 +2905,11 @@ FunctionType::LLVMFunctionType(llvm::LLVMContext *ctx, bool includeMask) const { return NULL; } - return llvm::FunctionType::get(returnType->LLVMType(g->ctx), callTypes, false); + llvm::Type *llvmReturnType = returnType->LLVMType(g->ctx); + if (llvmReturnType == NULL) + return NULL; + + return llvm::FunctionType::get(llvmReturnType, callTypes, false); }