| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- // 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
- // TIP: To test this file alone, run:
- // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/namespace/fail_conflict_imported_namespace_second.carbon
- // TIP: To dump output, run:
- // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/namespace/fail_conflict_imported_namespace_second.carbon
- // --- fn.carbon
- package Example library "fn";
- fn NS();
- // --- fail_conflict.carbon
- package Example;
- import library "fn";
- // CHECK:STDERR: fail_conflict.carbon:[[@LINE+10]]:1: ERROR: Duplicate name being declared in the same scope.
- // CHECK:STDERR: namespace NS;
- // CHECK:STDERR: ^~~~~~~~~~~~~
- // CHECK:STDERR: fail_conflict.carbon:[[@LINE-5]]:1: In import.
- // CHECK:STDERR: import library "fn";
- // CHECK:STDERR: ^~~~~~
- // CHECK:STDERR: fn.carbon:4:1: Name is previously declared here.
- // CHECK:STDERR: fn NS();
- // CHECK:STDERR: ^~~~~~~~
- // CHECK:STDERR:
- namespace NS;
- // CHECK:STDERR: fail_conflict.carbon:[[@LINE+9]]:4: ERROR: Name qualifiers are only allowed for entities that provide a scope.
- // CHECK:STDERR: fn NS.Foo();
- // CHECK:STDERR: ^~
- // CHECK:STDERR: fail_conflict.carbon:[[@LINE-17]]:1: In import.
- // CHECK:STDERR: import library "fn";
- // CHECK:STDERR: ^~~~~~
- // CHECK:STDERR: fn.carbon:4:1: Referenced non-scope entity declared here.
- // CHECK:STDERR: fn NS();
- // CHECK:STDERR: ^~~~~~~~
- fn NS.Foo();
- // CHECK:STDOUT: --- fn.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %NS.type: type = fn_type @NS [template]
- // CHECK:STDOUT: %.1: type = tuple_type () [template]
- // CHECK:STDOUT: %NS: %NS.type = struct_value () [template]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = namespace [template] {
- // CHECK:STDOUT: .Core = %Core
- // CHECK:STDOUT: .NS = %NS.decl
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
- // CHECK:STDOUT: %NS.decl: %NS.type = fn_decl @NS [template = constants.%NS] {}
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @NS();
- // CHECK:STDOUT:
- // CHECK:STDOUT: --- fail_conflict.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %NS.type: type = fn_type @NS [template]
- // CHECK:STDOUT: %.1: type = tuple_type () [template]
- // CHECK:STDOUT: %NS: %NS.type = struct_value () [template]
- // CHECK:STDOUT: %.type: type = fn_type @.1 [template]
- // CHECK:STDOUT: %.2: %.type = struct_value () [template]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = namespace [template] {
- // CHECK:STDOUT: .NS = %import_ref
- // CHECK:STDOUT: .Core = %Core
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %import_ref: %NS.type = import_ref ir1, inst+2, loaded [template = constants.%NS]
- // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
- // CHECK:STDOUT: %.loc16: <namespace> = namespace [template] {}
- // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.2] {}
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @NS();
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @.1();
- // CHECK:STDOUT:
|