mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Support indirect C++ dependency by sharing domains more broadly (#7763)
Fixes #7731, at least under `--share-cpp-ast` which is expected to be the future direction. When --share-cpp-ast is enabled and any compilation unit has C++ imports, include all compilation units in the shared CppDomain inputs and assign the domain to every unit. In ImportCpp, when a unit has no direct C++ imports but is covered by a shared CppDomain, initialize its C++ AST context and import namespace. This ensures units without direct C++ imports have access to the C++ AST and code generator when instantiating generics or referencing declarations from units that do. Assisted-by: Antigravity with Gemini
This commit is contained in:
@@ -100,22 +100,13 @@ fn TryToUseNotLeaked() {
|
||||
var unused x: Cpp.A.X = 0;
|
||||
}
|
||||
|
||||
// --- fail_todo_no_cpp_import.carbon
|
||||
// --- no_cpp_import.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: fail_todo_no_cpp_import.carbon:[[@LINE+6]]:1: in import [InImport]
|
||||
// CHECK:STDERR: direct_import.carbon:4:10: in file included here [InCppInclude]
|
||||
// CHECK:STDERR: ./shared.h:3:10: error: semantics TODO: `indirect import of C++ declaration with no direct Cpp import` [SemanticsTodo]
|
||||
// CHECK:STDERR: struct X {
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR:
|
||||
import library "direct_import";
|
||||
|
||||
fn Field() -> i32 {
|
||||
// TODO: This should eventually work, by importing the C++ AST from
|
||||
// `direct_import`, even though we don't otherwise have any C++ imports in
|
||||
// this compilation.
|
||||
return F().x;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user