inc.carbon 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/full.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/operators/overloaded/inc.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/operators/overloaded/inc.carbon
  14. // This file was generated from unary_stmt.carbon.tmpl. Run make_tests.sh to regenerate.
  15. package User;
  16. class C {};
  17. impl C as Core.Inc {
  18. fn Op[ref self: C]();
  19. }
  20. fn TestOp() {
  21. var c: C = {};
  22. //@dump-sem-ir-begin
  23. ++c;
  24. //@dump-sem-ir-end
  25. }
  26. // CHECK:STDOUT: --- inc.carbon
  27. // CHECK:STDOUT:
  28. // CHECK:STDOUT: constants {
  29. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  30. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  31. // CHECK:STDOUT: %Inc.type: type = facet_type <@Inc> [concrete]
  32. // CHECK:STDOUT: %Inc.Op.type: type = fn_type @Inc.Op [concrete]
  33. // CHECK:STDOUT: %Inc.impl_witness: <witness> = impl_witness file.%Inc.impl_witness_table [concrete]
  34. // CHECK:STDOUT: %C.as.Inc.impl.Op.type: type = fn_type @C.as.Inc.impl.Op [concrete]
  35. // CHECK:STDOUT: %C.as.Inc.impl.Op: %C.as.Inc.impl.Op.type = struct_value () [concrete]
  36. // CHECK:STDOUT: %Inc.facet: %Inc.type = facet_value %C, (%Inc.impl_witness) [concrete]
  37. // CHECK:STDOUT: %.35f: type = fn_type_with_self_type %Inc.Op.type, %Inc.facet [concrete]
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT:
  40. // CHECK:STDOUT: imports {
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: fn @TestOp() {
  44. // CHECK:STDOUT: !entry:
  45. // CHECK:STDOUT: <elided>
  46. // CHECK:STDOUT: %c.ref: ref %C = name_ref c, %c
  47. // CHECK:STDOUT: %impl.elem0: %.35f = impl_witness_access constants.%Inc.impl_witness, element0 [concrete = constants.%C.as.Inc.impl.Op]
  48. // CHECK:STDOUT: %bound_method.loc28: <bound method> = bound_method %c.ref, %impl.elem0
  49. // CHECK:STDOUT: %C.as.Inc.impl.Op.call: init %empty_tuple.type = call %bound_method.loc28(%c.ref)
  50. // CHECK:STDOUT: <elided>
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT: