function.carbon 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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/namespace/function.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/namespace/function.carbon
  10. namespace Foo;
  11. // Never called, just here to help catch bugs in name lookup.
  12. fn Baz() {
  13. }
  14. fn Foo.Baz() {
  15. }
  16. fn Bar() {
  17. Foo.Baz();
  18. }
  19. // CHECK:STDOUT: --- function.carbon
  20. // CHECK:STDOUT:
  21. // CHECK:STDOUT: constants {
  22. // CHECK:STDOUT: %Baz.type.1: type = fn_type @Baz.1 [template]
  23. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  24. // CHECK:STDOUT: %Baz.1: %Baz.type.1 = struct_value () [template]
  25. // CHECK:STDOUT: %Baz.type.2: type = fn_type @Baz.2 [template]
  26. // CHECK:STDOUT: %Baz.2: %Baz.type.2 = struct_value () [template]
  27. // CHECK:STDOUT: %Bar.type: type = fn_type @Bar [template]
  28. // CHECK:STDOUT: %Bar: %Bar.type = struct_value () [template]
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT:
  31. // CHECK:STDOUT: file {
  32. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  33. // CHECK:STDOUT: .Core = %Core
  34. // CHECK:STDOUT: .Foo = %Foo
  35. // CHECK:STDOUT: .Baz = %Baz.decl.loc14
  36. // CHECK:STDOUT: .Bar = %Bar.decl
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  39. // CHECK:STDOUT: %Foo: <namespace> = namespace [template] {
  40. // CHECK:STDOUT: .Baz = %Baz.decl.loc17
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT: %Baz.decl.loc14: %Baz.type.1 = fn_decl @Baz.1 [template = constants.%Baz.1] {}
  43. // CHECK:STDOUT: %Baz.decl.loc17: %Baz.type.2 = fn_decl @Baz.2 [template = constants.%Baz.2] {}
  44. // CHECK:STDOUT: %Bar.decl: %Bar.type = fn_decl @Bar [template = constants.%Bar] {}
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: fn @Baz.1() {
  48. // CHECK:STDOUT: !entry:
  49. // CHECK:STDOUT: return
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: fn @Baz.2() {
  53. // CHECK:STDOUT: !entry:
  54. // CHECK:STDOUT: return
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT:
  57. // CHECK:STDOUT: fn @Bar() {
  58. // CHECK:STDOUT: !entry:
  59. // CHECK:STDOUT: %Foo.ref: <namespace> = name_ref Foo, file.%Foo [template = file.%Foo]
  60. // CHECK:STDOUT: %Baz.ref: %Baz.type.2 = name_ref Baz, file.%Baz.decl.loc17 [template = constants.%Baz.2]
  61. // CHECK:STDOUT: %Baz.call: init %.1 = call %Baz.ref()
  62. // CHECK:STDOUT: return
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT: