mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
C++ interop: Don't crash when looking up names inside an incomplete C++ class/struct/union (#6096)
Only do the lookup when the class is complete. Before this change we crash in `Sema::LookupQualifiedName()` on `Declaration context must already be complete!`.
This commit is contained in:
@@ -339,6 +339,32 @@ fn F() {
|
||||
//@dump-sem-ir-end
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Incomplete struct
|
||||
// ============================================================================
|
||||
|
||||
// --- incomplete.h
|
||||
|
||||
struct Incomplete;
|
||||
|
||||
// --- fail_import_incomplete.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
import Cpp library "incomplete.h";
|
||||
|
||||
fn F() {
|
||||
// CHECK:STDERR: fail_import_incomplete.carbon:[[@LINE+8]]:3: error: member access into incomplete class `Cpp.Incomplete` [QualifiedExprInIncompleteClassScope]
|
||||
// CHECK:STDERR: Cpp.Incomplete.foo();
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_import_incomplete.carbon:[[@LINE-6]]:10: in file included here [InCppInclude]
|
||||
// CHECK:STDERR: ./incomplete.h:2:8: note: class was forward declared here [ClassForwardDeclaredHere]
|
||||
// CHECK:STDERR: struct Incomplete;
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR:
|
||||
Cpp.Incomplete.foo();
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Pointer to forward-declared struct as parameter type
|
||||
// ============================================================================
|
||||
|
||||
Reference in New Issue
Block a user