Skip to content

Commit 45c61ab

Browse files
committed
Deserializer: flush the diag engine to see a function type mismatch error
Fixes a not-printed error message. rdar://127767886
1 parent 09b8b08 commit 45c61ab

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

lib/Serialization/DeserializeSIL.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,10 +430,11 @@ SILFunction *SILDeserializer::getFuncForReference(StringRef name,
430430
if (auto *decl = dyn_cast_or_null<AbstractFunctionDecl>(dc->getAsDecl()))
431431
fnName = decl->getNameStr();
432432
}
433-
fn->getModule().getASTContext().Diags.diagnose(
434-
fn->getLocation().getSourceLoc(),
435-
diag::deserialize_function_type_mismatch,
436-
fnName, fnType.getASTType(), type.getASTType());
433+
auto &diags = fn->getModule().getASTContext().Diags;
434+
diags.diagnose(fn->getLocation().getSourceLoc(),
435+
diag::deserialize_function_type_mismatch,
436+
fnName, fnType.getASTType(), type.getASTType());
437+
diags.flushConsumers();
437438
exit(1);
438439
}
439440
return fn;

test/embedded/functype-mismatch.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: not %target-swift-frontend %s -enable-experimental-feature Embedded -wmo -emit-sil -o /dev/null 2>&1 | %FileCheck %s
2+
3+
// REQUIRES: optimized_stdlib
4+
// REQUIRES: OS=macosx
5+
6+
// This is a mismatch compared to what's in the stdlib, which is "cdecl" instead
7+
@_silgen_name("putchar")
8+
// CHECK: type mismatch of function 'putchar'
9+
public func putchar(_ value: CInt) -> CInt {
10+
return 0
11+
}
12+
13+
print("hello")

0 commit comments

Comments
 (0)