diff options
author | Chris Lattner <sabre@nondot.org> | 2009-01-08 19:05:36 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-01-08 19:05:36 +0000 |
commit | 1e407c338f6944242facb1e0c32903162cc366f0 (patch) | |
tree | a28e02ba5f020f91574aa5c214e515783c5c6986 /lib/AsmParser | |
parent | d7a97f06aea738a914cb56894138473ceb25bb39 (diff) | |
download | external_llvm-1e407c338f6944242facb1e0c32903162cc366f0.zip external_llvm-1e407c338f6944242facb1e0c32903162cc366f0.tar.gz external_llvm-1e407c338f6944242facb1e0c32903162cc366f0.tar.bz2 |
one more crash from PR3281, we now diagnose:
llvm-as: t.ll:2:39: function may not return opaque type
%"bwmoyl" = tail call coldcc opaque @g()
^
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61933 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AsmParser')
-rw-r--r-- | lib/AsmParser/LLParser.cpp | 11 |
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; |