mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-17 01:39:01 +00:00
Include the Carbon package name in the exported C++ namespace. (#7935)
When exporting `X` from Carbon package `Foo`, expose it to C++ with fully-qualified name `Carbon::Foo::X`, not simply `Carbon::X`. This ensures that C++ mangled names properly distinguish between same-named Carbon entities in different packages. Name *lookup* into `Carbon::` still uses the same rules as before: it finds what a `package.` lookup would find in Carbon. So `X` is named from C++ as `Carbon::X` still, and a lookup for `Carbon::Foo` fails, even though `X`'s "true name" is now `Carbon::Foo::X`. Assisted-by: Gemini via Antigravity
This commit is contained in:
1 parent
d87891f3a6
commit
09b79784dc
35 files changed
+440
-262
No files matched your search
@@ -113,7 +113,7 @@ class C {
|
||||
|
||||
fn F() {
|
||||
// CHECK:STDERR: fail_wrong_parent_type.carbon:[[@LINE+3]]:39-46: error: can't convert exported member function pointer to `void (C::*)(void) const` [ExportedFunctionPtrTypeMismatch]
|
||||
// CHECK:STDERR: fail_wrong_parent_type.carbon:[[@LINE-5]]:3-18: note: function exported with pointer type `void (Carbon::C::*)(void) const` [ExportedFromFunction]
|
||||
// CHECK:STDERR: fail_wrong_parent_type.carbon:[[@LINE-5]]:3-18: note: function exported with pointer type `void (Carbon::Main::C::*)(void) const` [ExportedFromFunction]
|
||||
// CHECK:STDERR:
|
||||
var unused ptr: Cpp.MethodPtrType = C.Method;
|
||||
}
|
||||
@@ -133,8 +133,8 @@ using MethodPtrType = void(Carbon::C::*)(float) const;
|
||||
|
||||
fn G() {
|
||||
//@dump-sem-ir-begin
|
||||
// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+3]]:39-46: error: can't convert exported member function pointer to `void (Carbon::C::*)(float) const` [ExportedFunctionPtrTypeMismatch]
|
||||
// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE-10]]:3-26: note: function exported with pointer type `void (Carbon::C::*)(int) const` [ExportedFromFunction]
|
||||
// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+3]]:39-46: error: can't convert exported member function pointer to `void (Carbon::Main::C::*)(float) const` [ExportedFunctionPtrTypeMismatch]
|
||||
// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE-10]]:3-26: note: function exported with pointer type `void (Carbon::Main::C::*)(int) const` [ExportedFromFunction]
|
||||
// CHECK:STDERR:
|
||||
var unused ptr: Cpp.MethodPtrType = C.Method;
|
||||
//@dump-sem-ir-end
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
// CHECK:STDOUT: TranslationUnitDecl {{0x[a-f0-9]+}} <<invalid sloc>> <invalid sloc>
|
||||
// CHECK:STDOUT: |-EmptyDecl {{0x[a-f0-9]+}} <<carbon Cpp imports>:1:1> col:1
|
||||
// CHECK:STDOUT: |-NamespaceDecl {{0x[a-f0-9]+}} <<invalid sloc>> <invalid sloc> Carbon external-linkage
|
||||
// CHECK:STDOUT: | `-NamespaceDecl {{0x[a-f0-9]+}} <<invalid sloc>> <invalid sloc> Main external-linkage
|
||||
|
||||
// --- thunk_required.h
|
||||
|
||||
@@ -45,10 +46,11 @@ fn F() {
|
||||
Cpp.foo(1 as i16);
|
||||
}
|
||||
|
||||
// CHECK:STDOUT: `-ImportDecl {{0x[a-f0-9]+}} <import_thunk_required.carbon:[[@LINE+3]]:104> col:104 in import_thunk_required.carbon implicit import_thunk_required.carbon
|
||||
// CHECK:STDOUT: `-ImportDecl {{0x[a-f0-9]+}} <import_thunk_required.carbon:[[@LINE+4]]:104> col:104 in import_thunk_required.carbon implicit import_thunk_required.carbon
|
||||
// CHECK:STDOUT: TranslationUnitDecl {{0x[a-f0-9]+}} <<invalid sloc>> <invalid sloc>
|
||||
// CHECK:STDOUT: |-EmptyDecl {{0x[a-f0-9]+}} <<carbon Cpp imports>:1:1> col:1
|
||||
// CHECK:STDOUT: |-NamespaceDecl {{0x[a-f0-9]+}} <<invalid sloc>> <invalid sloc> Carbon external-linkage
|
||||
// CHECK:STDOUT: | `-NamespaceDecl {{0x[a-f0-9]+}} <<invalid sloc>> <invalid sloc> Main external-linkage
|
||||
// --- return_thunk_required.h
|
||||
|
||||
auto foo() -> short;
|
||||
|
||||
Reference in new issue
Block a user