generic_import.carbon 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/let/generic_import.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/let/generic_import.carbon
  10. // --- implicit.carbon
  11. package Implicit;
  12. let T:! type = i32;
  13. // --- implicit.impl.carbon
  14. impl package Implicit;
  15. var a: T*;
  16. var b: T = *a;
  17. // CHECK:STDOUT: --- implicit.carbon
  18. // CHECK:STDOUT:
  19. // CHECK:STDOUT: constants {
  20. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  21. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  22. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  23. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic]
  24. // CHECK:STDOUT: }
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: file {
  27. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  28. // CHECK:STDOUT: .Core = %Core
  29. // CHECK:STDOUT: .T = @__global_init.%T
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  32. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  36. // CHECK:STDOUT:
  37. // CHECK:STDOUT: fn @__global_init() {
  38. // CHECK:STDOUT: !entry:
  39. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  40. // CHECK:STDOUT: %.loc4_19.1: type = value_of_initializer %int.make_type_32 [template = i32]
  41. // CHECK:STDOUT: %.loc4_19.2: type = converted %int.make_type_32, %.loc4_19.1 [template = i32]
  42. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0, %.loc4_19.2 [symbolic = constants.%T]
  43. // CHECK:STDOUT: return
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT:
  46. // CHECK:STDOUT: --- implicit.impl.carbon
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: constants {
  49. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic]
  50. // CHECK:STDOUT: %.1: type = ptr_type %T [symbolic]
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: file {
  54. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  55. // CHECK:STDOUT: .T = %import_ref
  56. // CHECK:STDOUT: .Core = %Core
  57. // CHECK:STDOUT: .a = %a
  58. // CHECK:STDOUT: .b = %b
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT: %import_ref: type = import_ref ir0, inst+2, loaded [symbolic = constants.%T]
  61. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  62. // CHECK:STDOUT: %T.ref.loc4: type = name_ref T, %import_ref [symbolic = constants.%T]
  63. // CHECK:STDOUT: %.loc4: type = ptr_type %T [symbolic = constants.%.1]
  64. // CHECK:STDOUT: %a.var: ref %.1 = var a
  65. // CHECK:STDOUT: %a: ref %.1 = bind_name a, %a.var
  66. // CHECK:STDOUT: %T.ref.loc5: type = name_ref T, %import_ref [symbolic = constants.%T]
  67. // CHECK:STDOUT: %b.var: ref %T = var b
  68. // CHECK:STDOUT: %b: ref %T = bind_name b, %b.var
  69. // CHECK:STDOUT: }
  70. // CHECK:STDOUT:
  71. // CHECK:STDOUT: fn @__global_init() {
  72. // CHECK:STDOUT: !entry:
  73. // CHECK:STDOUT: %a.ref: ref %.1 = name_ref a, file.%a
  74. // CHECK:STDOUT: %.loc5_13: %.1 = bind_value %a.ref
  75. // CHECK:STDOUT: %.loc5_12.1: ref %T = deref %.loc5_13
  76. // CHECK:STDOUT: %.loc5_12.2: %T = bind_value %.loc5_12.1
  77. // CHECK:STDOUT: assign file.%b.var, %.loc5_12.2
  78. // CHECK:STDOUT: return
  79. // CHECK:STDOUT: }
  80. // CHECK:STDOUT: