Skip to content

Commit 3561ec4

Browse files
committed
[interop] add more specific diagnostic when rvalue reference parameter isn't imported
1 parent 51bb845 commit 3561ec4

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

include/swift/AST/DiagnosticsClangImporter.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ NOTE(macro_not_imported, none, "macro '%0' unavailable (cannot import)", (String
156156

157157
NOTE(return_type_not_imported, none, "return type unavailable (cannot import)", ())
158158
NOTE(parameter_type_not_imported, none, "parameter %0 unavailable (cannot import)", (const clang::NamedDecl*))
159+
NOTE(rvalue_ref_params_not_imported, none, "C++ functions with rvalue reference parameters are unavailable in Swift", ())
159160
NOTE(incomplete_interface, none, "interface %0 is incomplete", (const clang::NamedDecl*))
160161
NOTE(incomplete_protocol, none, "protocol %0 is incomplete", (const clang::NamedDecl*))
161162
NOTE(incomplete_record, none, "record '%0' is not defined (incomplete)", (StringRef))

lib/ClangImporter/ImportType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2362,7 +2362,7 @@ ClangImporter::Implementation::importParameterType(
23622362

23632363
// We don't support rvalue reference types, just bail.
23642364
if (paramTy->isRValueReferenceType()) {
2365-
// FIXME: add import diagnostic.
2365+
addImportDiagnosticFn(Diagnostic(diag::rvalue_ref_params_not_imported));
23662366
return None;
23672367
}
23682368

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
13+
void acceptRValueRef(int &&);
14+
15+
//--- test.swift
16+
17+
import Test
18+
19+
public func test() {
20+
var x: CInt = 2
21+
acceptRValueRef(x)
22+
// CHECK: note: function 'acceptRValueRef' unavailable (cannot import)
23+
// CHECK: note: C++ functions with rvalue reference parameters are unavailable in Swift
24+
}

0 commit comments

Comments
 (0)