mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-24 14:42:40 +00:00
Shorthand names are intended to be used in the textual format of references to instructions in another IR (which can't happen now, but will be possible in a forthcoming PR). The shorthand name uses the file name (minus the `.carbon` suffix) as a base, and if that base name is ambiguous within the compilation, it is given a numerical suffix `.N`, just like other textual IR names. Shorthand names are prefixed with `$` in the textual format, to distinguish them from inst and scope names. For example, a file `foo/bar.carbon` has the shorthand name `$bar`, and an instruction `@baz.%qux` in that file can be referenced from another file as `$bar.@baz.%qux`. This PR adds `toolchain/check/testdata/basics/file_name.carbon` to test this behavior. All other test changes are just applying this change to the existing textual SemIR dumps. --------- Co-authored-by: Dana Jansens <danakj@orodu.net>
114 lines
4.0 KiB
Plaintext
114 lines
4.0 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
|
|
//
|
|
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/none.carbon
|
|
// TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
|
|
// EXTRA-ARGS: --dump-sem-ir-ranges=if-present
|
|
//
|
|
// AUTOUPDATE
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/packages/fail_duplicate_api.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/packages/fail_duplicate_api.carbon
|
|
|
|
// --- main1.carbon
|
|
|
|
// --- fail_main2.carbon
|
|
// CHECK:STDERR: fail_main2.carbon: error: `Main//default` previously provided by `main1.carbon` [DuplicateMainApi]
|
|
// CHECK:STDERR:
|
|
|
|
// --- main_lib1.carbon
|
|
|
|
library "lib";
|
|
|
|
// --- fail_main_lib2.carbon
|
|
|
|
// CHECK:STDERR: ╭─┤ fail_main_lib2.carbon:[[@LINE+7]]:1
|
|
// CHECK:STDERR: -> │ library "lib";
|
|
// CHECK:STDERR: · ━━━━━━━┳━━━━━━
|
|
// CHECK:STDERR: · ┗━━┫ error: library's API previously provided by `main_lib1.carbon`
|
|
// CHECK:STDERR: · ┃ [DuplicateLibraryApi]
|
|
// CHECK:STDERR: ╰────
|
|
// CHECK:STDERR:
|
|
library "lib";
|
|
|
|
// --- package1.carbon
|
|
|
|
package Package;
|
|
|
|
// --- fail_package2.carbon
|
|
|
|
// CHECK:STDERR: ╭─┤ fail_package2.carbon:[[@LINE+7]]:1
|
|
// CHECK:STDERR: -> │ package Package;
|
|
// CHECK:STDERR: · ━━━━━━━━┳━━━━━━━
|
|
// CHECK:STDERR: · ┗━━┫ error: library's API previously provided by `package1.carbon`
|
|
// CHECK:STDERR: · ┃ [DuplicateLibraryApi]
|
|
// CHECK:STDERR: ╰────
|
|
// CHECK:STDERR:
|
|
package Package;
|
|
|
|
// --- package_lib1.carbon
|
|
|
|
package Package library "lib";
|
|
|
|
// --- fail_package_lib2.carbon
|
|
|
|
// CHECK:STDERR: ╭─┤ fail_package_lib2.carbon:[[@LINE+7]]:1
|
|
// CHECK:STDERR: -> │ package Package library "lib";
|
|
// CHECK:STDERR: · ━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━
|
|
// CHECK:STDERR: · ┗━━┫ error: library's API previously provided by `package_lib1.carbon`
|
|
// CHECK:STDERR: · ┃ [DuplicateLibraryApi]
|
|
// CHECK:STDERR: ╰────
|
|
// CHECK:STDERR:
|
|
package Package library "lib";
|
|
|
|
// CHECK:STDOUT: --- main1.carbon = $main1
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {}
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: --- fail_main2.carbon = $fail_main2
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {}
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: --- main_lib1.carbon = $main_lib1
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {}
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: --- fail_main_lib2.carbon = $fail_main_lib2
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {}
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: --- package1.carbon = $package1
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {}
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: --- fail_package2.carbon = $fail_package2
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {}
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: --- package_lib1.carbon = $package_lib1
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {}
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: --- fail_package_lib2.carbon = $fail_package_lib2
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {}
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|