mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 20:11:12 +01:00
Require imported C++ types to be complete before creating a Core.Copy witness (#7106)
Fixes a crash that would occur due to `scope_id` of the class being unset.
This commit is contained in:
@@ -224,6 +224,34 @@ import Cpp library "template.h";
|
||||
fn MyF(bar: Cpp.Bar(Cpp.X)*);
|
||||
//@dump-sem-ir-end
|
||||
|
||||
// --- fail_copy_witness_of_incomplete_class.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
import Cpp inline '''
|
||||
class Class1;
|
||||
''';
|
||||
|
||||
class Generic(x:! Core.Copy) {
|
||||
}
|
||||
|
||||
// CHECK:STDERR: fail_copy_witness_of_incomplete_class.carbon:[[@LINE+14]]:19: error: argument to C++ call has incomplete type `Cpp.Class1` [IncompleteTypeInCopyWitness]
|
||||
// CHECK:STDERR: fn GenericUse(p2: Generic(Cpp.Class1)) {
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_copy_witness_of_incomplete_class.carbon:[[@LINE-9]]:7: note: class was forward declared here [ClassForwardDeclaredHere]
|
||||
// CHECK:STDERR: class Class1;
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_copy_witness_of_incomplete_class.carbon:[[@LINE-9]]:15: note: initializing generic parameter `x` declared here [InitializingGenericParam]
|
||||
// CHECK:STDERR: class Generic(x:! Core.Copy) {
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_copy_witness_of_incomplete_class.carbon:[[@LINE+4]]:15: warning: binding `p2` unused [UnusedBinding]
|
||||
// CHECK:STDERR: fn GenericUse(p2: Generic(Cpp.Class1)) {
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
fn GenericUse(p2: Generic(Cpp.Class1)) {
|
||||
}
|
||||
|
||||
// CHECK:STDOUT: --- import_declaration.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
|
||||
Reference in New Issue
Block a user