import.carbon 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  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/function/definition/import.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/definition/import.carbon
  10. // ============================================================================
  11. // Setup files
  12. // ============================================================================
  13. // --- fns.carbon
  14. library "fns";
  15. fn A() {}
  16. fn B(b: i32) -> i32 { return b; }
  17. fn C(c: (i32,)) -> {.c: i32} { return {.c = c[0]}; }
  18. fn D();
  19. // --- extern.carbon
  20. library "extern";
  21. extern fn A();
  22. // ============================================================================
  23. // Test files
  24. // ============================================================================
  25. // --- basics.carbon
  26. library "basics";
  27. import library "fns";
  28. var a: () = A();
  29. var b: i32 = B(1);
  30. var c: {.c: i32} = C((1,));
  31. // --- fail_def_ownership.carbon
  32. library "def_ownership";
  33. import library "fns";
  34. // CHECK:STDERR: fail_def_ownership.carbon:[[@LINE+10]]:1: ERROR: Only one library can declare `fn A` without `extern`.
  35. // CHECK:STDERR: fn A() {};
  36. // CHECK:STDERR: ^~~~~~~~
  37. // CHECK:STDERR: fail_def_ownership.carbon:[[@LINE-5]]:1: In import.
  38. // CHECK:STDERR: import library "fns";
  39. // CHECK:STDERR: ^~~~~~
  40. // CHECK:STDERR: fns.carbon:4:1: Previously declared here.
  41. // CHECK:STDERR: fn A() {}
  42. // CHECK:STDERR: ^~~~~~~~
  43. // CHECK:STDERR:
  44. fn A() {};
  45. // CHECK:STDERR: fail_def_ownership.carbon:[[@LINE+10]]:1: ERROR: Only one library can declare `fn B` without `extern`.
  46. // CHECK:STDERR: fn B(b: i32) -> i32;
  47. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
  48. // CHECK:STDERR: fail_def_ownership.carbon:[[@LINE-16]]:1: In import.
  49. // CHECK:STDERR: import library "fns";
  50. // CHECK:STDERR: ^~~~~~
  51. // CHECK:STDERR: fns.carbon:5:1: Previously declared here.
  52. // CHECK:STDERR: fn B(b: i32) -> i32 { return b; }
  53. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~
  54. // CHECK:STDERR:
  55. fn B(b: i32) -> i32;
  56. // --- redecl_then_def.carbon
  57. library "redecl_then_def";
  58. import library "extern";
  59. fn A();
  60. fn A() {}
  61. // --- fail_mix_extern_decl.carbon
  62. library "mix_extern_decl";
  63. import library "fns";
  64. extern fn D();
  65. // CHECK:STDERR: fail_mix_extern_decl.carbon:[[@LINE+6]]:1: ERROR: Redeclarations of `fn D` in the same library must match use of `extern`.
  66. // CHECK:STDERR: fn D() {}
  67. // CHECK:STDERR: ^~~~~~~~
  68. // CHECK:STDERR: fail_mix_extern_decl.carbon:[[@LINE-4]]:1: Previously declared here.
  69. // CHECK:STDERR: extern fn D();
  70. // CHECK:STDERR: ^~~~~~~~~~~~~~
  71. fn D() {}
  72. // CHECK:STDOUT: --- fns.carbon
  73. // CHECK:STDOUT:
  74. // CHECK:STDOUT: constants {
  75. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  76. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  77. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  78. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  79. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  80. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  81. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  82. // CHECK:STDOUT: %.2: type = tuple_type (type) [template]
  83. // CHECK:STDOUT: %.3: type = tuple_type (i32) [template]
  84. // CHECK:STDOUT: %.4: type = struct_type {.c: i32} [template]
  85. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  86. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  87. // CHECK:STDOUT: %.5: i32 = int_literal 0 [template]
  88. // CHECK:STDOUT: %D.type: type = fn_type @D [template]
  89. // CHECK:STDOUT: %D: %D.type = struct_value () [template]
  90. // CHECK:STDOUT: }
  91. // CHECK:STDOUT:
  92. // CHECK:STDOUT: file {
  93. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  94. // CHECK:STDOUT: .Core = %Core
  95. // CHECK:STDOUT: .A = %A.decl
  96. // CHECK:STDOUT: .B = %B.decl
  97. // CHECK:STDOUT: .C = %C.decl
  98. // CHECK:STDOUT: .D = %D.decl
  99. // CHECK:STDOUT: }
  100. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  101. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {}
  102. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  103. // CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  104. // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] {
  105. // CHECK:STDOUT: %int.make_type_32.loc5_9: init type = call constants.%Int32() [template = i32]
  106. // CHECK:STDOUT: %.loc5_9.1: type = value_of_initializer %int.make_type_32.loc5_9 [template = i32]
  107. // CHECK:STDOUT: %.loc5_9.2: type = converted %int.make_type_32.loc5_9, %.loc5_9.1 [template = i32]
  108. // CHECK:STDOUT: %b.loc5_6.1: i32 = param b
  109. // CHECK:STDOUT: @B.%b: i32 = bind_name b, %b.loc5_6.1
  110. // CHECK:STDOUT: %int.make_type_32.loc5_17: init type = call constants.%Int32() [template = i32]
  111. // CHECK:STDOUT: %.loc5_17.1: type = value_of_initializer %int.make_type_32.loc5_17 [template = i32]
  112. // CHECK:STDOUT: %.loc5_17.2: type = converted %int.make_type_32.loc5_17, %.loc5_17.1 [template = i32]
  113. // CHECK:STDOUT: @B.%return: ref i32 = var <return slot>
  114. // CHECK:STDOUT: }
  115. // CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  116. // CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  117. // CHECK:STDOUT: %C.decl: %C.type = fn_decl @C [template = constants.%C] {
  118. // CHECK:STDOUT: %int.make_type_32.loc6_10: init type = call constants.%Int32() [template = i32]
  119. // CHECK:STDOUT: %.loc6_14.1: %.2 = tuple_literal (%int.make_type_32.loc6_10)
  120. // CHECK:STDOUT: %.loc6_14.2: type = value_of_initializer %int.make_type_32.loc6_10 [template = i32]
  121. // CHECK:STDOUT: %.loc6_14.3: type = converted %int.make_type_32.loc6_10, %.loc6_14.2 [template = i32]
  122. // CHECK:STDOUT: %.loc6_14.4: type = converted %.loc6_14.1, constants.%.3 [template = constants.%.3]
  123. // CHECK:STDOUT: %c.loc6_6.1: %.3 = param c
  124. // CHECK:STDOUT: @C.%c: %.3 = bind_name c, %c.loc6_6.1
  125. // CHECK:STDOUT: %int.make_type_32.loc6_25: init type = call constants.%Int32() [template = i32]
  126. // CHECK:STDOUT: %.loc6_25.1: type = value_of_initializer %int.make_type_32.loc6_25 [template = i32]
  127. // CHECK:STDOUT: %.loc6_25.2: type = converted %int.make_type_32.loc6_25, %.loc6_25.1 [template = i32]
  128. // CHECK:STDOUT: %.loc6_28: type = struct_type {.c: i32} [template = constants.%.4]
  129. // CHECK:STDOUT: @C.%return: ref %.4 = var <return slot>
  130. // CHECK:STDOUT: }
  131. // CHECK:STDOUT: %D.decl: %D.type = fn_decl @D [template = constants.%D] {}
  132. // CHECK:STDOUT: }
  133. // CHECK:STDOUT:
  134. // CHECK:STDOUT: fn @A() {
  135. // CHECK:STDOUT: !entry:
  136. // CHECK:STDOUT: return
  137. // CHECK:STDOUT: }
  138. // CHECK:STDOUT:
  139. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  140. // CHECK:STDOUT:
  141. // CHECK:STDOUT: fn @B(%b: i32) -> i32 {
  142. // CHECK:STDOUT: !entry:
  143. // CHECK:STDOUT: %b.ref: i32 = name_ref b, %b
  144. // CHECK:STDOUT: return %b.ref
  145. // CHECK:STDOUT: }
  146. // CHECK:STDOUT:
  147. // CHECK:STDOUT: fn @C(%c: %.3) -> %.4 {
  148. // CHECK:STDOUT: !entry:
  149. // CHECK:STDOUT: %c.ref: %.3 = name_ref c, %c
  150. // CHECK:STDOUT: %.loc6_47: i32 = int_literal 0 [template = constants.%.5]
  151. // CHECK:STDOUT: %.loc6_48: i32 = tuple_index %c.ref, %.loc6_47
  152. // CHECK:STDOUT: %.loc6_49: %.4 = struct_literal (%.loc6_48)
  153. // CHECK:STDOUT: %struct: %.4 = struct_value (%.loc6_48)
  154. // CHECK:STDOUT: %.loc6_50: %.4 = converted %.loc6_49, %struct
  155. // CHECK:STDOUT: return %.loc6_50
  156. // CHECK:STDOUT: }
  157. // CHECK:STDOUT:
  158. // CHECK:STDOUT: fn @D();
  159. // CHECK:STDOUT:
  160. // CHECK:STDOUT: --- extern.carbon
  161. // CHECK:STDOUT:
  162. // CHECK:STDOUT: constants {
  163. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  164. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  165. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  166. // CHECK:STDOUT: }
  167. // CHECK:STDOUT:
  168. // CHECK:STDOUT: file {
  169. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  170. // CHECK:STDOUT: .Core = %Core
  171. // CHECK:STDOUT: .A = %A.decl
  172. // CHECK:STDOUT: }
  173. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  174. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {}
  175. // CHECK:STDOUT: }
  176. // CHECK:STDOUT:
  177. // CHECK:STDOUT: extern fn @A();
  178. // CHECK:STDOUT:
  179. // CHECK:STDOUT: --- basics.carbon
  180. // CHECK:STDOUT:
  181. // CHECK:STDOUT: constants {
  182. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  183. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  184. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  185. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  186. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  187. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  188. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  189. // CHECK:STDOUT: %.2: i32 = int_literal 1 [template]
  190. // CHECK:STDOUT: %.3: type = struct_type {.c: i32} [template]
  191. // CHECK:STDOUT: %.4: type = tuple_type (i32) [template]
  192. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  193. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  194. // CHECK:STDOUT: %tuple: %.4 = tuple_value (%.2) [template]
  195. // CHECK:STDOUT: }
  196. // CHECK:STDOUT:
  197. // CHECK:STDOUT: file {
  198. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  199. // CHECK:STDOUT: .A = %import_ref.1
  200. // CHECK:STDOUT: .B = %import_ref.2
  201. // CHECK:STDOUT: .C = %import_ref.3
  202. // CHECK:STDOUT: .D = %import_ref.4
  203. // CHECK:STDOUT: .Core = %Core
  204. // CHECK:STDOUT: .a = %a
  205. // CHECK:STDOUT: .b = %b
  206. // CHECK:STDOUT: .c = %c
  207. // CHECK:STDOUT: }
  208. // CHECK:STDOUT: %import_ref.1: %A.type = import_ref ir1, inst+2, loaded [template = constants.%A]
  209. // CHECK:STDOUT: %import_ref.2: %B.type = import_ref ir1, inst+22, loaded [template = constants.%B]
  210. // CHECK:STDOUT: %import_ref.3: %C.type = import_ref ir1, inst+46, loaded [template = constants.%C]
  211. // CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+58, unloaded
  212. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  213. // CHECK:STDOUT: %.loc6_9.1: %.1 = tuple_literal ()
  214. // CHECK:STDOUT: %.loc6_9.2: type = converted %.loc6_9.1, constants.%.1 [template = constants.%.1]
  215. // CHECK:STDOUT: %a.var: ref %.1 = var a
  216. // CHECK:STDOUT: %a: ref %.1 = bind_name a, %a.var
  217. // CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir4, inst+3, loaded [template = constants.%Int32]
  218. // CHECK:STDOUT: %int.make_type_32.loc7: init type = call constants.%Int32() [template = i32]
  219. // CHECK:STDOUT: %.loc7_8.1: type = value_of_initializer %int.make_type_32.loc7 [template = i32]
  220. // CHECK:STDOUT: %.loc7_8.2: type = converted %int.make_type_32.loc7, %.loc7_8.1 [template = i32]
  221. // CHECK:STDOUT: %b.var: ref i32 = var b
  222. // CHECK:STDOUT: %b: ref i32 = bind_name b, %b.var
  223. // CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir4, inst+3, loaded [template = constants.%Int32]
  224. // CHECK:STDOUT: %int.make_type_32.loc8: init type = call constants.%Int32() [template = i32]
  225. // CHECK:STDOUT: %.loc8_13.1: type = value_of_initializer %int.make_type_32.loc8 [template = i32]
  226. // CHECK:STDOUT: %.loc8_13.2: type = converted %int.make_type_32.loc8, %.loc8_13.1 [template = i32]
  227. // CHECK:STDOUT: %.loc8_16: type = struct_type {.c: i32} [template = constants.%.3]
  228. // CHECK:STDOUT: %c.var: ref %.3 = var c
  229. // CHECK:STDOUT: %c: ref %.3 = bind_name c, %c.var
  230. // CHECK:STDOUT: }
  231. // CHECK:STDOUT:
  232. // CHECK:STDOUT: fn @A();
  233. // CHECK:STDOUT:
  234. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  235. // CHECK:STDOUT:
  236. // CHECK:STDOUT: fn @B(%b: i32) -> i32;
  237. // CHECK:STDOUT:
  238. // CHECK:STDOUT: fn @C(%c: %.4) -> %.3;
  239. // CHECK:STDOUT:
  240. // CHECK:STDOUT: fn @__global_init() {
  241. // CHECK:STDOUT: !entry:
  242. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, file.%import_ref.1 [template = constants.%A]
  243. // CHECK:STDOUT: %A.call: init %.1 = call %A.ref()
  244. // CHECK:STDOUT: assign file.%a.var, %A.call
  245. // CHECK:STDOUT: %B.ref: %B.type = name_ref B, file.%import_ref.2 [template = constants.%B]
  246. // CHECK:STDOUT: %.loc7: i32 = int_literal 1 [template = constants.%.2]
  247. // CHECK:STDOUT: %B.call: init i32 = call %B.ref(%.loc7)
  248. // CHECK:STDOUT: assign file.%b.var, %B.call
  249. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, file.%import_ref.3 [template = constants.%C]
  250. // CHECK:STDOUT: %.loc8_23: i32 = int_literal 1 [template = constants.%.2]
  251. // CHECK:STDOUT: %.loc8_25: %.4 = tuple_literal (%.loc8_23)
  252. // CHECK:STDOUT: %tuple: %.4 = tuple_value (%.loc8_23) [template = constants.%tuple]
  253. // CHECK:STDOUT: %.loc8_21: %.4 = converted %.loc8_25, %tuple [template = constants.%tuple]
  254. // CHECK:STDOUT: %C.call: init %.3 = call %C.ref(%.loc8_21)
  255. // CHECK:STDOUT: assign file.%c.var, %C.call
  256. // CHECK:STDOUT: return
  257. // CHECK:STDOUT: }
  258. // CHECK:STDOUT:
  259. // CHECK:STDOUT: --- fail_def_ownership.carbon
  260. // CHECK:STDOUT:
  261. // CHECK:STDOUT: constants {
  262. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  263. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  264. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  265. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  266. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  267. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  268. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  269. // CHECK:STDOUT: }
  270. // CHECK:STDOUT:
  271. // CHECK:STDOUT: file {
  272. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  273. // CHECK:STDOUT: .A = %A.decl
  274. // CHECK:STDOUT: .B = %B.decl
  275. // CHECK:STDOUT: .C = %import_ref.3
  276. // CHECK:STDOUT: .D = %import_ref.4
  277. // CHECK:STDOUT: .Core = %Core
  278. // CHECK:STDOUT: }
  279. // CHECK:STDOUT: %import_ref.1: %A.type = import_ref ir1, inst+2, loaded [template = constants.%A]
  280. // CHECK:STDOUT: %import_ref.2: %B.type = import_ref ir1, inst+22, loaded [template = constants.%B]
  281. // CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+46, unloaded
  282. // CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+58, unloaded
  283. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  284. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {}
  285. // CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref ir4, inst+3, loaded [template = constants.%Int32]
  286. // CHECK:STDOUT: %import_ref.6: %Int32.type = import_ref ir4, inst+3, loaded [template = constants.%Int32]
  287. // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] {
  288. // CHECK:STDOUT: %int.make_type_32.loc27_9: init type = call constants.%Int32() [template = i32]
  289. // CHECK:STDOUT: %.loc27_9.1: type = value_of_initializer %int.make_type_32.loc27_9 [template = i32]
  290. // CHECK:STDOUT: %.loc27_9.2: type = converted %int.make_type_32.loc27_9, %.loc27_9.1 [template = i32]
  291. // CHECK:STDOUT: %b.loc27_6.1: i32 = param b
  292. // CHECK:STDOUT: %b.loc27_6.2: i32 = bind_name b, %b.loc27_6.1
  293. // CHECK:STDOUT: %int.make_type_32.loc27_17: init type = call constants.%Int32() [template = i32]
  294. // CHECK:STDOUT: %.loc27_17.1: type = value_of_initializer %int.make_type_32.loc27_17 [template = i32]
  295. // CHECK:STDOUT: %.loc27_17.2: type = converted %int.make_type_32.loc27_17, %.loc27_17.1 [template = i32]
  296. // CHECK:STDOUT: %return.var: ref i32 = var <return slot>
  297. // CHECK:STDOUT: }
  298. // CHECK:STDOUT: }
  299. // CHECK:STDOUT:
  300. // CHECK:STDOUT: fn @A() {
  301. // CHECK:STDOUT: !entry:
  302. // CHECK:STDOUT: return
  303. // CHECK:STDOUT: }
  304. // CHECK:STDOUT:
  305. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  306. // CHECK:STDOUT:
  307. // CHECK:STDOUT: fn @B(%b: i32) -> i32;
  308. // CHECK:STDOUT:
  309. // CHECK:STDOUT: --- redecl_then_def.carbon
  310. // CHECK:STDOUT:
  311. // CHECK:STDOUT: constants {
  312. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  313. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  314. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  315. // CHECK:STDOUT: }
  316. // CHECK:STDOUT:
  317. // CHECK:STDOUT: file {
  318. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  319. // CHECK:STDOUT: .A = %A.decl.loc6
  320. // CHECK:STDOUT: .Core = %Core
  321. // CHECK:STDOUT: }
  322. // CHECK:STDOUT: %import_ref: %A.type = import_ref ir1, inst+2, loaded [template = constants.%A]
  323. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  324. // CHECK:STDOUT: %A.decl.loc6: %A.type = fn_decl @A [template = constants.%A] {}
  325. // CHECK:STDOUT: %A.decl.loc7: %A.type = fn_decl @A [template = constants.%A] {}
  326. // CHECK:STDOUT: }
  327. // CHECK:STDOUT:
  328. // CHECK:STDOUT: fn @A() {
  329. // CHECK:STDOUT: !entry:
  330. // CHECK:STDOUT: return
  331. // CHECK:STDOUT: }
  332. // CHECK:STDOUT:
  333. // CHECK:STDOUT: --- fail_mix_extern_decl.carbon
  334. // CHECK:STDOUT:
  335. // CHECK:STDOUT: constants {
  336. // CHECK:STDOUT: %D.type: type = fn_type @D [template]
  337. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  338. // CHECK:STDOUT: %D: %D.type = struct_value () [template]
  339. // CHECK:STDOUT: }
  340. // CHECK:STDOUT:
  341. // CHECK:STDOUT: file {
  342. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  343. // CHECK:STDOUT: .A = %import_ref.1
  344. // CHECK:STDOUT: .B = %import_ref.2
  345. // CHECK:STDOUT: .C = %import_ref.3
  346. // CHECK:STDOUT: .D = %D.decl.loc13
  347. // CHECK:STDOUT: .Core = %Core
  348. // CHECK:STDOUT: }
  349. // CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+2, unloaded
  350. // CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+22, unloaded
  351. // CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+46, unloaded
  352. // CHECK:STDOUT: %import_ref.4: %D.type = import_ref ir1, inst+58, loaded [template = constants.%D]
  353. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  354. // CHECK:STDOUT: %D.decl.loc6: %D.type = fn_decl @D [template = constants.%D] {}
  355. // CHECK:STDOUT: %D.decl.loc13: %D.type = fn_decl @D [template = constants.%D] {}
  356. // CHECK:STDOUT: }
  357. // CHECK:STDOUT:
  358. // CHECK:STDOUT: fn @D() {
  359. // CHECK:STDOUT: !entry:
  360. // CHECK:STDOUT: return
  361. // CHECK:STDOUT: }
  362. // CHECK:STDOUT: