import_member_cycle.carbon 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 "a";
  12. class Cycle {
  13. var a: Cycle*;
  14. }
  15. // --- b.carbon
  16. library "b";
  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: }
  29. // CHECK:STDOUT:
  30. // CHECK:STDOUT: file {
  31. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  32. // CHECK:STDOUT: .Core = %Core
  33. // CHECK:STDOUT: .Cycle = %Cycle.decl
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  36. // CHECK:STDOUT: %Cycle.decl: type = class_decl @Cycle [template = constants.%Cycle] {}
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT:
  39. // CHECK:STDOUT: class @Cycle {
  40. // CHECK:STDOUT: %Cycle.ref: type = name_ref Cycle, file.%Cycle.decl [template = constants.%Cycle]
  41. // CHECK:STDOUT: %.loc5_15: type = ptr_type %Cycle [template = constants.%.1]
  42. // CHECK:STDOUT: %.loc5_8: %.2 = field_decl a, element0 [template]
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: !members:
  45. // CHECK:STDOUT: .Self = constants.%Cycle
  46. // CHECK:STDOUT: .a = %.loc5_8
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: --- b.carbon
  50. // CHECK:STDOUT:
  51. // CHECK:STDOUT: constants {
  52. // CHECK:STDOUT: %Run.type: type = fn_type @Run [template]
  53. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  54. // CHECK:STDOUT: %Run: %Run.type = struct_value () [template]
  55. // CHECK:STDOUT: %Cycle: type = class_type @Cycle [template]
  56. // CHECK:STDOUT: %.2: type = ptr_type %Cycle [template]
  57. // CHECK:STDOUT: %.3: type = struct_type {.a: %.2} [template]
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: file {
  61. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  62. // CHECK:STDOUT: .Cycle = %import_ref.1
  63. // CHECK:STDOUT: .Core = %Core
  64. // CHECK:STDOUT: .Run = %Run.decl
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+2, loaded [template = constants.%Cycle]
  67. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  68. // CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [template = constants.%Run] {}
  69. // CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+3, unloaded
  70. // CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+8, unloaded
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: class @Cycle {
  74. // CHECK:STDOUT: !members:
  75. // CHECK:STDOUT: .Self = file.%import_ref.2
  76. // CHECK:STDOUT: .a = file.%import_ref.3
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: fn @Run() {
  80. // CHECK:STDOUT: !entry:
  81. // CHECK:STDOUT: %Cycle.ref: type = name_ref Cycle, file.%import_ref.1 [template = constants.%Cycle]
  82. // CHECK:STDOUT: %.loc7: type = ptr_type %Cycle [template = constants.%.2]
  83. // CHECK:STDOUT: %a.var: ref %.2 = var a
  84. // CHECK:STDOUT: %a: ref %.2 = bind_name a, %a.var
  85. // CHECK:STDOUT: return
  86. // CHECK:STDOUT: }
  87. // CHECK:STDOUT: