forward_declared.carbon 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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/convert.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/class/forward_declared.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/forward_declared.carbon
  14. class Class;
  15. fn F(p: Class*) -> Class* { return p; }
  16. // CHECK:STDOUT: --- forward_declared.carbon
  17. // CHECK:STDOUT:
  18. // CHECK:STDOUT: constants {
  19. // CHECK:STDOUT: %Class: type = class_type @Class [concrete]
  20. // CHECK:STDOUT: %ptr: type = ptr_type %Class [concrete]
  21. // CHECK:STDOUT: %pattern_type: type = pattern_type %ptr [concrete]
  22. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  23. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  24. // CHECK:STDOUT: }
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: imports {
  27. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  28. // CHECK:STDOUT: import Core//prelude
  29. // CHECK:STDOUT: import Core//prelude/...
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: file {
  34. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  35. // CHECK:STDOUT: .Core = imports.%Core
  36. // CHECK:STDOUT: .Class = %Class.decl
  37. // CHECK:STDOUT: .F = %F.decl
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT: %Core.import = import Core
  40. // CHECK:STDOUT: %Class.decl: type = class_decl @Class [concrete = constants.%Class] {} {}
  41. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  42. // CHECK:STDOUT: %p.patt: %pattern_type = binding_pattern p [concrete]
  43. // CHECK:STDOUT: %p.param_patt: %pattern_type = value_param_pattern %p.patt, call_param0 [concrete]
  44. // CHECK:STDOUT: %return.patt: %pattern_type = return_slot_pattern [concrete]
  45. // CHECK:STDOUT: %return.param_patt: %pattern_type = out_param_pattern %return.patt, call_param1 [concrete]
  46. // CHECK:STDOUT: } {
  47. // CHECK:STDOUT: %Class.ref.loc17_20: type = name_ref Class, file.%Class.decl [concrete = constants.%Class]
  48. // CHECK:STDOUT: %ptr.loc17_25: type = ptr_type %Class.ref.loc17_20 [concrete = constants.%ptr]
  49. // CHECK:STDOUT: %p.param: %ptr = value_param call_param0
  50. // CHECK:STDOUT: %.loc17: type = splice_block %ptr.loc17_14 [concrete = constants.%ptr] {
  51. // CHECK:STDOUT: %Class.ref.loc17_9: type = name_ref Class, file.%Class.decl [concrete = constants.%Class]
  52. // CHECK:STDOUT: %ptr.loc17_14: type = ptr_type %Class.ref.loc17_9 [concrete = constants.%ptr]
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT: %p: %ptr = bind_name p, %p.param
  55. // CHECK:STDOUT: %return.param: ref %ptr = out_param call_param1
  56. // CHECK:STDOUT: %return: ref %ptr = return_slot %return.param
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: class @Class;
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: fn @F(%p.param: %ptr) -> %ptr {
  63. // CHECK:STDOUT: !entry:
  64. // CHECK:STDOUT: %p.ref: %ptr = name_ref p, %p
  65. // CHECK:STDOUT: return %p.ref
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT: