forward_declared.carbon 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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/operators
  26. // CHECK:STDOUT: import Core//prelude/types
  27. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  28. // CHECK:STDOUT: import Core//prelude/operators/as
  29. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  30. // CHECK:STDOUT: import Core//prelude/operators/comparison
  31. // CHECK:STDOUT: import Core//prelude/types/bool
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: file {
  36. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  37. // CHECK:STDOUT: .Core = imports.%Core
  38. // CHECK:STDOUT: .Class = %Class.decl
  39. // CHECK:STDOUT: .F = %F.decl
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT: %Core.import = import Core
  42. // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} {}
  43. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  44. // CHECK:STDOUT: %p.patt: %.1 = binding_pattern p
  45. // CHECK:STDOUT: %p.param_patt: %.1 = param_pattern %p.patt, runtime_param0
  46. // CHECK:STDOUT: } {
  47. // CHECK:STDOUT: %Class.ref.loc13_9: type = name_ref Class, file.%Class.decl [template = constants.%Class]
  48. // CHECK:STDOUT: %.loc13_14: type = ptr_type %Class [template = constants.%.1]
  49. // CHECK:STDOUT: %Class.ref.loc13_20: type = name_ref Class, file.%Class.decl [template = constants.%Class]
  50. // CHECK:STDOUT: %.loc13_25: type = ptr_type %Class [template = constants.%.1]
  51. // CHECK:STDOUT: %return: ref %.1 = var <return slot>
  52. // CHECK:STDOUT: %param: %.1 = param runtime_param0
  53. // CHECK:STDOUT: %p: %.1 = bind_name p, %param
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT:
  57. // CHECK:STDOUT: class @Class;
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: fn @F(%p.param_patt: %.1) -> %.1 {
  60. // CHECK:STDOUT: !entry:
  61. // CHECK:STDOUT: %p.ref: %.1 = name_ref p, %p
  62. // CHECK:STDOUT: return %p.ref
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT: