Add a lint check for mismatched return types, inspired by PR6944.
authorDan Gohman <gohman@apple.com>
Mon, 12 Jul 2010 18:02:04 +0000 (18:02 +0000)
committerDan Gohman <gohman@apple.com>
Mon, 12 Jul 2010 18:02:04 +0000 (18:02 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108162 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/Lint.cpp
test/Other/lint.ll

index 60654e6170172126e6052dc64d9439c1efa555a3..9f1b30d2cf45ccd8758f05771a22236f347f9de5 100644 (file)
@@ -225,6 +225,10 @@ void Lint::visitCallSite(CallSite CS) {
             "Undefined behavior: Call argument count mismatches callee "
             "argument count", &I);
 
+    Assert1(FT->getReturnType() == I.getType(),
+            "Undefined behavior: Call return type mismatches "
+            "callee return type", &I);
+
     // Check argument types (in case the callee was casted) and attributes.
     // TODO: Verify that caller and callee attributes are compatible.
     Function::arg_iterator PI = F->arg_begin(), PE = F->arg_end();
index 9a10abf3c70320a4adb2de5ffe61a4056c26a5d8..dee3d11d2fb5e0543313d493af385d0cd3eb54ba 100644 (file)
@@ -154,3 +154,12 @@ exit:
   %x = volatile load i32* %t3
   br label %exit
 }
+
+; CHECK: Call return type mismatches callee return type
+%struct = type { double, double }
+declare i32 @nonstruct_callee() nounwind
+define void @struct_caller() nounwind {
+entry:
+  call %struct bitcast (i32 ()* @foo to %struct ()*)()
+  ret void
+}