import_member_cycle.carbon 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. // --- a.carbon
  7. library "a" api;
  8. class Cycle {
  9. var a: Cycle*;
  10. }
  11. // --- b.carbon
  12. library "b" api;
  13. import library "a";
  14. fn Run() {
  15. var a: Cycle*;
  16. }
  17. // CHECK:STDOUT: --- a.carbon
  18. // CHECK:STDOUT:
  19. // CHECK:STDOUT: constants {
  20. // CHECK:STDOUT: %Cycle: type = class_type @Cycle [template]
  21. // CHECK:STDOUT: %.1: type = ptr_type Cycle [template]
  22. // CHECK:STDOUT: %.2: type = unbound_element_type Cycle, Cycle* [template]
  23. // CHECK:STDOUT: %.3: type = struct_type {.a: Cycle*} [template]
  24. // CHECK:STDOUT: }
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: file {
  27. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  28. // CHECK:STDOUT: .Cycle = %Cycle.decl
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT: %Cycle.decl: type = class_decl @Cycle [template = constants.%Cycle] {}
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: class @Cycle {
  34. // CHECK:STDOUT: %Cycle.ref: type = name_ref Cycle, file.%Cycle.decl [template = constants.%Cycle]
  35. // CHECK:STDOUT: %.loc5_15: type = ptr_type Cycle [template = constants.%.1]
  36. // CHECK:STDOUT: %.loc5_8: <unbound element of class Cycle> = field_decl a, element0 [template]
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: !members:
  39. // CHECK:STDOUT: .Self = constants.%Cycle
  40. // CHECK:STDOUT: .a = %.loc5_8
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: --- b.carbon
  44. // CHECK:STDOUT:
  45. // CHECK:STDOUT: constants {
  46. // CHECK:STDOUT: %Cycle: type = class_type @Cycle [template]
  47. // CHECK:STDOUT: %.1: type = ptr_type Cycle [template]
  48. // CHECK:STDOUT: %.2: type = struct_type {.a: Cycle*} [template]
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT:
  51. // CHECK:STDOUT: file {
  52. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  53. // CHECK:STDOUT: .Cycle = %import_ref.1
  54. // CHECK:STDOUT: .Run = %Run
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+1, used [template = constants.%Cycle]
  57. // CHECK:STDOUT: %Run: <function> = fn_decl @Run [template] {}
  58. // CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+7, unused
  59. // CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+2, unused
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: class @Cycle {
  63. // CHECK:STDOUT: !members:
  64. // CHECK:STDOUT: .a = file.%import_ref.2
  65. // CHECK:STDOUT: .Self = file.%import_ref.3
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: fn @Run() {
  69. // CHECK:STDOUT: !entry:
  70. // CHECK:STDOUT: %Cycle.decl: invalid = class_decl @Cycle [template = constants.%Cycle] {}
  71. // CHECK:STDOUT: %Cycle.ref: type = name_ref Cycle, file.%import_ref.1 [template = constants.%Cycle]
  72. // CHECK:STDOUT: %.loc7: type = ptr_type Cycle [template = constants.%.1]
  73. // CHECK:STDOUT: %a.var: ref Cycle* = var a
  74. // CHECK:STDOUT: %a: ref Cycle* = bind_name a, %a.var
  75. // CHECK:STDOUT: return
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT: