| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- // 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_export_name_member.carbon
- // TIP: To dump output, run:
- // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/packages/fail_export_name_member.carbon
- // --- a.carbon
- package Foo library "[[@TEST_NAME]]";
- class C {
- var n: {};
- }
- // --- fail_b.carbon
- package Foo library "[[@TEST_NAME]]";
- import library "a";
- // TODO: This diagnostic doesn't clearly explain the problem. We should instead
- // say something like: Only namespace-scope names can be exported.
- // CHECK:STDERR: fail_b.carbon:[[@LINE+8]]:8: error: name qualifiers are only allowed for entities that provide a scope [QualifiedNameInNonScope]
- // CHECK:STDERR: export C.n;
- // CHECK:STDERR: ^
- // CHECK:STDERR: fail_b.carbon:[[@LINE-7]]:1: in import [InImport]
- // CHECK:STDERR: a.carbon:4:1: note: referenced non-scope entity declared here [QualifiedNameNonScopeEntity]
- // CHECK:STDERR: class C {
- // CHECK:STDERR: ^~~~~~~~~
- // CHECK:STDERR:
- export C.n;
- // CHECK:STDOUT: --- a.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %C: type = class_type @C [concrete]
- // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
- // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete]
- // CHECK:STDOUT: %C.elem: type = unbound_element_type %C, %empty_struct_type [concrete]
- // CHECK:STDOUT: %struct_type.n: type = struct_type {.n: %empty_struct_type} [concrete]
- // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.n [concrete]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
- // CHECK:STDOUT: .C = %C.decl
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: class @C {
- // CHECK:STDOUT: %.loc5_11.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
- // CHECK:STDOUT: %.loc5_11.2: type = converted %.loc5_11.1, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
- // CHECK:STDOUT: %.loc5_8: %C.elem = field_decl n, element0 [concrete]
- // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%struct_type.n [concrete = constants.%complete_type]
- // CHECK:STDOUT: complete_type_witness = %complete_type
- // CHECK:STDOUT:
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = constants.%C
- // CHECK:STDOUT: .n = %.loc5_8
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: --- fail_b.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %C: type = class_type @C [concrete]
- // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
- // CHECK:STDOUT: %struct_type.n: type = struct_type {.n: %empty_struct_type} [concrete]
- // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.n [concrete]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: imports {
- // CHECK:STDOUT: %Foo.C: type = import_ref Foo//a, C, loaded [concrete = constants.%C]
- // CHECK:STDOUT: %Foo.import_ref.9fc: <witness> = import_ref Foo//a, loc6_1, loaded [concrete = constants.%complete_type]
- // CHECK:STDOUT: %Foo.import_ref.1d1 = import_ref Foo//a, inst{{[0-9A-F]+}} [no loc], unloaded
- // CHECK:STDOUT: %Foo.import_ref.8c5 = import_ref Foo//a, loc5_8, unloaded
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
- // CHECK:STDOUT: .C = imports.%Foo.C
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %default.import = import <none>
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: class @C [from "a.carbon"] {
- // CHECK:STDOUT: complete_type_witness = imports.%Foo.import_ref.9fc
- // CHECK:STDOUT:
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = imports.%Foo.import_ref.1d1
- // CHECK:STDOUT: .n = imports.%Foo.import_ref.8c5
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
|