File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed
test/Interop/Cxx/foreign-reference Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -4943,6 +4943,10 @@ TinyPtrVector<ValueDecl *> ClangRecordMemberLookup::evaluate(
4943
4943
auto named = found.get <clang::NamedDecl *>();
4944
4944
if (dyn_cast<clang::Decl>(named->getDeclContext ()) ==
4945
4945
recordDecl->getClangDecl ()) {
4946
+ // Don't import constructors on foreign reference types.
4947
+ if (isa<clang::CXXConstructorDecl>(named) && isa<ClassDecl>(recordDecl))
4948
+ continue ;
4949
+
4946
4950
if (auto import = clangModuleLoader->importDeclDirectly (named))
4947
4951
result.push_back (cast<ValueDecl>(import ));
4948
4952
}
Original file line number Diff line number Diff line change
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
13
+ __attribute__( ( swift_attr ( " import_reference " ) ) )
14
+ __attribute__ ( ( swift_attr ( " retain:immortal " ) ) )
15
+ __attribute__ ( ( swift_attr ( " release:immortal " ) ) )
16
+ HasCtor {
17
+ HasCtor ( int a) { }
18
+ } ;
19
+
20
+ //--- test.swift
21
+
22
+ import Test
23
+
24
+ // CHECK: error: 'HasCtor' cannot be constructed because it has no accessible initializers
25
+ let x = HasCtor ( 42 )
You can’t perform that action at this time.
0 commit comments