mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-03 22:02:51 +01:00
Support calling Carbon methods from C++ (#7078)
The FunctionDecl created for calling the Carbon thunk now takes a `self` parameter for non-static methods, and the C++ thunk now passes an extra argument for that `self` parameter when needed. The CXXMethodDecl thunk created for calling methods now sets the storage class appropriate depending on whether the method is static or not. To reduce the number of parameters being passed around to thunk-building functions, added a `FunctionInfo` struct and pass that around instead.
This commit is contained in:
@@ -101,22 +101,13 @@ void G() {
|
||||
}
|
||||
''';
|
||||
|
||||
// --- fail_todo_method.carbon
|
||||
// --- method.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_todo_method.carbon:[[@LINE+5]]:1: in import [InImport]
|
||||
// CHECK:STDERR: other.carbon:11:3: error: semantics TODO: `unsupported: C++ calling a Carbon function with an implicit parameter` [SemanticsTodo]
|
||||
// CHECK:STDERR: fn Method[self: Self]() { self; }
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
import Other;
|
||||
import Cpp inline '''
|
||||
void G() {
|
||||
// CHECK:STDERR: fail_todo_method.carbon:[[@LINE+4]]:22: error: no member named 'Method' in 'Carbon::Other::C' [CppInteropParseError]
|
||||
// CHECK:STDERR: 16 | Carbon::Other::C().Method();
|
||||
// CHECK:STDERR: | ~~~~~~~~~~~~~~~~~~ ^
|
||||
// CHECK:STDERR:
|
||||
Carbon::Other::C().Method();
|
||||
}
|
||||
''';
|
||||
|
||||
Reference in New Issue
Block a user