diff options
Diffstat (limited to 'lib/AsmParser/LLParser.cpp')
-rw-r--r-- | lib/AsmParser/LLParser.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index c13737aae5..a9f8e192d3 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -602,11 +602,17 @@ GlobalValue *LLParser::GetGlobalVal(unsigned ID, const Type *Ty, LocTy Loc) { // Otherwise, create a new forward reference for this value and remember it. GlobalValue *FwdVal; - if (const FunctionType *FT = dyn_cast<FunctionType>(PTy->getElementType())) + if (const FunctionType *FT = dyn_cast<FunctionType>(PTy->getElementType())) { + // Function types can return opaque but functions can't. + if (isa<OpaqueType>(FT->getReturnType())) { + Error(Loc, "function may not return return opaque type"); + return 0; + } FwdVal = Function::Create(FT, GlobalValue::ExternalWeakLinkage, "", M); - else + } else { FwdVal = new GlobalVariable(PTy->getElementType(), false, GlobalValue::ExternalWeakLinkage, 0, "", M); + } ForwardRefValIDs[ID] = std::make_pair(FwdVal, Loc); return FwdVal; |