| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272 |
- // 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/alias/no_prelude/export_name.carbon
- // TIP: To dump output, run:
- // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/alias/no_prelude/export_name.carbon
- // ============================================================================
- // Setup files
- // ============================================================================
- // --- base.carbon
- library "[[@TEST_NAME]]";
- class C {}
- alias D = C;
- // --- export.carbon
- library "[[@TEST_NAME]]";
- import library "base";
- export D;
- // --- export_orig.carbon
- library "[[@TEST_NAME]]";
- import library "base";
- export C;
- // ============================================================================
- // Test files
- // ============================================================================
- // --- use_export.carbon
- library "[[@TEST_NAME]]";
- import library "export";
- var d: D = {};
- // --- fail_orig_name_not_in_export.carbon
- library "[[@TEST_NAME]]";
- import library "export";
- // CHECK:STDERR: fail_orig_name_not_in_export.carbon:[[@LINE+3]]:8: error: name `C` not found
- // CHECK:STDERR: var c: C = {};
- // CHECK:STDERR: ^
- var c: C = {};
- // --- indirect_compat.carbon
- library "[[@TEST_NAME]]";
- import library "export";
- import library "export_orig";
- var c: C = {};
- var d: D* = &c;
- // CHECK:STDOUT: --- base.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %C: type = class_type @C [template]
- // CHECK:STDOUT: %.1: type = struct_type {} [template]
- // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = namespace [template] {
- // CHECK:STDOUT: .C = %C.decl
- // CHECK:STDOUT: .D = %D
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
- // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C]
- // CHECK:STDOUT: %D: type = bind_alias D, %C.decl [template = constants.%C]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: class @C {
- // CHECK:STDOUT: %.loc4: <witness> = complete_type_witness %.1 [template = constants.%.2]
- // CHECK:STDOUT:
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = constants.%C
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: --- export.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %C: type = class_type @C [template]
- // CHECK:STDOUT: %.1: type = struct_type {} [template]
- // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: imports {
- // CHECK:STDOUT: %import_ref.1 = import_ref Main//base, inst+1, unloaded
- // CHECK:STDOUT: %import_ref.2: type = import_ref Main//base, inst+7, loaded [template = constants.%C]
- // CHECK:STDOUT: %import_ref.3 = import_ref Main//base, inst+2, unloaded
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = namespace [template] {
- // CHECK:STDOUT: .C = imports.%import_ref.1
- // CHECK:STDOUT: .D = %D
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %default.import = import <invalid>
- // CHECK:STDOUT: %D: type = export D, imports.%import_ref.2 [template = constants.%C]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: class @C {
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = imports.%import_ref.3
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: --- export_orig.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %C: type = class_type @C [template]
- // CHECK:STDOUT: %.1: type = struct_type {} [template]
- // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: imports {
- // CHECK:STDOUT: %import_ref.1: type = import_ref Main//base, inst+1, loaded [template = constants.%C]
- // CHECK:STDOUT: %import_ref.2 = import_ref Main//base, inst+7, unloaded
- // CHECK:STDOUT: %import_ref.3 = import_ref Main//base, inst+2, unloaded
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = namespace [template] {
- // CHECK:STDOUT: .C = %C
- // CHECK:STDOUT: .D = imports.%import_ref.2
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %default.import = import <invalid>
- // CHECK:STDOUT: %C: type = export C, imports.%import_ref.1 [template = constants.%C]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: class @C {
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = imports.%import_ref.3
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: --- use_export.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %C: type = class_type @C [template]
- // CHECK:STDOUT: %.1: type = struct_type {} [template]
- // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
- // CHECK:STDOUT: %.3: type = tuple_type () [template]
- // CHECK:STDOUT: %.4: type = ptr_type %.1 [template]
- // CHECK:STDOUT: %struct: %C = struct_value () [template]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: imports {
- // CHECK:STDOUT: %import_ref.1: type = import_ref Main//export, inst+9, loaded [template = constants.%C]
- // CHECK:STDOUT: %import_ref.2 = import_ref Main//export, inst+8, unloaded
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = namespace [template] {
- // CHECK:STDOUT: .D = imports.%import_ref.1
- // CHECK:STDOUT: .d = %d
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %default.import = import <invalid>
- // CHECK:STDOUT: %D.ref: type = name_ref D, imports.%import_ref.1 [template = constants.%C]
- // CHECK:STDOUT: %d.var: ref %C = var d
- // CHECK:STDOUT: %d: ref %C = bind_name d, %d.var
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: class @C {
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = imports.%import_ref.2
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @__global_init() {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: %.loc6_13.1: %.1 = struct_literal ()
- // CHECK:STDOUT: %.loc6_13.2: init %C = class_init (), file.%d.var [template = constants.%struct]
- // CHECK:STDOUT: %.loc6_14: init %C = converted %.loc6_13.1, %.loc6_13.2 [template = constants.%struct]
- // CHECK:STDOUT: assign file.%d.var, %.loc6_14
- // CHECK:STDOUT: return
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: --- fail_orig_name_not_in_export.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %.1: type = struct_type {} [template]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: imports {
- // CHECK:STDOUT: %import_ref = import_ref Main//export, inst+9, unloaded
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = namespace [template] {
- // CHECK:STDOUT: .D = imports.%import_ref
- // CHECK:STDOUT: .c = %c
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %default.import = import <invalid>
- // CHECK:STDOUT: %C.ref: <error> = name_ref C, <error> [template = <error>]
- // CHECK:STDOUT: %c.var: ref <error> = var c
- // CHECK:STDOUT: %c: ref <error> = bind_name c, %c.var
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @__global_init() {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: %.loc9: %.1 = struct_literal ()
- // CHECK:STDOUT: assign file.%c.var, <error>
- // CHECK:STDOUT: return
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: --- indirect_compat.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %C: type = class_type @C [template]
- // CHECK:STDOUT: %.1: type = struct_type {} [template]
- // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
- // CHECK:STDOUT: %.3: type = tuple_type () [template]
- // CHECK:STDOUT: %.4: type = ptr_type %.1 [template]
- // CHECK:STDOUT: %struct: %C = struct_value () [template]
- // CHECK:STDOUT: %.5: type = ptr_type %C [template]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: imports {
- // CHECK:STDOUT: %import_ref.1: type = import_ref Main//export, inst+9, loaded [template = constants.%C]
- // CHECK:STDOUT: %import_ref.2: type = import_ref Main//export_orig, inst+9, loaded [template = constants.%C]
- // CHECK:STDOUT: %import_ref.3 = import_ref Main//export_orig, inst+8, unloaded
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = namespace [template] {
- // CHECK:STDOUT: .D = imports.%import_ref.1
- // CHECK:STDOUT: .C = imports.%import_ref.2
- // CHECK:STDOUT: .c = %c
- // CHECK:STDOUT: .d = %d
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %default.import = import <invalid>
- // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.2 [template = constants.%C]
- // CHECK:STDOUT: %c.var: ref %C = var c
- // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var
- // CHECK:STDOUT: %D.ref: type = name_ref D, imports.%import_ref.1 [template = constants.%C]
- // CHECK:STDOUT: %.loc8: type = ptr_type %C [template = constants.%.5]
- // CHECK:STDOUT: %d.var: ref %.5 = var d
- // CHECK:STDOUT: %d: ref %.5 = bind_name d, %d.var
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: class @C {
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = imports.%import_ref.3
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @__global_init() {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: %.loc7_13.1: %.1 = struct_literal ()
- // CHECK:STDOUT: %.loc7_13.2: init %C = class_init (), file.%c.var [template = constants.%struct]
- // CHECK:STDOUT: %.loc7_14: init %C = converted %.loc7_13.1, %.loc7_13.2 [template = constants.%struct]
- // CHECK:STDOUT: assign file.%c.var, %.loc7_14
- // CHECK:STDOUT: %c.ref: ref %C = name_ref c, file.%c
- // CHECK:STDOUT: %.loc8: %.5 = addr_of %c.ref
- // CHECK:STDOUT: assign file.%d.var, %.loc8
- // CHECK:STDOUT: return
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
|