Skip to content

Commit 168c4f9

Browse files
Merge pull request #23426 from aschwaighofer/sema_cdecl_not_dynamic
Sema: Don't implicitly mark functions with a cdecl as dynamic
2 parents 43e771e + 6b807d9 commit 168c4f9

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2570,6 +2570,9 @@ void TypeChecker::addImplicitDynamicAttribute(Decl *D) {
25702570
// Don't add dynamic to defer bodies.
25712571
if (FD->isDeferBody())
25722572
return;
2573+
// Don't add dynamic to functions with a cdecl.
2574+
if (FD->getAttrs().hasAttribute<CDeclAttr>())
2575+
return;
25732576
}
25742577

25752578
if (auto *VD = dyn_cast<VarDecl>(D)) {

test/SILGen/dynamically_replaceable.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,11 @@ dynamic func funcWithDefaultArg(_ arg : String = String("hello")) {
357357
print("hello")
358358
}
359359

360+
// IMPLICIT-LABEL: sil hidden [thunk] [ossa] @barfoo
361+
@_cdecl("barfoo")
362+
func foobar() {
363+
}
364+
360365
// IMPLICIT-LABEL: sil private [ossa] @$s23dynamically_replaceable6$deferL_yyF
361366
var x = 10
362367
defer {

0 commit comments

Comments
 (0)