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:
arhwx
2026-07-30 00:29:53 +00:00
committed by GitHub
parent 198e447e4a
commit 8f224222a1
3 changed files with 60 additions and 1 deletions
+5
View File
@@ -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,