forward_declared.carbon 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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: %.1: type = ptr_type %Class [template]
  17. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  18. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  19. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  20. // CHECK:STDOUT: }
  21. // CHECK:STDOUT:
  22. // CHECK:STDOUT: imports {
  23. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  24. // CHECK:STDOUT: import Core//prelude
  25. // CHECK:STDOUT: import Core//prelude/...
  26. // CHECK:STDOUT: }
  27. // CHECK:STDOUT: }
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: file {
  30. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  31. // CHECK:STDOUT: .Core = imports.%Core
  32. // CHECK:STDOUT: .Class = %Class.decl
  33. // CHECK:STDOUT: .F = %F.decl
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT: %Core.import = import Core
  36. // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} {}
  37. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  38. // CHECK:STDOUT: %p.patt: %.1 = binding_pattern p
  39. // CHECK:STDOUT: %p.param_patt: %.1 = value_param_pattern %p.patt, runtime_param0
  40. // CHECK:STDOUT: %return.patt: %.1 = return_slot_pattern
  41. // CHECK:STDOUT: %return.param_patt: %.1 = out_param_pattern %return.patt, runtime_param1
  42. // CHECK:STDOUT: } {
  43. // CHECK:STDOUT: %Class.ref.loc13_9: type = name_ref Class, file.%Class.decl [template = constants.%Class]
  44. // CHECK:STDOUT: %.loc13_14: type = ptr_type %Class [template = constants.%.1]
  45. // CHECK:STDOUT: %Class.ref.loc13_20: type = name_ref Class, file.%Class.decl [template = constants.%Class]
  46. // CHECK:STDOUT: %.loc13_25: type = ptr_type %Class [template = constants.%.1]
  47. // CHECK:STDOUT: %p.param: %.1 = value_param runtime_param0
  48. // CHECK:STDOUT: %p: %.1 = bind_name p, %p.param
  49. // CHECK:STDOUT: %return.param: ref %.1 = out_param runtime_param1
  50. // CHECK:STDOUT: %return: ref %.1 = return_slot %return.param
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT:
  54. // CHECK:STDOUT: class @Class;
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: fn @F(%p.param_patt: %.1) -> %.1 {
  57. // CHECK:STDOUT: !entry:
  58. // CHECK:STDOUT: %p.ref: %.1 = name_ref p, %p
  59. // CHECK:STDOUT: return %p.ref
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT: