forward_declared.carbon 3.0 KB

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