unqualified_lookup.carbon 4.8 KB

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