diff options
author | Eli Bendersky <eliben@google.com> | 2013-04-22 17:03:42 +0000 |
---|---|---|
committer | Eli Bendersky <eliben@google.com> | 2013-04-22 17:03:42 +0000 |
commit | d9806687bc6d48115c97d22dae14590327d6e3fd (patch) | |
tree | d825e1e95f78e4e789f2f095abbf39e1fddf3439 /llvm/lib/AsmParser/LLParser.cpp | |
parent | 5e6a5d6ce5a82625c1def4caf30363a183149863 (diff) | |
download | bcm5719-llvm-d9806687bc6d48115c97d22dae14590327d6e3fd.tar.gz bcm5719-llvm-d9806687bc6d48115c97d22dae14590327d6e3fd.zip |
Fix for PR 14965: Better error message for GEP with partially defined contents
llvm-svn: 180030
Diffstat (limited to 'llvm/lib/AsmParser/LLParser.cpp')
-rw-r--r-- | llvm/lib/AsmParser/LLParser.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index cdacce13188..998bca5212d 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -4263,7 +4263,9 @@ int LLParser::ParseGetElementPtr(Instruction *&Inst, PerFunctionState &PFS) { if (ParseTypeAndValue(Ptr, Loc, PFS)) return true; - if (!Ptr->getType()->getScalarType()->isPointerTy()) + Type *BaseType = Ptr->getType(); + PointerType *BasePointerType = dyn_cast<PointerType>(BaseType->getScalarType()); + if (!BasePointerType) return Error(Loc, "base of getelementptr must be a pointer"); SmallVector<Value*, 16> Indices; @@ -4288,7 +4290,10 @@ int LLParser::ParseGetElementPtr(Instruction *&Inst, PerFunctionState &PFS) { Indices.push_back(Val); } - if (!GetElementPtrInst::getIndexedType(Ptr->getType(), Indices)) + if (!Indices.empty() && !BasePointerType->getElementType()->isSized()) + return Error(Loc, "base element of getelementptr must be sized"); + + if (!GetElementPtrInst::getIndexedType(BaseType, Indices)) return Error(Loc, "invalid getelementptr indices"); Inst = GetElementPtrInst::Create(Ptr, Indices); if (InBounds) |