Files
swift-mirror/test/Interop/Cxx/class/inline-function-codegen/constructor-calls-function-execution.swift
Alex 93c4c621b7 [cxx-interop] Walk initializer decls when walking constructor decls (#41584)
This addresses SR-15272.

When you have a function (e.g. 'foo') which is used in a constructor
initializer (e.g. constructor of some class 'Bar'), and you use the
constructor from swift code without directly using the function (e.g.
Bar's ctor is used from swift but foo isn't, foo is used from Bar's ctor),
you will get a link error. My fix is as follows:

When walking the clangAST to be imported, make sure you look at each
CXXCtorInitializer for each CXXConstructorDecl you see.
2022-03-14 09:56:55 -07:00

25 lines
590 B
Swift

// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-cxx-interop)
//
// REQUIRES: executable_test
import ConstructorCallsFunction
import StdlibUnittest
var MembersTestSuite = TestSuite("MembersTestSuite")
MembersTestSuite.test("constructor calls function (explicit)") {
expectEqual(42, callConstructor(41))
}
MembersTestSuite.test("constructor calls function (implicit)") {
let holder = Hold42()
expectEqual(42, holder.m)
}
MembersTestSuite.test("constructor calls template function (implicit)") {
let holder = Hold23()
expectEqual(23, holder.m)
}
runAllTests()