unqualified_lookup.carbon 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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/unqualified_lookup.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/namespace/unqualified_lookup.carbon
  10. namespace OuterN;
  11. namespace OuterN.InnerN;
  12. fn A();
  13. fn OuterN.B();
  14. fn OuterN.InnerN.C();
  15. fn CallA() {
  16. A();
  17. }
  18. fn OuterN.CallAB() {
  19. A();
  20. B();
  21. }
  22. fn OuterN.InnerN.CallABC() {
  23. A();
  24. B();
  25. C();
  26. }
  27. // CHECK:STDOUT: --- unqualified_lookup.carbon
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: constants {
  30. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  31. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  32. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  33. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  34. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  35. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  36. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  37. // CHECK:STDOUT: %CallA.type: type = fn_type @CallA [template]
  38. // CHECK:STDOUT: %CallA: %CallA.type = struct_value () [template]
  39. // CHECK:STDOUT: %CallAB.type: type = fn_type @CallAB [template]
  40. // CHECK:STDOUT: %CallAB: %CallAB.type = struct_value () [template]
  41. // CHECK:STDOUT: %CallABC.type: type = fn_type @CallABC [template]
  42. // CHECK:STDOUT: %CallABC: %CallABC.type = struct_value () [template]
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT:
  45. // CHECK:STDOUT: imports {
  46. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  47. // CHECK:STDOUT: import Core//prelude
  48. // CHECK:STDOUT: import Core//prelude/...
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: file {
  53. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  54. // CHECK:STDOUT: .Core = imports.%Core
  55. // CHECK:STDOUT: .OuterN = %OuterN
  56. // CHECK:STDOUT: .A = %A.decl
  57. // CHECK:STDOUT: .CallA = %CallA.decl
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT: %Core.import = import Core
  60. // CHECK:STDOUT: %OuterN: <namespace> = namespace [template] {
  61. // CHECK:STDOUT: .InnerN = %InnerN
  62. // CHECK:STDOUT: .B = %B.decl
  63. // CHECK:STDOUT: .CallAB = %CallAB.decl
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT: %InnerN: <namespace> = namespace [template] {
  66. // CHECK:STDOUT: .C = %C.decl
  67. // CHECK:STDOUT: .CallABC = %CallABC.decl
  68. // CHECK:STDOUT: }
  69. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} {}
  70. // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] {} {}
  71. // CHECK:STDOUT: %C.decl: %C.type = fn_decl @C [template = constants.%C] {} {}
  72. // CHECK:STDOUT: %CallA.decl: %CallA.type = fn_decl @CallA [template = constants.%CallA] {} {}
  73. // CHECK:STDOUT: %CallAB.decl: %CallAB.type = fn_decl @CallAB [template = constants.%CallAB] {} {}
  74. // CHECK:STDOUT: %CallABC.decl: %CallABC.type = fn_decl @CallABC [template = constants.%CallABC] {} {}
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT:
  77. // CHECK:STDOUT: fn @A();
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: fn @B();
  80. // CHECK:STDOUT:
  81. // CHECK:STDOUT: fn @C();
  82. // CHECK:STDOUT:
  83. // CHECK:STDOUT: fn @CallA() {
  84. // CHECK:STDOUT: !entry:
  85. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, file.%A.decl [template = constants.%A]
  86. // CHECK:STDOUT: %A.call: init %empty_tuple.type = call %A.ref()
  87. // CHECK:STDOUT: return
  88. // CHECK:STDOUT: }
  89. // CHECK:STDOUT:
  90. // CHECK:STDOUT: fn @CallAB() {
  91. // CHECK:STDOUT: !entry:
  92. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, file.%A.decl [template = constants.%A]
  93. // CHECK:STDOUT: %A.call: init %empty_tuple.type = call %A.ref()
  94. // CHECK:STDOUT: %B.ref: %B.type = name_ref B, file.%B.decl [template = constants.%B]
  95. // CHECK:STDOUT: %B.call: init %empty_tuple.type = call %B.ref()
  96. // CHECK:STDOUT: return
  97. // CHECK:STDOUT: }
  98. // CHECK:STDOUT:
  99. // CHECK:STDOUT: fn @CallABC() {
  100. // CHECK:STDOUT: !entry:
  101. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, file.%A.decl [template = constants.%A]
  102. // CHECK:STDOUT: %A.call: init %empty_tuple.type = call %A.ref()
  103. // CHECK:STDOUT: %B.ref: %B.type = name_ref B, file.%B.decl [template = constants.%B]
  104. // CHECK:STDOUT: %B.call: init %empty_tuple.type = call %B.ref()
  105. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, file.%C.decl [template = constants.%C]
  106. // CHECK:STDOUT: %C.call: init %empty_tuple.type = call %C.ref()
  107. // CHECK:STDOUT: return
  108. // CHECK:STDOUT: }
  109. // CHECK:STDOUT: