aboutsummaryrefslogtreecommitdiffstats
path: root/lib/AsmParser
diff options
context:
space:
mode:
Diffstat (limited to 'lib/AsmParser')
-rw-r--r--lib/AsmParser/LLParser.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp
index 80a4fca..edfdf15 100644
--- a/lib/AsmParser/LLParser.cpp
+++ b/lib/AsmParser/LLParser.cpp
@@ -564,11 +564,18 @@ GlobalValue *LLParser::GetGlobalVal(const std::string &Name, const Type *Ty,
// 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 opaque type");
+ return 0;
+ }
+
FwdVal = Function::Create(FT, GlobalValue::ExternalWeakLinkage, Name, M);
- else
+ } else {
FwdVal = new GlobalVariable(PTy->getElementType(), false,
GlobalValue::ExternalWeakLinkage, 0, Name, M);
+ }
ForwardRefVals[Name] = std::make_pair(FwdVal, Loc);
return FwdVal;