mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
Handle signature mismatch when a Carbon function overrides a C++ virtual function. (#7499)
When a Carbon virtual function overrides a C++ virtual function, we need to export it with the C++ signature in order for it to work as an override. Instead of mapping the C++ signature into Carbon and then back again, use the original C++ signature from the base class as the signature exported to C++. Also add documentation explaining how we use thunks in C++ interop, including in this new virtual function handling logic.
This commit is contained in:
@@ -43,16 +43,6 @@ import Cpp;
|
||||
// HLSL extension, or by mapping to a `std::array` parameter.
|
||||
|
||||
// TODO: These diagnostics are very bad.
|
||||
// CHECK:STDERR: fail_todo_array_var_param.carbon:[[@LINE+18]]:1: error: cannot copy value of type `array(i32, 5)` [CopyOfUncopyableType]
|
||||
// CHECK:STDERR: fn F(var a: array(i32, 5)) -> i32 { return a[2]; }
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_todo_array_var_param.carbon:[[@LINE+15]]:1: note: type `array(i32, 5)` does not implement interface `Core.Copy` [MissingImplInMemberAccessInContext]
|
||||
// CHECK:STDERR: fn F(var a: array(i32, 5)) -> i32 { return a[2]; }
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_todo_array_var_param.carbon:[[@LINE+12]]:6: note: initializing function parameter [InCallToFunctionParam]
|
||||
// CHECK:STDERR: fn F(var a: array(i32, 5)) -> i32 { return a[2]; }
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_todo_array_var_param.carbon:[[@LINE+8]]:1: error: semantics TODO: `by-var array parameter` [SemanticsTodo]
|
||||
// CHECK:STDERR: fn F(var a: array(i32, 5)) -> i32 { return a[2]; }
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -67,7 +57,7 @@ inline Cpp '''
|
||||
int G() {
|
||||
//@dump-sem-ir-begin
|
||||
// CHECK:STDERR: fail_todo_array_var_param.carbon:[[@LINE+4]]:18: error: no member named 'F' in namespace 'Carbon' [CppInteropParseError]
|
||||
// CHECK:STDERR: 38 | return Carbon::F({1, 2, 3, 4, 5});
|
||||
// CHECK:STDERR: 28 | return Carbon::F({1, 2, 3, 4, 5});
|
||||
// CHECK:STDERR: | ^
|
||||
// CHECK:STDERR:
|
||||
return Carbon::F({1, 2, 3, 4, 5});
|
||||
|
||||
Reference in New Issue
Block a user