reject forward references to functions whose type don't match
authorChris Lattner <sabre@nondot.org>
Sat, 17 Apr 2010 20:45:56 +0000 (20:45 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 17 Apr 2010 20:45:56 +0000 (20:45 +0000)
up with the definition (and fix a broken testcase).  PR6491.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101670 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AsmParser/LLParser.cpp
test/Bitcode/memcpy.ll

index fe8e9c7f07d5cfb50a1369e14db24e8f8697126e..aa887d21777973b4c9840bb748390c06fa799131 100644 (file)
@@ -2787,6 +2787,10 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
       ForwardRefVals.find(FunctionName);
     if (FRVI != ForwardRefVals.end()) {
       Fn = M->getFunction(FunctionName);
+      if (Fn->getType() != PFT)
+        return Error(FRVI->second.second, "invalid forward reference to "
+                     "function '" + FunctionName + "' with wrong type!");
+      
       ForwardRefVals.erase(FRVI);
     } else if ((Fn = M->getFunction(FunctionName))) {
       // If this function already exists in the symbol table, then it is
index b6573b5f6216e8a238a69a576e557df47814271c..299eb1ed41e3cbf00358f7b095690ecbf4ef255b 100644 (file)
@@ -20,4 +20,4 @@ declare void @llvm.memset.i32(i8*, i8, i32, i32)
 
 declare void @llvm.memmove.i32(i8*, i8*, i32, i32)
 
-declare void @llvm.memmove.i64(i8*, i8*, i32, i32)
+declare void @llvm.memmove.i64(i8*, i8*, i64, i32)