in_namespace.carbon 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. class C { var v: i32; }
  7. namespace NS;
  8. alias NS.a = C;
  9. let b: NS.a = {.v = 0};
  10. fn F() -> NS.a {
  11. return {.v = 0};
  12. }
  13. // CHECK:STDOUT: --- in_namespace.carbon
  14. // CHECK:STDOUT:
  15. // CHECK:STDOUT: constants {
  16. // CHECK:STDOUT: %C: type = class_type @C [template]
  17. // CHECK:STDOUT: %.1: type = unbound_element_type C, i32 [template]
  18. // CHECK:STDOUT: %.2: type = struct_type {.v: i32} [template]
  19. // CHECK:STDOUT: %.3: type = ptr_type {.v: i32} [template]
  20. // CHECK:STDOUT: %.4: i32 = int_literal 0 [template]
  21. // CHECK:STDOUT: %.5: C = struct_value (%.4) [template]
  22. // CHECK:STDOUT: }
  23. // CHECK:STDOUT:
  24. // CHECK:STDOUT: file {
  25. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  26. // CHECK:STDOUT: .Core = %Core
  27. // CHECK:STDOUT: .C = %C.decl
  28. // CHECK:STDOUT: .NS = %NS
  29. // CHECK:STDOUT: .F = %F
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  32. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
  33. // CHECK:STDOUT: %NS: <namespace> = namespace [template] {
  34. // CHECK:STDOUT: .a = %a
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C]
  37. // CHECK:STDOUT: %a: type = bind_alias a, %C.decl [template = constants.%C]
  38. // CHECK:STDOUT: %NS.ref.loc12: <namespace> = name_ref NS, %NS [template = %NS]
  39. // CHECK:STDOUT: %a.ref.loc12: type = name_ref a, %a [template = constants.%C]
  40. // CHECK:STDOUT: %.loc12_21: i32 = int_literal 0 [template = constants.%.4]
  41. // CHECK:STDOUT: %.loc12_22.1: {.v: i32} = struct_literal (%.loc12_21)
  42. // CHECK:STDOUT: %.loc12_22.2: ref C = temporary_storage
  43. // CHECK:STDOUT: %.loc12_22.3: ref i32 = class_element_access %.loc12_22.2, element0
  44. // CHECK:STDOUT: %.loc12_22.4: init i32 = initialize_from %.loc12_21 to %.loc12_22.3 [template = constants.%.4]
  45. // CHECK:STDOUT: %.loc12_22.5: init C = class_init (%.loc12_22.4), %.loc12_22.2 [template = constants.%.5]
  46. // CHECK:STDOUT: %.loc12_22.6: ref C = temporary %.loc12_22.2, %.loc12_22.5
  47. // CHECK:STDOUT: %.loc12_22.7: ref C = converted %.loc12_22.1, %.loc12_22.6
  48. // CHECK:STDOUT: %.loc12_22.8: C = bind_value %.loc12_22.7
  49. // CHECK:STDOUT: %b: C = bind_name b, %.loc12_22.8
  50. // CHECK:STDOUT: %F: <function> = fn_decl @F [template] {
  51. // CHECK:STDOUT: %NS.ref.loc14: <namespace> = name_ref NS, %NS [template = %NS]
  52. // CHECK:STDOUT: %a.ref.loc14: type = name_ref a, %a [template = constants.%C]
  53. // CHECK:STDOUT: @F.%return: ref C = var <return slot>
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT:
  57. // CHECK:STDOUT: class @C {
  58. // CHECK:STDOUT: %.loc7: <unbound element of class C> = field_decl v, element0 [template]
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: !members:
  61. // CHECK:STDOUT: .Self = constants.%C
  62. // CHECK:STDOUT: .v = %.loc7
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: fn @F() -> %return: C {
  66. // CHECK:STDOUT: !entry:
  67. // CHECK:STDOUT: %.loc15_16: i32 = int_literal 0 [template = constants.%.4]
  68. // CHECK:STDOUT: %.loc15_17.1: {.v: i32} = struct_literal (%.loc15_16)
  69. // CHECK:STDOUT: %.loc15_17.2: ref i32 = class_element_access %return, element0
  70. // CHECK:STDOUT: %.loc15_17.3: init i32 = initialize_from %.loc15_16 to %.loc15_17.2 [template = constants.%.4]
  71. // CHECK:STDOUT: %.loc15_17.4: init C = class_init (%.loc15_17.3), %return [template = constants.%.5]
  72. // CHECK:STDOUT: %.loc15_17.5: init C = converted %.loc15_17.1, %.loc15_17.4 [template = constants.%.5]
  73. // CHECK:STDOUT: return %.loc15_17.5
  74. // CHECK:STDOUT: }
  75. // CHECK:STDOUT: