Skip to content

Commit 1b397d3

Browse files
committed
showcase SILGen crash
1 parent 7a3fe7c commit 1b397d3

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

test/Interop/Cxx/stdlib/Inputs/module.modulemap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ module StdString {
77
header "std-string.h"
88
requires cplusplus
99
}
10+
11+
module Sample {
12+
header "sample.h"
13+
requires cplusplus
14+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#ifndef TEST_INTEROP_CXX_STDLIB_INPUTS_STD_SAMPLE_H
2+
#define TEST_INTEROP_CXX_STDLIB_INPUTS_STD_SAMPLE_H
3+
4+
#include <string>
5+
6+
#define SWIFT_CXX_REF_IMMORTAL \
7+
__attribute__((swift_attr("import_as_ref"))) \
8+
__attribute__((swift_attr("retain:immortal"))) \
9+
__attribute__((swift_attr("release:immortal")))
10+
11+
12+
struct SWIFT_CXX_REF_IMMORTAL Counter {
13+
public:
14+
typedef int64_t Value;
15+
16+
void operator+=(Value delta);
17+
void operator++() { *this += 1; }
18+
19+
private:
20+
std::string name;
21+
};
22+
23+
#endif // TEST_INTEROP_CXX_STDLIB_INPUTS_STD_SAMPLE_H
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop)
2+
//
3+
// REQUIRES: executable_test
4+
//
5+
// Enable this everywhere once we have a solution for modularizing libstdc++: rdar://87654514
6+
// REQUIRES: OS=macosx
7+
8+
import StdlibUnittest
9+
import std.map
10+
import Sample
11+
12+
var SampleTestSuite = TestSuite("Sample")
13+
14+
actor X {
15+
var counter: Counter
16+
17+
init(counter: Counter) {
18+
self.counter = counter
19+
}
20+
21+
func test() {
22+
self.counter = self.counter.successor() // this is ++
23+
}
24+
}
25+
26+
SampleTestSuite.test("test") {
27+
}
28+
29+
runAllTests()

0 commit comments

Comments
 (0)