mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Export abstract methods as pure virtual (#7578)
`abstract fn` was exported to C++ as a plain virtual function rather than a pure virtual one, so the class wasn't abstract and could be instantiated from C++. Abstract functions no longer get a thunk since there is no definition to call. The tests are prefixed with `fail_` since an abstract class still errors on `Core.Destroy` regardless.
This commit is contained in:
@@ -544,6 +544,11 @@ auto CarbonExternalASTSource::CompleteType(clang::TagDecl* tag_decl) -> void {
|
||||
method_decl,
|
||||
MakeVirtualFunctionSignature(*context_, method_decl)),
|
||||
.inst_id = function.first_decl_id()});
|
||||
// An abstract function has no definition, so it doesn't need a thunk.
|
||||
if (function.virtual_modifier ==
|
||||
SemIR::Function::VirtualModifier::Abstract) {
|
||||
continue;
|
||||
}
|
||||
pending_virtual_functions.push_back(
|
||||
{.loc_id = SemIR::LocId(vtable_entry_id),
|
||||
.function_id = callee_function.function_id,
|
||||
|
||||
Reference in New Issue
Block a user