mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
Support C++ calling Carbon functions with ref parameters (#7107)
When creating the C++ thunk, make the parameters references if the corresponding callee parameters are `ref`s. When creating the Carbon thunk, tag the call arguments as `ref` if the corresponding callee parameters are `ref`s.
This commit is contained in:
@@ -20,10 +20,6 @@ fn F3(_: i32) {}
|
||||
fn HasGenericArg(T:! type, a: T) { a; }
|
||||
fn HasDeducedArg[T:! type](a: T) { a; }
|
||||
|
||||
class C {
|
||||
fn Method[self: Self]() { self; }
|
||||
}
|
||||
|
||||
// --- function.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
@@ -57,6 +53,21 @@ void G() {
|
||||
}
|
||||
''';
|
||||
|
||||
// --- ref_arg.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
import Cpp;
|
||||
|
||||
fn F(ref n: i32);
|
||||
|
||||
inline Cpp '''
|
||||
void G() {
|
||||
int n = 0;
|
||||
Carbon::F(n);
|
||||
}
|
||||
''';
|
||||
|
||||
// --- using.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
@@ -113,14 +124,3 @@ void G() {
|
||||
Carbon::Other::HasDeducedArg(123);
|
||||
}
|
||||
''';
|
||||
|
||||
// --- method.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
import Other;
|
||||
import Cpp inline '''
|
||||
void G() {
|
||||
Carbon::Other::C().Method();
|
||||
}
|
||||
''';
|
||||
|
||||
Reference in New Issue
Block a user