Skip to content

[cxx-interop] Re-enable a test for C foreign reference types #76670

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions test/Interop/C/struct/foreign-reference.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// RUN: %target-run-simple-swift(-I %S/Inputs/ -Xfrontend -validate-tbd-against-ir=none -Xfrontend -experimental-c-foreign-reference-types)
// RUN: %target-run-simple-swift(-I %S/Inputs/ -Xfrontend -validate-tbd-against-ir=none -Xfrontend -experimental-c-foreign-reference-types -Onone -D NO_OPTIMIZATIONS)
// RUN: %target-run-simple-swift(-I %S/Inputs/ -Xfrontend -validate-tbd-against-ir=none -Xfrontend -experimental-c-foreign-reference-types -O)
//
// REQUIRES: executable_test
// TODO: This should work without ObjC interop in the future rdar://97497120
// REQUIRES: objc_interop
// REQUIRES: rdar101790203

import StdlibUnittest
import ForeignReference
Expand All @@ -15,24 +15,32 @@ public func blackHole<T>(_ _: T) { }

ReferenceCountedTestSuite.test("Local") {
var x = createLocalCount()
#if NO_OPTIMIZATIONS
expectEqual(x.value, 6) // This is 6 because of "var x" "x.value" * 2 and "(x, x, x)".
#endif

let t = (x, x, x)
#if NO_OPTIMIZATIONS
expectEqual(x.value, 5)
#endif
}

@inline(never)
func globalTest1() {
var x = createGlobalCount()
let t = (x, x, x)
#if NO_OPTIMIZATIONS
expectEqual(globalCount, 4)
#endif
blackHole(t)
}

@inline(never)
func globalTest2() {
var x = createGlobalCount()
#if NO_OPTIMIZATIONS
expectEqual(globalCount, 1)
#endif
}

ReferenceCountedTestSuite.test("Global") {
Expand Down