mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-02 15:05:48 +01:00
This creates a namespace for `package` scope. It looks like names of class_decls in namespaces lead to an unexpected instref. This is already true, as best as I can tell. I'm not sure if there's a preferred approach to address that, so I've left a TODO for now.
52 lines
1.4 KiB
Plaintext
52 lines
1.4 KiB
Plaintext
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
// AUTOUPDATE
|
|
|
|
namespace Foo;
|
|
|
|
// Never called, just here to help catch bugs in name lookup.
|
|
fn Baz() {
|
|
}
|
|
|
|
fn Foo.Baz() {
|
|
}
|
|
|
|
fn Bar() {
|
|
Foo.Baz();
|
|
}
|
|
|
|
// CHECK:STDOUT: --- function.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %.loc17: type = tuple_type ()
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace {.Foo = %.loc7, .Baz = %Baz.loc10, .Bar = %Bar}
|
|
// CHECK:STDOUT: %.loc7: <namespace> = namespace {.Baz = %Baz.loc13}
|
|
// CHECK:STDOUT: %Baz.loc10: <function> = fn_decl @Baz.1
|
|
// CHECK:STDOUT: %Baz.loc13: <function> = fn_decl @Baz.2
|
|
// CHECK:STDOUT: %Bar: <function> = fn_decl @Bar
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Baz.1() {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Baz.2() {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Bar() {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %Foo.ref: <namespace> = name_ref Foo, file.%.loc7
|
|
// CHECK:STDOUT: %Baz.ref: <function> = name_ref Baz, file.%Baz.loc13
|
|
// CHECK:STDOUT: %.loc17: init () = call %Baz.ref()
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|