import_member_cycle.carbon 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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/class/import_member_cycle.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/import_member_cycle.carbon
  10. // --- a.carbon
  11. library "[[@TEST_NAME]]";
  12. class Cycle {
  13. var a: Cycle*;
  14. }
  15. // --- b.carbon
  16. library "[[@TEST_NAME]]";
  17. import library "a";
  18. fn Run() {
  19. var a: Cycle*;
  20. }
  21. // CHECK:STDOUT: --- a.carbon
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: constants {
  24. // CHECK:STDOUT: %Cycle: type = class_type @Cycle [template]
  25. // CHECK:STDOUT: %.1: type = ptr_type %Cycle [template]
  26. // CHECK:STDOUT: %.2: type = unbound_element_type %Cycle, %.1 [template]
  27. // CHECK:STDOUT: %.3: type = struct_type {.a: %.1} [template]
  28. // CHECK:STDOUT: %.4: <witness> = complete_type_witness %.3 [template]
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT:
  31. // CHECK:STDOUT: imports {
  32. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  33. // CHECK:STDOUT: import Core//prelude
  34. // CHECK:STDOUT: import Core//prelude/...
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: file {
  39. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  40. // CHECK:STDOUT: .Core = imports.%Core
  41. // CHECK:STDOUT: .Cycle = %Cycle.decl
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT: %Core.import = import Core
  44. // CHECK:STDOUT: %Cycle.decl: type = class_decl @Cycle [template = constants.%Cycle] {} {}
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: class @Cycle {
  48. // CHECK:STDOUT: %Cycle.ref: type = name_ref Cycle, file.%Cycle.decl [template = constants.%Cycle]
  49. // CHECK:STDOUT: %.loc5_15: type = ptr_type %Cycle [template = constants.%.1]
  50. // CHECK:STDOUT: %.loc5_8: %.2 = field_decl a, element0 [template]
  51. // CHECK:STDOUT: %.loc6: <witness> = complete_type_witness %.3 [template = constants.%.4]
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: !members:
  54. // CHECK:STDOUT: .Self = constants.%Cycle
  55. // CHECK:STDOUT: .a = %.loc5_8
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT:
  58. // CHECK:STDOUT: --- b.carbon
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: constants {
  61. // CHECK:STDOUT: %Run.type: type = fn_type @Run [template]
  62. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  63. // CHECK:STDOUT: %Run: %Run.type = struct_value () [template]
  64. // CHECK:STDOUT: %Cycle: type = class_type @Cycle [template]
  65. // CHECK:STDOUT: %.2: type = ptr_type %Cycle [template]
  66. // CHECK:STDOUT: %.3: type = struct_type {.a: %.2} [template]
  67. // CHECK:STDOUT: %.4: <witness> = complete_type_witness %.3 [template]
  68. // CHECK:STDOUT: }
  69. // CHECK:STDOUT:
  70. // CHECK:STDOUT: imports {
  71. // CHECK:STDOUT: %import_ref.1: type = import_ref Main//a, inst+3, loaded [template = constants.%Cycle]
  72. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  73. // CHECK:STDOUT: import Core//prelude
  74. // CHECK:STDOUT: import Core//prelude/...
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT: %import_ref.2 = import_ref Main//a, inst+4, unloaded
  77. // CHECK:STDOUT: %import_ref.3 = import_ref Main//a, inst+9, unloaded
  78. // CHECK:STDOUT: }
  79. // CHECK:STDOUT:
  80. // CHECK:STDOUT: file {
  81. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  82. // CHECK:STDOUT: .Cycle = imports.%import_ref.1
  83. // CHECK:STDOUT: .Core = imports.%Core
  84. // CHECK:STDOUT: .Run = %Run.decl
  85. // CHECK:STDOUT: }
  86. // CHECK:STDOUT: %Core.import = import Core
  87. // CHECK:STDOUT: %default.import = import <invalid>
  88. // CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [template = constants.%Run] {} {}
  89. // CHECK:STDOUT: }
  90. // CHECK:STDOUT:
  91. // CHECK:STDOUT: class @Cycle {
  92. // CHECK:STDOUT: !members:
  93. // CHECK:STDOUT: .Self = imports.%import_ref.2
  94. // CHECK:STDOUT: .a = imports.%import_ref.3
  95. // CHECK:STDOUT: }
  96. // CHECK:STDOUT:
  97. // CHECK:STDOUT: fn @Run() {
  98. // CHECK:STDOUT: !entry:
  99. // CHECK:STDOUT: %Cycle.ref: type = name_ref Cycle, imports.%import_ref.1 [template = constants.%Cycle]
  100. // CHECK:STDOUT: %.loc7: type = ptr_type %Cycle [template = constants.%.2]
  101. // CHECK:STDOUT: %a.var: ref %.2 = var a
  102. // CHECK:STDOUT: %a: ref %.2 = bind_name a, %a.var
  103. // CHECK:STDOUT: return
  104. // CHECK:STDOUT: }
  105. // CHECK:STDOUT: