mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 18:40:16 +01:00
C++ Interop: Make CppVoidType always-incomplete (#6302)
Part of https://github.com/carbon-language/carbon-lang/issues/6280.
This commit is contained in:
@@ -84,13 +84,18 @@ fn F() {
|
||||
//@dump-sem-ir-end
|
||||
}
|
||||
|
||||
// --- todo_fail_void.carbon
|
||||
// --- fail_void.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
import Cpp inline "";
|
||||
|
||||
fn F(x: Cpp.void);
|
||||
// CHECK:STDERR: fail_void.carbon:[[@LINE+5]]:6: error: parameter has incomplete type `Cpp.void` in function definition [IncompleteTypeInFunctionParam]
|
||||
// CHECK:STDERR: fn F(x: Cpp.void) {}
|
||||
// CHECK:STDERR: ^~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_void.carbon: note: `Cpp.void` is always-incomplete [CppVoidIncomplete]
|
||||
// CHECK:STDERR:
|
||||
fn F(x: Cpp.void) {}
|
||||
|
||||
// --- non_nullable_pointer.carbon
|
||||
|
||||
|
||||
@@ -195,8 +195,7 @@ class TypeCompleter {
|
||||
auto BuildInfoForInst(SemIR::TypeId /*type_id*/,
|
||||
SemIR::CppVoidType /*inst*/) const
|
||||
-> SemIR::CompleteTypeInfo {
|
||||
// TODO: `CppVoidType` should be always-incomplete.
|
||||
return {.value_repr = MakeEmptyValueRepr()};
|
||||
CARBON_FATAL("`CppVoidType` is always-incomplete");
|
||||
}
|
||||
|
||||
auto BuildInfoForInst(SemIR::TypeId type_id,
|
||||
@@ -372,6 +371,17 @@ auto TypeCompleter::AddNestedIncompleteTypes(SemIR::Inst type_inst) -> bool {
|
||||
Push(context_->types().GetTypeIdForTypeInstId(inst.inner_id));
|
||||
break;
|
||||
}
|
||||
case SemIR::CppVoidType::Kind: {
|
||||
// TODO: Consider checking `VoidTy` for completeness and checking whether
|
||||
// this extra check triggers an error. For that, reuse the code in
|
||||
// https://github.com/carbon-language/carbon-lang/blob/ca3f95faa610fdb9412c9e58ece524abf30c7a9e/toolchain/check/cpp/import.cpp#L2317-L2325.
|
||||
if (diagnoser_) {
|
||||
CARBON_DIAGNOSTIC(CppVoidIncomplete, Note,
|
||||
"`Cpp.void` is always-incomplete");
|
||||
diagnoser_().Note(SemIR::LocId::None, CppVoidIncomplete).Emit();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
case CARBON_KIND(SemIR::CustomLayoutType inst): {
|
||||
for (auto field : context_->struct_type_fields().Get(inst.fields_id)) {
|
||||
Push(context_->types().GetTypeIdForTypeInstId(field.type_inst_id));
|
||||
|
||||
@@ -289,6 +289,7 @@ CARBON_DIAGNOSTIC_KIND(ClassForwardDeclaredHere)
|
||||
CARBON_DIAGNOSTIC_KIND(ClassSpecificDeclOutsideClass)
|
||||
CARBON_DIAGNOSTIC_KIND(ClassSpecificDeclPrevious)
|
||||
CARBON_DIAGNOSTIC_KIND(ClassIncompleteWithinDefinition)
|
||||
CARBON_DIAGNOSTIC_KIND(CppVoidIncomplete)
|
||||
CARBON_DIAGNOSTIC_KIND(GenericVirtual)
|
||||
CARBON_DIAGNOSTIC_KIND(OverrideWithoutBase)
|
||||
CARBON_DIAGNOSTIC_KIND(OverrideWithoutVirtualInBase)
|
||||
|
||||
Reference in New Issue
Block a user