diff options
-rw-r--r-- | llvm/lib/Analysis/Lint.cpp | 4 | ||||
-rw-r--r-- | llvm/test/Other/lint.ll | 9 |
2 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/Lint.cpp b/llvm/lib/Analysis/Lint.cpp index 60654e617017..9f1b30d2cf45 100644 --- a/llvm/lib/Analysis/Lint.cpp +++ b/llvm/lib/Analysis/Lint.cpp @@ -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(); diff --git a/llvm/test/Other/lint.ll b/llvm/test/Other/lint.ll index 9a10abf3c703..dee3d11d2fb5 100644 --- a/llvm/test/Other/lint.ll +++ b/llvm/test/Other/lint.ll @@ -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 +} |