dec.carbon 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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/operators/overloaded/dec.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/operators/overloaded/dec.carbon
  10. // This file was generated from unary_stmt.carbon.tmpl. Run make_tests.sh to regenerate.
  11. package User;
  12. class C {};
  13. impl C as Core.Dec {
  14. fn Op[addr self: C*]();
  15. }
  16. fn TestOp() {
  17. var c: C = {};
  18. --c;
  19. }
  20. // CHECK:STDOUT: --- dec.carbon
  21. // CHECK:STDOUT:
  22. // CHECK:STDOUT: constants {
  23. // CHECK:STDOUT: %C: type = class_type @C [template]
  24. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  25. // CHECK:STDOUT: %.2: type = interface_type @Dec [template]
  26. // CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic]
  27. // CHECK:STDOUT: %.3: type = ptr_type %C [template]
  28. // CHECK:STDOUT: %Op.type.1: type = fn_type @Op.1 [template]
  29. // CHECK:STDOUT: %.4: type = tuple_type () [template]
  30. // CHECK:STDOUT: %Op.1: %Op.type.1 = struct_value () [template]
  31. // CHECK:STDOUT: %Op.type.2: type = fn_type @Op.2 [template]
  32. // CHECK:STDOUT: %Op.2: %Op.type.2 = struct_value () [template]
  33. // CHECK:STDOUT: %.5: type = ptr_type %Self [symbolic]
  34. // CHECK:STDOUT: %.6: <witness> = interface_witness (%Op.1) [template]
  35. // CHECK:STDOUT: %TestOp.type: type = fn_type @TestOp [template]
  36. // CHECK:STDOUT: %TestOp: %TestOp.type = struct_value () [template]
  37. // CHECK:STDOUT: %.7: type = ptr_type %.1 [template]
  38. // CHECK:STDOUT: %struct: %C = struct_value () [template]
  39. // CHECK:STDOUT: %.8: type = assoc_entity_type %.2, %Op.type.2 [template]
  40. // CHECK:STDOUT: %.9: %.8 = assoc_entity element0, imports.%import_ref.5 [template]
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: imports {
  44. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  45. // CHECK:STDOUT: .Dec = %import_ref.1
  46. // CHECK:STDOUT: import Core//prelude
  47. // CHECK:STDOUT: import Core//prelude/operators
  48. // CHECK:STDOUT: import Core//prelude/types
  49. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  50. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  51. // CHECK:STDOUT: import Core//prelude/operators/comparison
  52. // CHECK:STDOUT: import Core//prelude/types/bool
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT: %import_ref.1: type = import_ref Core//prelude/operators/arithmetic, inst+142, loaded [template = constants.%.2]
  55. // CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/arithmetic, inst+144, unloaded
  56. // CHECK:STDOUT: %import_ref.3: %.8 = import_ref Core//prelude/operators/arithmetic, inst+160, loaded [template = constants.%.9]
  57. // CHECK:STDOUT: %import_ref.4: %Op.type.2 = import_ref Core//prelude/operators/arithmetic, inst+154, loaded [template = constants.%Op.2]
  58. // CHECK:STDOUT: %import_ref.5 = import_ref Core//prelude/operators/arithmetic, inst+154, unloaded
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT:
  61. // CHECK:STDOUT: file {
  62. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  63. // CHECK:STDOUT: .Core = imports.%Core
  64. // CHECK:STDOUT: .C = %C.decl
  65. // CHECK:STDOUT: .TestOp = %TestOp.decl
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT: %Core.import = import Core
  68. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
  69. // CHECK:STDOUT: impl_decl @impl {
  70. // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C]
  71. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [template = imports.%Core]
  72. // CHECK:STDOUT: %Dec.ref: type = name_ref Dec, imports.%import_ref.1 [template = constants.%.2]
  73. // CHECK:STDOUT: }
  74. // CHECK:STDOUT: %TestOp.decl: %TestOp.type = fn_decl @TestOp [template = constants.%TestOp] {}
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT:
  77. // CHECK:STDOUT: interface @Dec {
  78. // CHECK:STDOUT: !members:
  79. // CHECK:STDOUT: .Self = imports.%import_ref.2
  80. // CHECK:STDOUT: .Op = imports.%import_ref.3
  81. // CHECK:STDOUT: witness = (imports.%import_ref.4)
  82. // CHECK:STDOUT: }
  83. // CHECK:STDOUT:
  84. // CHECK:STDOUT: impl @impl: %C as %.2 {
  85. // CHECK:STDOUT: %Op.decl: %Op.type.1 = fn_decl @Op.1 [template = constants.%Op.1] {
  86. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  87. // CHECK:STDOUT: %.loc18_21: type = ptr_type %C [template = constants.%.3]
  88. // CHECK:STDOUT: %self.loc18_14.1: %.3 = param self
  89. // CHECK:STDOUT: %self.loc18_14.3: %.3 = bind_name self, %self.loc18_14.1
  90. // CHECK:STDOUT: %.loc18_9: %.3 = addr_pattern %self.loc18_14.3
  91. // CHECK:STDOUT: }
  92. // CHECK:STDOUT: %.1: <witness> = interface_witness (%Op.decl) [template = constants.%.6]
  93. // CHECK:STDOUT:
  94. // CHECK:STDOUT: !members:
  95. // CHECK:STDOUT: .Op = %Op.decl
  96. // CHECK:STDOUT: witness = %.1
  97. // CHECK:STDOUT: }
  98. // CHECK:STDOUT:
  99. // CHECK:STDOUT: class @C {
  100. // CHECK:STDOUT: !members:
  101. // CHECK:STDOUT: .Self = constants.%C
  102. // CHECK:STDOUT: }
  103. // CHECK:STDOUT:
  104. // CHECK:STDOUT: fn @Op.1[addr @impl.%self.loc18_14.3: %.3]();
  105. // CHECK:STDOUT:
  106. // CHECK:STDOUT: generic fn @Op.2(constants.%Self: %.2) {
  107. // CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)]
  108. // CHECK:STDOUT: %.2: type = ptr_type @Op.2.%Self (%Self) [symbolic = %.2 (constants.%.5)]
  109. // CHECK:STDOUT:
  110. // CHECK:STDOUT: fn[addr %self: @Op.2.%.2 (%.5)]();
  111. // CHECK:STDOUT: }
  112. // CHECK:STDOUT:
  113. // CHECK:STDOUT: fn @TestOp() {
  114. // CHECK:STDOUT: !entry:
  115. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  116. // CHECK:STDOUT: %c.var: ref %C = var c
  117. // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var
  118. // CHECK:STDOUT: %.loc22_15.1: %.1 = struct_literal ()
  119. // CHECK:STDOUT: %.loc22_15.2: init %C = class_init (), %c.var [template = constants.%struct]
  120. // CHECK:STDOUT: %.loc22_16: init %C = converted %.loc22_15.1, %.loc22_15.2 [template = constants.%struct]
  121. // CHECK:STDOUT: assign %c.var, %.loc22_16
  122. // CHECK:STDOUT: %c.ref: ref %C = name_ref c, %c
  123. // CHECK:STDOUT: %.1: %Op.type.2 = interface_witness_access @impl.%.1, element0 [template = constants.%Op.1]
  124. // CHECK:STDOUT: %.loc23_3: <bound method> = bound_method %c.ref, %.1
  125. // CHECK:STDOUT: %.loc23_5: %.3 = addr_of %c.ref
  126. // CHECK:STDOUT: %Op.call: init %.4 = call %.loc23_3(%.loc23_5)
  127. // CHECK:STDOUT: return
  128. // CHECK:STDOUT: }
  129. // CHECK:STDOUT:
  130. // CHECK:STDOUT: specific @Op.2(constants.%Self) {
  131. // CHECK:STDOUT: %Self => constants.%Self
  132. // CHECK:STDOUT: %.2 => constants.%.5
  133. // CHECK:STDOUT: }
  134. // CHECK:STDOUT:
  135. // CHECK:STDOUT: specific @Op.2(constants.%C) {
  136. // CHECK:STDOUT: %Self => constants.%C
  137. // CHECK:STDOUT: %.2 => constants.%.3
  138. // CHECK:STDOUT: }
  139. // CHECK:STDOUT: