forward_declared.carbon 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 [concrete]
  16. // CHECK:STDOUT: %ptr: type = ptr_type %Class [concrete]
  17. // CHECK:STDOUT: %pattern_type: type = pattern_type %ptr [concrete]
  18. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  19. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  20. // CHECK:STDOUT: }
  21. // CHECK:STDOUT:
  22. // CHECK:STDOUT: imports {
  23. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  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 [concrete] {
  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 [concrete = constants.%Class] {} {}
  37. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  38. // CHECK:STDOUT: %p.patt: %pattern_type = binding_pattern p [concrete]
  39. // CHECK:STDOUT: %p.param_patt: %pattern_type = value_param_pattern %p.patt, call_param0 [concrete]
  40. // CHECK:STDOUT: %return.patt: %pattern_type = return_slot_pattern [concrete]
  41. // CHECK:STDOUT: %return.param_patt: %pattern_type = out_param_pattern %return.patt, call_param1 [concrete]
  42. // CHECK:STDOUT: } {
  43. // CHECK:STDOUT: %Class.ref.loc13_20: type = name_ref Class, file.%Class.decl [concrete = constants.%Class]
  44. // CHECK:STDOUT: %ptr.loc13_25: type = ptr_type %Class.ref.loc13_20 [concrete = constants.%ptr]
  45. // CHECK:STDOUT: %p.param: %ptr = value_param call_param0
  46. // CHECK:STDOUT: %.loc13: type = splice_block %ptr.loc13_14 [concrete = constants.%ptr] {
  47. // CHECK:STDOUT: %Class.ref.loc13_9: type = name_ref Class, file.%Class.decl [concrete = constants.%Class]
  48. // CHECK:STDOUT: %ptr.loc13_14: type = ptr_type %Class.ref.loc13_9 [concrete = constants.%ptr]
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT: %p: %ptr = bind_name p, %p.param
  51. // CHECK:STDOUT: %return.param: ref %ptr = out_param call_param1
  52. // CHECK:STDOUT: %return: ref %ptr = return_slot %return.param
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: class @Class;
  57. // CHECK:STDOUT:
  58. // CHECK:STDOUT: fn @F(%p.param: %ptr) -> %ptr {
  59. // CHECK:STDOUT: !entry:
  60. // CHECK:STDOUT: %p.ref: %ptr = name_ref p, %p
  61. // CHECK:STDOUT: return %p.ref
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT: