Skip to content

Commit 41f01e3

Browse files
committed
[nfc] Add a test for the attribute fix-its.
1 parent ebc492a commit 41f01e3

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// RUN: rm -rf %t
2+
// RUN: split-file %s %t
3+
// RUN: not %target-swift-frontend -typecheck -I %t/Inputs %t/test.swift -enable-experimental-cxx-interop 2>&1 | %FileCheck %s
4+
5+
//--- Inputs/module.modulemap
6+
module Test {
7+
header "test.h"
8+
requires cplusplus
9+
}
10+
11+
//--- Inputs/test.h
12+
struct Ptr { int *p; };
13+
14+
struct X {
15+
int *test() { }
16+
Ptr other() { }
17+
};
18+
19+
//--- test.swift
20+
21+
import Test
22+
23+
public func test(x: X) {
24+
// CHECK: note: Mark method 'test' as 'safe_to_import' in C++ to make it available in Swift.
25+
// CHECK: int *test() { }
26+
// CHECK: ^
27+
// CHECK: __attribute__((swift_attr("safe_to_import")))
28+
29+
x.test()
30+
31+
// CHECK: note: Mark method 'other' as 'safe_to_import' in C++ to make it available in Swift.
32+
// CHECK: Ptr other() { }
33+
// CHECK: ^
34+
// CHECK: __attribute__((swift_attr("safe_to_import")))
35+
36+
// CHECK: note: Mark type 'Ptr' as 'self_contained' in C++ to make methods that use it available in Swift.
37+
// CHECK: struct X {
38+
// CHECK: ^
39+
// CHECK: __attribute__((swift_attr("self_contained")))
40+
x.other()
41+
}

0 commit comments

Comments
 (0)