1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 12:41:49 +01:00

Don't crash if a .ll file contains a forward-reference that looks like a global

value but later turns out to be a function.

Unfortunately, we can't fold tests into a single file because we only get one
error out of llvm-as.

llvm-svn: 165680
This commit is contained in:
Nick Lewycky 2012-10-11 00:38:25 +00:00
parent b84fe4f16a
commit 0f21841b72
2 changed files with 7 additions and 0 deletions

View File

@ -2795,6 +2795,9 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
ForwardRefVals.find(FunctionName);
if (FRVI != ForwardRefVals.end()) {
Fn = M->getFunction(FunctionName);
if (!Fn)
return Error(FRVI->second.second, "invalid forward reference to "
"function as global value!");
if (Fn->getType() != PFT)
return Error(FRVI->second.second, "invalid forward reference to "
"function '" + FunctionName + "' with wrong type!");

View File

@ -0,0 +1,4 @@
; RUN: not llvm-as %s -disable-output 2>&1 | grep "invalid forward reference to function as global value!"
define i8* @test1() { ret i8* @test1a }
define void @test1a() { }