complete_in_member_fn.carbon 4.1 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. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/complete_in_member_fn.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/complete_in_member_fn.carbon
  10. class C {
  11. fn F(c: C) -> i32 { return c.a; }
  12. var a: i32;
  13. }
  14. // CHECK:STDOUT: --- complete_in_member_fn.carbon
  15. // CHECK:STDOUT:
  16. // CHECK:STDOUT: constants {
  17. // CHECK:STDOUT: %C: type = class_type @C [template]
  18. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  19. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  20. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  21. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  22. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  23. // CHECK:STDOUT: %.2: type = unbound_element_type %C, i32 [template]
  24. // CHECK:STDOUT: %.3: type = struct_type {.a: i32} [template]
  25. // CHECK:STDOUT: %.4: type = ptr_type %.3 [template]
  26. // CHECK:STDOUT: }
  27. // CHECK:STDOUT:
  28. // CHECK:STDOUT: imports {
  29. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  30. // CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: file {
  34. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  35. // CHECK:STDOUT: .Core = %Core
  36. // CHECK:STDOUT: .C = %C.decl
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: %Core.import = import Core
  39. // CHECK:STDOUT: %Core: <namespace> = namespace %Core.import, [template] {
  40. // CHECK:STDOUT: import Core//prelude
  41. // CHECK:STDOUT: import Core//prelude/operators
  42. // CHECK:STDOUT: import Core//prelude/types
  43. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  44. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  45. // CHECK:STDOUT: import Core//prelude/operators/comparison
  46. // CHECK:STDOUT: import Core//prelude/types/bool
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT:
  51. // CHECK:STDOUT: class @C {
  52. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  53. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  54. // CHECK:STDOUT: %c.loc12_8.1: %C = param c
  55. // CHECK:STDOUT: %c.loc12_8.2: %C = bind_name c, %c.loc12_8.1
  56. // CHECK:STDOUT: %int.make_type_32.loc12: init type = call constants.%Int32() [template = i32]
  57. // CHECK:STDOUT: %.loc12_17.1: type = value_of_initializer %int.make_type_32.loc12 [template = i32]
  58. // CHECK:STDOUT: %.loc12_17.2: type = converted %int.make_type_32.loc12, %.loc12_17.1 [template = i32]
  59. // CHECK:STDOUT: %return.var: ref i32 = var <return slot>
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT: %int.make_type_32.loc14: init type = call constants.%Int32() [template = i32]
  62. // CHECK:STDOUT: %.loc14_10.1: type = value_of_initializer %int.make_type_32.loc14 [template = i32]
  63. // CHECK:STDOUT: %.loc14_10.2: type = converted %int.make_type_32.loc14, %.loc14_10.1 [template = i32]
  64. // CHECK:STDOUT: %.loc14_8: %.2 = field_decl a, element0 [template]
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: !members:
  67. // CHECK:STDOUT: .Self = constants.%C
  68. // CHECK:STDOUT: .F = %F.decl
  69. // CHECK:STDOUT: .a = %.loc14_8
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT:
  72. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  73. // CHECK:STDOUT:
  74. // CHECK:STDOUT: fn @F(@C.%c.loc12_8.2: %C) -> i32 {
  75. // CHECK:STDOUT: !entry:
  76. // CHECK:STDOUT: %c.ref: %C = name_ref c, @C.%c.loc12_8.2
  77. // CHECK:STDOUT: %a.ref: %.2 = name_ref a, @C.%.loc14_8 [template = @C.%.loc14_8]
  78. // CHECK:STDOUT: %.loc12_31.1: ref i32 = class_element_access %c.ref, element0
  79. // CHECK:STDOUT: %.loc12_31.2: i32 = bind_value %.loc12_31.1
  80. // CHECK:STDOUT: return %.loc12_31.2
  81. // CHECK:STDOUT: }
  82. // CHECK:STDOUT: