mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 06:54:44 +01:00
Allow incomplete return types in function declarations. (#3875)
Move completeness check to the point where the function is defined or first called. This means we also defer deciding whether the function has a return slot until that point. Instead of storing a return slot per function, store the location of the return storage, which may or may not be used, and compute and store a separate flag saying whether to use it at the point of first use or definition. This is the final piece in supporting simple `Make` functions in classes as a replacement for constructors.
This commit is contained in:
@@ -627,7 +627,9 @@ auto Context::FinalizeGlobalInit() -> void {
|
||||
.implicit_param_refs_id = SemIR::InstBlockId::Empty,
|
||||
.param_refs_id = SemIR::InstBlockId::Empty,
|
||||
.return_type_id = SemIR::TypeId::Invalid,
|
||||
.return_slot_id = SemIR::InstId::Invalid,
|
||||
.return_storage_id = SemIR::InstId::Invalid,
|
||||
.is_extern = false,
|
||||
.return_slot = SemIR::Function::ReturnSlot::Absent,
|
||||
.body_block_ids = {SemIR::InstBlockId::GlobalInit}});
|
||||
} else {
|
||||
inst_block_stack().PopGlobalInit();
|
||||
|
||||
Reference in New Issue
Block a user