virtual_modifiers.carbon 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  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/virtual_modifiers.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/virtual_modifiers.carbon
  10. // --- modifiers.carbon
  11. package Modifiers;
  12. base class Base {
  13. virtual fn H();
  14. }
  15. abstract class Abstract {
  16. abstract fn J();
  17. virtual fn K();
  18. }
  19. // --- todo_fail_later_base.carbon
  20. package FailLaterBase;
  21. import Modifiers;
  22. base class Derived {
  23. virtual fn F();
  24. extend base: Modifiers.Base;
  25. }
  26. // --- init.carbon
  27. package Init;
  28. import Modifiers;
  29. fn F() {
  30. var v: Modifiers.Base = {};
  31. }
  32. // --- impl_abstract.carbon
  33. package ImplAbstract;
  34. abstract class A1 {
  35. virtual fn F();
  36. }
  37. abstract class A2 {
  38. extend base: A1;
  39. impl fn F();
  40. }
  41. // --- impl_base.carbon
  42. package ImplBase;
  43. base class B1 {
  44. virtual fn F();
  45. }
  46. base class B2 {
  47. extend base: B1;
  48. impl fn F();
  49. }
  50. class C {
  51. extend base: B2;
  52. impl fn F();
  53. }
  54. // --- fail_modifiers.carbon
  55. package FailModifiers;
  56. class C {
  57. // CHECK:STDERR: fail_modifiers.carbon:[[@LINE+3]]:3: error: impl without base class [ImplWithoutBase]
  58. // CHECK:STDERR: impl fn F();
  59. // CHECK:STDERR: ^~~~~~~~~~~~
  60. impl fn F();
  61. }
  62. // --- init_members.carbon
  63. package InitMembers;
  64. base class Base {
  65. var m1: i32;
  66. var m2: i32;
  67. virtual fn F();
  68. }
  69. fn F() {
  70. var i: i32 = 3;
  71. // TODO: These should initialize element1 (.m), not element0 (the vptr)
  72. var b1: Base = {.m2 = i, .m1 = i};
  73. var b2: Base = {.m2 = 3, .m1 = 5};
  74. // This one is good, though.
  75. b1.m2 = 4;
  76. }
  77. // --- todo_fail_impl_without_base_declaration.carbon
  78. package ImplWithoutBaseDeclaration;
  79. base class Base {
  80. }
  81. class Derived {
  82. extend base: Base;
  83. impl fn F();
  84. }
  85. // CHECK:STDOUT: --- modifiers.carbon
  86. // CHECK:STDOUT:
  87. // CHECK:STDOUT: constants {
  88. // CHECK:STDOUT: %Base: type = class_type @Base [template]
  89. // CHECK:STDOUT: %H.type: type = fn_type @H [template]
  90. // CHECK:STDOUT: %H: %H.type = struct_value () [template]
  91. // CHECK:STDOUT: %ptr: type = ptr_type <vtable> [template]
  92. // CHECK:STDOUT: %struct_type.vptr: type = struct_type {.<vptr>: %ptr} [template]
  93. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template]
  94. // CHECK:STDOUT: %Abstract: type = class_type @Abstract [template]
  95. // CHECK:STDOUT: %J.type: type = fn_type @J [template]
  96. // CHECK:STDOUT: %J: %J.type = struct_value () [template]
  97. // CHECK:STDOUT: %K.type: type = fn_type @K [template]
  98. // CHECK:STDOUT: %K: %K.type = struct_value () [template]
  99. // CHECK:STDOUT: }
  100. // CHECK:STDOUT:
  101. // CHECK:STDOUT: imports {
  102. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  103. // CHECK:STDOUT: import Core//prelude
  104. // CHECK:STDOUT: import Core//prelude/...
  105. // CHECK:STDOUT: }
  106. // CHECK:STDOUT: }
  107. // CHECK:STDOUT:
  108. // CHECK:STDOUT: file {
  109. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  110. // CHECK:STDOUT: .Core = imports.%Core
  111. // CHECK:STDOUT: .Base = %Base.decl
  112. // CHECK:STDOUT: .Abstract = %Abstract.decl
  113. // CHECK:STDOUT: }
  114. // CHECK:STDOUT: %Core.import = import Core
  115. // CHECK:STDOUT: %Base.decl: type = class_decl @Base [template = constants.%Base] {} {}
  116. // CHECK:STDOUT: %Abstract.decl: type = class_decl @Abstract [template = constants.%Abstract] {} {}
  117. // CHECK:STDOUT: }
  118. // CHECK:STDOUT:
  119. // CHECK:STDOUT: class @Base {
  120. // CHECK:STDOUT: %H.decl: %H.type = fn_decl @H [template = constants.%H] {} {}
  121. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template = constants.%complete_type]
  122. // CHECK:STDOUT:
  123. // CHECK:STDOUT: !members:
  124. // CHECK:STDOUT: .Self = constants.%Base
  125. // CHECK:STDOUT: .H = %H.decl
  126. // CHECK:STDOUT: complete_type_witness = %complete_type
  127. // CHECK:STDOUT: }
  128. // CHECK:STDOUT:
  129. // CHECK:STDOUT: class @Abstract {
  130. // CHECK:STDOUT: %J.decl: %J.type = fn_decl @J [template = constants.%J] {} {}
  131. // CHECK:STDOUT: %K.decl: %K.type = fn_decl @K [template = constants.%K] {} {}
  132. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template = constants.%complete_type]
  133. // CHECK:STDOUT:
  134. // CHECK:STDOUT: !members:
  135. // CHECK:STDOUT: .Self = constants.%Abstract
  136. // CHECK:STDOUT: .J = %J.decl
  137. // CHECK:STDOUT: .K = %K.decl
  138. // CHECK:STDOUT: complete_type_witness = %complete_type
  139. // CHECK:STDOUT: }
  140. // CHECK:STDOUT:
  141. // CHECK:STDOUT: virtual fn @H();
  142. // CHECK:STDOUT:
  143. // CHECK:STDOUT: abstract fn @J();
  144. // CHECK:STDOUT:
  145. // CHECK:STDOUT: virtual fn @K();
  146. // CHECK:STDOUT:
  147. // CHECK:STDOUT: --- todo_fail_later_base.carbon
  148. // CHECK:STDOUT:
  149. // CHECK:STDOUT: constants {
  150. // CHECK:STDOUT: %Derived: type = class_type @Derived [template]
  151. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  152. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  153. // CHECK:STDOUT: %Base: type = class_type @Base [template]
  154. // CHECK:STDOUT: %ptr.1: type = ptr_type <vtable> [template]
  155. // CHECK:STDOUT: %struct_type.vptr: type = struct_type {.<vptr>: %ptr.1} [template]
  156. // CHECK:STDOUT: %complete_type.1: <witness> = complete_type_witness %struct_type.vptr [template]
  157. // CHECK:STDOUT: %Derived.elem: type = unbound_element_type %Derived, %Base [template]
  158. // CHECK:STDOUT: %struct_type.base: type = struct_type {.base: %Base} [template]
  159. // CHECK:STDOUT: %complete_type.2: <witness> = complete_type_witness %struct_type.base [template]
  160. // CHECK:STDOUT: }
  161. // CHECK:STDOUT:
  162. // CHECK:STDOUT: imports {
  163. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  164. // CHECK:STDOUT: import Core//prelude
  165. // CHECK:STDOUT: import Core//prelude/...
  166. // CHECK:STDOUT: }
  167. // CHECK:STDOUT: %Modifiers: <namespace> = namespace file.%Modifiers.import, [template] {
  168. // CHECK:STDOUT: .Base = %import_ref.1
  169. // CHECK:STDOUT: import Modifiers//default
  170. // CHECK:STDOUT: }
  171. // CHECK:STDOUT: %import_ref.1: type = import_ref Modifiers//default, inst+3, loaded [template = constants.%Base]
  172. // CHECK:STDOUT: %import_ref.2: <witness> = import_ref Modifiers//default, inst+11, loaded [template = constants.%complete_type.1]
  173. // CHECK:STDOUT: %import_ref.3 = import_ref Modifiers//default, inst+4, unloaded
  174. // CHECK:STDOUT: %import_ref.4 = import_ref Modifiers//default, inst+5, unloaded
  175. // CHECK:STDOUT: }
  176. // CHECK:STDOUT:
  177. // CHECK:STDOUT: file {
  178. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  179. // CHECK:STDOUT: .Core = imports.%Core
  180. // CHECK:STDOUT: .Modifiers = imports.%Modifiers
  181. // CHECK:STDOUT: .Derived = %Derived.decl
  182. // CHECK:STDOUT: }
  183. // CHECK:STDOUT: %Core.import = import Core
  184. // CHECK:STDOUT: %Modifiers.import = import Modifiers
  185. // CHECK:STDOUT: %Derived.decl: type = class_decl @Derived [template = constants.%Derived] {} {}
  186. // CHECK:STDOUT: }
  187. // CHECK:STDOUT:
  188. // CHECK:STDOUT: class @Derived {
  189. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {}
  190. // CHECK:STDOUT: %Modifiers.ref: <namespace> = name_ref Modifiers, imports.%Modifiers [template = imports.%Modifiers]
  191. // CHECK:STDOUT: %Base.ref: type = name_ref Base, imports.%import_ref.1 [template = constants.%Base]
  192. // CHECK:STDOUT: %.loc8: %Derived.elem = base_decl %Base.ref, element0 [template]
  193. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.base [template = constants.%complete_type.2]
  194. // CHECK:STDOUT:
  195. // CHECK:STDOUT: !members:
  196. // CHECK:STDOUT: .Self = constants.%Derived
  197. // CHECK:STDOUT: .F = %F.decl
  198. // CHECK:STDOUT: .base = %.loc8
  199. // CHECK:STDOUT: extend %Base.ref
  200. // CHECK:STDOUT: complete_type_witness = %complete_type
  201. // CHECK:STDOUT: }
  202. // CHECK:STDOUT:
  203. // CHECK:STDOUT: class @Base [from "modifiers.carbon"] {
  204. // CHECK:STDOUT: !members:
  205. // CHECK:STDOUT: .Self = imports.%import_ref.3
  206. // CHECK:STDOUT: .H = imports.%import_ref.4
  207. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.2
  208. // CHECK:STDOUT: }
  209. // CHECK:STDOUT:
  210. // CHECK:STDOUT: virtual fn @F();
  211. // CHECK:STDOUT:
  212. // CHECK:STDOUT: --- init.carbon
  213. // CHECK:STDOUT:
  214. // CHECK:STDOUT: constants {
  215. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  216. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  217. // CHECK:STDOUT: %Base: type = class_type @Base [template]
  218. // CHECK:STDOUT: %ptr.1: type = ptr_type <vtable> [template]
  219. // CHECK:STDOUT: %struct_type.vptr: type = struct_type {.<vptr>: %ptr.1} [template]
  220. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template]
  221. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  222. // CHECK:STDOUT: }
  223. // CHECK:STDOUT:
  224. // CHECK:STDOUT: imports {
  225. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  226. // CHECK:STDOUT: import Core//prelude
  227. // CHECK:STDOUT: import Core//prelude/...
  228. // CHECK:STDOUT: }
  229. // CHECK:STDOUT: %Modifiers: <namespace> = namespace file.%Modifiers.import, [template] {
  230. // CHECK:STDOUT: .Base = %import_ref.1
  231. // CHECK:STDOUT: import Modifiers//default
  232. // CHECK:STDOUT: }
  233. // CHECK:STDOUT: %import_ref.1: type = import_ref Modifiers//default, inst+3, loaded [template = constants.%Base]
  234. // CHECK:STDOUT: %import_ref.2: <witness> = import_ref Modifiers//default, inst+11, loaded [template = constants.%complete_type]
  235. // CHECK:STDOUT: %import_ref.3 = import_ref Modifiers//default, inst+4, unloaded
  236. // CHECK:STDOUT: %import_ref.4 = import_ref Modifiers//default, inst+5, unloaded
  237. // CHECK:STDOUT: }
  238. // CHECK:STDOUT:
  239. // CHECK:STDOUT: file {
  240. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  241. // CHECK:STDOUT: .Core = imports.%Core
  242. // CHECK:STDOUT: .Modifiers = imports.%Modifiers
  243. // CHECK:STDOUT: .F = %F.decl
  244. // CHECK:STDOUT: }
  245. // CHECK:STDOUT: %Core.import = import Core
  246. // CHECK:STDOUT: %Modifiers.import = import Modifiers
  247. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {}
  248. // CHECK:STDOUT: }
  249. // CHECK:STDOUT:
  250. // CHECK:STDOUT: class @Base [from "modifiers.carbon"] {
  251. // CHECK:STDOUT: !members:
  252. // CHECK:STDOUT: .Self = imports.%import_ref.3
  253. // CHECK:STDOUT: .H = imports.%import_ref.4
  254. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.2
  255. // CHECK:STDOUT: }
  256. // CHECK:STDOUT:
  257. // CHECK:STDOUT: fn @F() {
  258. // CHECK:STDOUT: !entry:
  259. // CHECK:STDOUT: %Modifiers.ref: <namespace> = name_ref Modifiers, imports.%Modifiers [template = imports.%Modifiers]
  260. // CHECK:STDOUT: %Base.ref: type = name_ref Base, imports.%import_ref.1 [template = constants.%Base]
  261. // CHECK:STDOUT: %v.var: ref %Base = var v
  262. // CHECK:STDOUT: %v: ref %Base = bind_name v, %v.var
  263. // CHECK:STDOUT: %.loc7_28.1: %empty_struct_type = struct_literal ()
  264. // CHECK:STDOUT: %.loc7_28.2: ref %ptr.1 = class_element_access %v.var, element0
  265. // CHECK:STDOUT: %.loc7_28.3: ref %ptr.1 = vtable_ptr
  266. // CHECK:STDOUT: %.loc7_28.4: init %ptr.1 = initialize_from %.loc7_28.3 to %.loc7_28.2
  267. // CHECK:STDOUT: %.loc7_28.5: init %Base = class_init (%.loc7_28.4), %v.var
  268. // CHECK:STDOUT: %.loc7_29: init %Base = converted %.loc7_28.1, %.loc7_28.5
  269. // CHECK:STDOUT: assign %v.var, %.loc7_29
  270. // CHECK:STDOUT: return
  271. // CHECK:STDOUT: }
  272. // CHECK:STDOUT:
  273. // CHECK:STDOUT: --- impl_abstract.carbon
  274. // CHECK:STDOUT:
  275. // CHECK:STDOUT: constants {
  276. // CHECK:STDOUT: %A1: type = class_type @A1 [template]
  277. // CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template]
  278. // CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [template]
  279. // CHECK:STDOUT: %ptr.1: type = ptr_type <vtable> [template]
  280. // CHECK:STDOUT: %struct_type.vptr: type = struct_type {.<vptr>: %ptr.1} [template]
  281. // CHECK:STDOUT: %complete_type.1: <witness> = complete_type_witness %struct_type.vptr [template]
  282. // CHECK:STDOUT: %A2: type = class_type @A2 [template]
  283. // CHECK:STDOUT: %A2.elem: type = unbound_element_type %A2, %A1 [template]
  284. // CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template]
  285. // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template]
  286. // CHECK:STDOUT: %struct_type.base: type = struct_type {.base: %A1} [template]
  287. // CHECK:STDOUT: %complete_type.2: <witness> = complete_type_witness %struct_type.base [template]
  288. // CHECK:STDOUT: }
  289. // CHECK:STDOUT:
  290. // CHECK:STDOUT: imports {
  291. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  292. // CHECK:STDOUT: import Core//prelude
  293. // CHECK:STDOUT: import Core//prelude/...
  294. // CHECK:STDOUT: }
  295. // CHECK:STDOUT: }
  296. // CHECK:STDOUT:
  297. // CHECK:STDOUT: file {
  298. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  299. // CHECK:STDOUT: .Core = imports.%Core
  300. // CHECK:STDOUT: .A1 = %A1.decl
  301. // CHECK:STDOUT: .A2 = %A2.decl
  302. // CHECK:STDOUT: }
  303. // CHECK:STDOUT: %Core.import = import Core
  304. // CHECK:STDOUT: %A1.decl: type = class_decl @A1 [template = constants.%A1] {} {}
  305. // CHECK:STDOUT: %A2.decl: type = class_decl @A2 [template = constants.%A2] {} {}
  306. // CHECK:STDOUT: }
  307. // CHECK:STDOUT:
  308. // CHECK:STDOUT: class @A1 {
  309. // CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] {} {}
  310. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template = constants.%complete_type.1]
  311. // CHECK:STDOUT:
  312. // CHECK:STDOUT: !members:
  313. // CHECK:STDOUT: .Self = constants.%A1
  314. // CHECK:STDOUT: .F = %F.decl
  315. // CHECK:STDOUT: complete_type_witness = %complete_type
  316. // CHECK:STDOUT: }
  317. // CHECK:STDOUT:
  318. // CHECK:STDOUT: class @A2 {
  319. // CHECK:STDOUT: %A1.ref: type = name_ref A1, file.%A1.decl [template = constants.%A1]
  320. // CHECK:STDOUT: %.loc9: %A2.elem = base_decl %A1.ref, element0 [template]
  321. // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] {} {}
  322. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.base [template = constants.%complete_type.2]
  323. // CHECK:STDOUT:
  324. // CHECK:STDOUT: !members:
  325. // CHECK:STDOUT: .Self = constants.%A2
  326. // CHECK:STDOUT: .base = %.loc9
  327. // CHECK:STDOUT: .F = %F.decl
  328. // CHECK:STDOUT: extend %A1.ref
  329. // CHECK:STDOUT: complete_type_witness = %complete_type
  330. // CHECK:STDOUT: }
  331. // CHECK:STDOUT:
  332. // CHECK:STDOUT: virtual fn @F.1();
  333. // CHECK:STDOUT:
  334. // CHECK:STDOUT: impl fn @F.2();
  335. // CHECK:STDOUT:
  336. // CHECK:STDOUT: --- impl_base.carbon
  337. // CHECK:STDOUT:
  338. // CHECK:STDOUT: constants {
  339. // CHECK:STDOUT: %B1: type = class_type @B1 [template]
  340. // CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template]
  341. // CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [template]
  342. // CHECK:STDOUT: %ptr.1: type = ptr_type <vtable> [template]
  343. // CHECK:STDOUT: %struct_type.vptr: type = struct_type {.<vptr>: %ptr.1} [template]
  344. // CHECK:STDOUT: %complete_type.1: <witness> = complete_type_witness %struct_type.vptr [template]
  345. // CHECK:STDOUT: %B2: type = class_type @B2 [template]
  346. // CHECK:STDOUT: %B2.elem: type = unbound_element_type %B2, %B1 [template]
  347. // CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template]
  348. // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template]
  349. // CHECK:STDOUT: %struct_type.base.1: type = struct_type {.base: %B1} [template]
  350. // CHECK:STDOUT: %complete_type.2: <witness> = complete_type_witness %struct_type.base.1 [template]
  351. // CHECK:STDOUT: %C: type = class_type @C [template]
  352. // CHECK:STDOUT: %C.elem: type = unbound_element_type %C, %B2 [template]
  353. // CHECK:STDOUT: %F.type.3: type = fn_type @F.3 [template]
  354. // CHECK:STDOUT: %F.3: %F.type.3 = struct_value () [template]
  355. // CHECK:STDOUT: %struct_type.base.3: type = struct_type {.base: %B2} [template]
  356. // CHECK:STDOUT: %complete_type.3: <witness> = complete_type_witness %struct_type.base.3 [template]
  357. // CHECK:STDOUT: }
  358. // CHECK:STDOUT:
  359. // CHECK:STDOUT: imports {
  360. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  361. // CHECK:STDOUT: import Core//prelude
  362. // CHECK:STDOUT: import Core//prelude/...
  363. // CHECK:STDOUT: }
  364. // CHECK:STDOUT: }
  365. // CHECK:STDOUT:
  366. // CHECK:STDOUT: file {
  367. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  368. // CHECK:STDOUT: .Core = imports.%Core
  369. // CHECK:STDOUT: .B1 = %B1.decl
  370. // CHECK:STDOUT: .B2 = %B2.decl
  371. // CHECK:STDOUT: .C = %C.decl
  372. // CHECK:STDOUT: }
  373. // CHECK:STDOUT: %Core.import = import Core
  374. // CHECK:STDOUT: %B1.decl: type = class_decl @B1 [template = constants.%B1] {} {}
  375. // CHECK:STDOUT: %B2.decl: type = class_decl @B2 [template = constants.%B2] {} {}
  376. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  377. // CHECK:STDOUT: }
  378. // CHECK:STDOUT:
  379. // CHECK:STDOUT: class @B1 {
  380. // CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] {} {}
  381. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template = constants.%complete_type.1]
  382. // CHECK:STDOUT:
  383. // CHECK:STDOUT: !members:
  384. // CHECK:STDOUT: .Self = constants.%B1
  385. // CHECK:STDOUT: .F = %F.decl
  386. // CHECK:STDOUT: complete_type_witness = %complete_type
  387. // CHECK:STDOUT: }
  388. // CHECK:STDOUT:
  389. // CHECK:STDOUT: class @B2 {
  390. // CHECK:STDOUT: %B1.ref: type = name_ref B1, file.%B1.decl [template = constants.%B1]
  391. // CHECK:STDOUT: %.loc9: %B2.elem = base_decl %B1.ref, element0 [template]
  392. // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] {} {}
  393. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.base.1 [template = constants.%complete_type.2]
  394. // CHECK:STDOUT:
  395. // CHECK:STDOUT: !members:
  396. // CHECK:STDOUT: .Self = constants.%B2
  397. // CHECK:STDOUT: .base = %.loc9
  398. // CHECK:STDOUT: .F = %F.decl
  399. // CHECK:STDOUT: extend %B1.ref
  400. // CHECK:STDOUT: complete_type_witness = %complete_type
  401. // CHECK:STDOUT: }
  402. // CHECK:STDOUT:
  403. // CHECK:STDOUT: class @C {
  404. // CHECK:STDOUT: %B2.ref: type = name_ref B2, file.%B2.decl [template = constants.%B2]
  405. // CHECK:STDOUT: %.loc14: %C.elem = base_decl %B2.ref, element0 [template]
  406. // CHECK:STDOUT: %F.decl: %F.type.3 = fn_decl @F.3 [template = constants.%F.3] {} {}
  407. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.base.3 [template = constants.%complete_type.3]
  408. // CHECK:STDOUT:
  409. // CHECK:STDOUT: !members:
  410. // CHECK:STDOUT: .Self = constants.%C
  411. // CHECK:STDOUT: .base = %.loc14
  412. // CHECK:STDOUT: .F = %F.decl
  413. // CHECK:STDOUT: extend %B2.ref
  414. // CHECK:STDOUT: complete_type_witness = %complete_type
  415. // CHECK:STDOUT: }
  416. // CHECK:STDOUT:
  417. // CHECK:STDOUT: virtual fn @F.1();
  418. // CHECK:STDOUT:
  419. // CHECK:STDOUT: impl fn @F.2();
  420. // CHECK:STDOUT:
  421. // CHECK:STDOUT: impl fn @F.3();
  422. // CHECK:STDOUT:
  423. // CHECK:STDOUT: --- fail_modifiers.carbon
  424. // CHECK:STDOUT:
  425. // CHECK:STDOUT: constants {
  426. // CHECK:STDOUT: %C: type = class_type @C [template]
  427. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  428. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  429. // CHECK:STDOUT: %ptr: type = ptr_type <vtable> [template]
  430. // CHECK:STDOUT: %struct_type.vptr: type = struct_type {.<vptr>: %ptr} [template]
  431. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template]
  432. // CHECK:STDOUT: }
  433. // CHECK:STDOUT:
  434. // CHECK:STDOUT: imports {
  435. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  436. // CHECK:STDOUT: import Core//prelude
  437. // CHECK:STDOUT: import Core//prelude/...
  438. // CHECK:STDOUT: }
  439. // CHECK:STDOUT: }
  440. // CHECK:STDOUT:
  441. // CHECK:STDOUT: file {
  442. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  443. // CHECK:STDOUT: .Core = imports.%Core
  444. // CHECK:STDOUT: .C = %C.decl
  445. // CHECK:STDOUT: }
  446. // CHECK:STDOUT: %Core.import = import Core
  447. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  448. // CHECK:STDOUT: }
  449. // CHECK:STDOUT:
  450. // CHECK:STDOUT: class @C {
  451. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {}
  452. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr [template = constants.%complete_type]
  453. // CHECK:STDOUT:
  454. // CHECK:STDOUT: !members:
  455. // CHECK:STDOUT: .Self = constants.%C
  456. // CHECK:STDOUT: .F = %F.decl
  457. // CHECK:STDOUT: complete_type_witness = %complete_type
  458. // CHECK:STDOUT: }
  459. // CHECK:STDOUT:
  460. // CHECK:STDOUT: impl fn @F();
  461. // CHECK:STDOUT:
  462. // CHECK:STDOUT: --- init_members.carbon
  463. // CHECK:STDOUT:
  464. // CHECK:STDOUT: constants {
  465. // CHECK:STDOUT: %Base: type = class_type @Base [template]
  466. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  467. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  468. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  469. // CHECK:STDOUT: %i32: type = int_type signed, %int_32 [template]
  470. // CHECK:STDOUT: %Base.elem: type = unbound_element_type %Base, %i32 [template]
  471. // CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template]
  472. // CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [template]
  473. // CHECK:STDOUT: %ptr.1: type = ptr_type <vtable> [template]
  474. // CHECK:STDOUT: %struct_type.vptr.m1.m2: type = struct_type {.<vptr>: %ptr.1, .m1: %i32, .m2: %i32} [template]
  475. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr.m1.m2 [template]
  476. // CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template]
  477. // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template]
  478. // CHECK:STDOUT: %int_3.1: Core.IntLiteral = int_value 3 [template]
  479. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  480. // CHECK:STDOUT: %Convert.type.14: type = fn_type @Convert.2, @impl.1(%int_32) [template]
  481. // CHECK:STDOUT: %Convert.14: %Convert.type.14 = struct_value () [template]
  482. // CHECK:STDOUT: %interface.9: <witness> = interface_witness (%Convert.14) [template]
  483. // CHECK:STDOUT: %Convert.bound.1: <bound method> = bound_method %int_3.1, %Convert.14 [template]
  484. // CHECK:STDOUT: %Convert.specific_fn.1: <specific function> = specific_function %Convert.bound.1, @Convert.2(%int_32) [template]
  485. // CHECK:STDOUT: %int_3.2: %i32 = int_value 3 [template]
  486. // CHECK:STDOUT: %struct_type.m2.m1.1: type = struct_type {.m2: %i32, .m1: %i32} [template]
  487. // CHECK:STDOUT: %int_5.1: Core.IntLiteral = int_value 5 [template]
  488. // CHECK:STDOUT: %struct_type.m2.m1.2: type = struct_type {.m2: Core.IntLiteral, .m1: Core.IntLiteral} [template]
  489. // CHECK:STDOUT: %Convert.bound.2: <bound method> = bound_method %int_5.1, %Convert.14 [template]
  490. // CHECK:STDOUT: %Convert.specific_fn.2: <specific function> = specific_function %Convert.bound.2, @Convert.2(%int_32) [template]
  491. // CHECK:STDOUT: %int_5.2: %i32 = int_value 5 [template]
  492. // CHECK:STDOUT: %int_4.1: Core.IntLiteral = int_value 4 [template]
  493. // CHECK:STDOUT: %Convert.bound.3: <bound method> = bound_method %int_4.1, %Convert.14 [template]
  494. // CHECK:STDOUT: %Convert.specific_fn.3: <specific function> = specific_function %Convert.bound.3, @Convert.2(%int_32) [template]
  495. // CHECK:STDOUT: %int_4.2: %i32 = int_value 4 [template]
  496. // CHECK:STDOUT: }
  497. // CHECK:STDOUT:
  498. // CHECK:STDOUT: imports {
  499. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  500. // CHECK:STDOUT: .Int = %import_ref.1
  501. // CHECK:STDOUT: .ImplicitAs = %import_ref.2
  502. // CHECK:STDOUT: import Core//prelude
  503. // CHECK:STDOUT: import Core//prelude/...
  504. // CHECK:STDOUT: }
  505. // CHECK:STDOUT: }
  506. // CHECK:STDOUT:
  507. // CHECK:STDOUT: file {
  508. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  509. // CHECK:STDOUT: .Core = imports.%Core
  510. // CHECK:STDOUT: .Base = %Base.decl
  511. // CHECK:STDOUT: .F = %F.decl
  512. // CHECK:STDOUT: }
  513. // CHECK:STDOUT: %Core.import = import Core
  514. // CHECK:STDOUT: %Base.decl: type = class_decl @Base [template = constants.%Base] {} {}
  515. // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] {} {}
  516. // CHECK:STDOUT: }
  517. // CHECK:STDOUT:
  518. // CHECK:STDOUT: class @Base {
  519. // CHECK:STDOUT: %int_32.loc5: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  520. // CHECK:STDOUT: %int.make_type_signed.loc5: init type = call constants.%Int(%int_32.loc5) [template = constants.%i32]
  521. // CHECK:STDOUT: %.loc5_11.1: type = value_of_initializer %int.make_type_signed.loc5 [template = constants.%i32]
  522. // CHECK:STDOUT: %.loc5_11.2: type = converted %int.make_type_signed.loc5, %.loc5_11.1 [template = constants.%i32]
  523. // CHECK:STDOUT: %.loc5_9: %Base.elem = field_decl m1, element1 [template]
  524. // CHECK:STDOUT: %int_32.loc6: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  525. // CHECK:STDOUT: %int.make_type_signed.loc6: init type = call constants.%Int(%int_32.loc6) [template = constants.%i32]
  526. // CHECK:STDOUT: %.loc6_11.1: type = value_of_initializer %int.make_type_signed.loc6 [template = constants.%i32]
  527. // CHECK:STDOUT: %.loc6_11.2: type = converted %int.make_type_signed.loc6, %.loc6_11.1 [template = constants.%i32]
  528. // CHECK:STDOUT: %.loc6_9: %Base.elem = field_decl m2, element2 [template]
  529. // CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] {} {}
  530. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr.m1.m2 [template = constants.%complete_type]
  531. // CHECK:STDOUT:
  532. // CHECK:STDOUT: !members:
  533. // CHECK:STDOUT: .Self = constants.%Base
  534. // CHECK:STDOUT: .m1 = %.loc5_9
  535. // CHECK:STDOUT: .m2 = %.loc6_9
  536. // CHECK:STDOUT: .F = %F.decl
  537. // CHECK:STDOUT: complete_type_witness = %complete_type
  538. // CHECK:STDOUT: }
  539. // CHECK:STDOUT:
  540. // CHECK:STDOUT: virtual fn @F.1();
  541. // CHECK:STDOUT:
  542. // CHECK:STDOUT: fn @F.2() {
  543. // CHECK:STDOUT: !entry:
  544. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  545. // CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%int_32) [template = constants.%i32]
  546. // CHECK:STDOUT: %.loc12_10.1: type = value_of_initializer %int.make_type_signed [template = constants.%i32]
  547. // CHECK:STDOUT: %.loc12_10.2: type = converted %int.make_type_signed, %.loc12_10.1 [template = constants.%i32]
  548. // CHECK:STDOUT: %i.var: ref %i32 = var i
  549. // CHECK:STDOUT: %i: ref %i32 = bind_name i, %i.var
  550. // CHECK:STDOUT: %int_3.loc12: Core.IntLiteral = int_value 3 [template = constants.%int_3.1]
  551. // CHECK:STDOUT: %impl.elem0.loc12: %Convert.type.2 = interface_witness_access constants.%interface.9, element0 [template = constants.%Convert.14]
  552. // CHECK:STDOUT: %Convert.bound.loc12: <bound method> = bound_method %int_3.loc12, %impl.elem0.loc12 [template = constants.%Convert.bound.1]
  553. // CHECK:STDOUT: %Convert.specific_fn.loc12: <specific function> = specific_function %Convert.bound.loc12, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.1]
  554. // CHECK:STDOUT: %int.convert_checked.loc12: init %i32 = call %Convert.specific_fn.loc12(%int_3.loc12) [template = constants.%int_3.2]
  555. // CHECK:STDOUT: %.loc12_17: init %i32 = converted %int_3.loc12, %int.convert_checked.loc12 [template = constants.%int_3.2]
  556. // CHECK:STDOUT: assign %i.var, %.loc12_17
  557. // CHECK:STDOUT: %Base.ref.loc14: type = name_ref Base, file.%Base.decl [template = constants.%Base]
  558. // CHECK:STDOUT: %b1.var: ref %Base = var b1
  559. // CHECK:STDOUT: %b1: ref %Base = bind_name b1, %b1.var
  560. // CHECK:STDOUT: %i.ref.loc14_25: ref %i32 = name_ref i, %i
  561. // CHECK:STDOUT: %i.ref.loc14_34: ref %i32 = name_ref i, %i
  562. // CHECK:STDOUT: %.loc14_35.1: %struct_type.m2.m1.1 = struct_literal (%i.ref.loc14_25, %i.ref.loc14_34)
  563. // CHECK:STDOUT: %.loc14_35.2: ref %ptr.1 = class_element_access %b1.var, element0
  564. // CHECK:STDOUT: %.loc14_35.3: ref %ptr.1 = vtable_ptr
  565. // CHECK:STDOUT: %.loc14_35.4: init %ptr.1 = initialize_from %.loc14_35.3 to %.loc14_35.2
  566. // CHECK:STDOUT: %.loc14_34: %i32 = bind_value %i.ref.loc14_34
  567. // CHECK:STDOUT: %.loc14_35.5: ref %i32 = class_element_access %b1.var, element2
  568. // CHECK:STDOUT: %.loc14_35.6: init %i32 = initialize_from %.loc14_34 to %.loc14_35.5
  569. // CHECK:STDOUT: %.loc14_25: %i32 = bind_value %i.ref.loc14_25
  570. // CHECK:STDOUT: %.loc14_35.7: ref %i32 = class_element_access %b1.var, element1
  571. // CHECK:STDOUT: %.loc14_35.8: init %i32 = initialize_from %.loc14_25 to %.loc14_35.7
  572. // CHECK:STDOUT: %.loc14_35.9: init %Base = class_init (%.loc14_35.4, %.loc14_35.6, %.loc14_35.8), %b1.var
  573. // CHECK:STDOUT: %.loc14_36: init %Base = converted %.loc14_35.1, %.loc14_35.9
  574. // CHECK:STDOUT: assign %b1.var, %.loc14_36
  575. // CHECK:STDOUT: %Base.ref.loc15: type = name_ref Base, file.%Base.decl [template = constants.%Base]
  576. // CHECK:STDOUT: %b2.var: ref %Base = var b2
  577. // CHECK:STDOUT: %b2: ref %Base = bind_name b2, %b2.var
  578. // CHECK:STDOUT: %int_3.loc15: Core.IntLiteral = int_value 3 [template = constants.%int_3.1]
  579. // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [template = constants.%int_5.1]
  580. // CHECK:STDOUT: %.loc15_35.1: %struct_type.m2.m1.2 = struct_literal (%int_3.loc15, %int_5)
  581. // CHECK:STDOUT: %.loc15_35.2: ref %ptr.1 = class_element_access %b2.var, element0
  582. // CHECK:STDOUT: %.loc15_35.3: ref %ptr.1 = vtable_ptr
  583. // CHECK:STDOUT: %.loc15_35.4: init %ptr.1 = initialize_from %.loc15_35.3 to %.loc15_35.2
  584. // CHECK:STDOUT: %impl.elem0.loc15_35.1: %Convert.type.2 = interface_witness_access constants.%interface.9, element0 [template = constants.%Convert.14]
  585. // CHECK:STDOUT: %Convert.bound.loc15_35.1: <bound method> = bound_method %int_5, %impl.elem0.loc15_35.1 [template = constants.%Convert.bound.2]
  586. // CHECK:STDOUT: %Convert.specific_fn.loc15_35.1: <specific function> = specific_function %Convert.bound.loc15_35.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.2]
  587. // CHECK:STDOUT: %int.convert_checked.loc15_35.1: init %i32 = call %Convert.specific_fn.loc15_35.1(%int_5) [template = constants.%int_5.2]
  588. // CHECK:STDOUT: %.loc15_35.5: init %i32 = converted %int_5, %int.convert_checked.loc15_35.1 [template = constants.%int_5.2]
  589. // CHECK:STDOUT: %.loc15_35.6: ref %i32 = class_element_access %b2.var, element2
  590. // CHECK:STDOUT: %.loc15_35.7: init %i32 = initialize_from %.loc15_35.5 to %.loc15_35.6 [template = constants.%int_5.2]
  591. // CHECK:STDOUT: %impl.elem0.loc15_35.2: %Convert.type.2 = interface_witness_access constants.%interface.9, element0 [template = constants.%Convert.14]
  592. // CHECK:STDOUT: %Convert.bound.loc15_35.2: <bound method> = bound_method %int_3.loc15, %impl.elem0.loc15_35.2 [template = constants.%Convert.bound.1]
  593. // CHECK:STDOUT: %Convert.specific_fn.loc15_35.2: <specific function> = specific_function %Convert.bound.loc15_35.2, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.1]
  594. // CHECK:STDOUT: %int.convert_checked.loc15_35.2: init %i32 = call %Convert.specific_fn.loc15_35.2(%int_3.loc15) [template = constants.%int_3.2]
  595. // CHECK:STDOUT: %.loc15_35.8: init %i32 = converted %int_3.loc15, %int.convert_checked.loc15_35.2 [template = constants.%int_3.2]
  596. // CHECK:STDOUT: %.loc15_35.9: ref %i32 = class_element_access %b2.var, element1
  597. // CHECK:STDOUT: %.loc15_35.10: init %i32 = initialize_from %.loc15_35.8 to %.loc15_35.9 [template = constants.%int_3.2]
  598. // CHECK:STDOUT: %.loc15_35.11: init %Base = class_init (%.loc15_35.4, %.loc15_35.7, %.loc15_35.10), %b2.var
  599. // CHECK:STDOUT: %.loc15_36: init %Base = converted %.loc15_35.1, %.loc15_35.11
  600. // CHECK:STDOUT: assign %b2.var, %.loc15_36
  601. // CHECK:STDOUT: %b1.ref: ref %Base = name_ref b1, %b1
  602. // CHECK:STDOUT: %m2.ref: %Base.elem = name_ref m2, @Base.%.loc6_9 [template = @Base.%.loc6_9]
  603. // CHECK:STDOUT: %.loc18_5: ref %i32 = class_element_access %b1.ref, element2
  604. // CHECK:STDOUT: %int_4: Core.IntLiteral = int_value 4 [template = constants.%int_4.1]
  605. // CHECK:STDOUT: %impl.elem0.loc18: %Convert.type.2 = interface_witness_access constants.%interface.9, element0 [template = constants.%Convert.14]
  606. // CHECK:STDOUT: %Convert.bound.loc18: <bound method> = bound_method %int_4, %impl.elem0.loc18 [template = constants.%Convert.bound.3]
  607. // CHECK:STDOUT: %Convert.specific_fn.loc18: <specific function> = specific_function %Convert.bound.loc18, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.3]
  608. // CHECK:STDOUT: %int.convert_checked.loc18: init %i32 = call %Convert.specific_fn.loc18(%int_4) [template = constants.%int_4.2]
  609. // CHECK:STDOUT: %.loc18_9: init %i32 = converted %int_4, %int.convert_checked.loc18 [template = constants.%int_4.2]
  610. // CHECK:STDOUT: assign %.loc18_5, %.loc18_9
  611. // CHECK:STDOUT: return
  612. // CHECK:STDOUT: }
  613. // CHECK:STDOUT:
  614. // CHECK:STDOUT: --- todo_fail_impl_without_base_declaration.carbon
  615. // CHECK:STDOUT:
  616. // CHECK:STDOUT: constants {
  617. // CHECK:STDOUT: %Base: type = class_type @Base [template]
  618. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  619. // CHECK:STDOUT: %complete_type.1: <witness> = complete_type_witness %empty_struct_type [template]
  620. // CHECK:STDOUT: %Derived: type = class_type @Derived [template]
  621. // CHECK:STDOUT: %Derived.elem: type = unbound_element_type %Derived, %Base [template]
  622. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  623. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  624. // CHECK:STDOUT: %ptr.2: type = ptr_type <vtable> [template]
  625. // CHECK:STDOUT: %struct_type.vptr.base: type = struct_type {.<vptr>: %ptr.2, .base: %Base} [template]
  626. // CHECK:STDOUT: %complete_type.2: <witness> = complete_type_witness %struct_type.vptr.base [template]
  627. // CHECK:STDOUT: }
  628. // CHECK:STDOUT:
  629. // CHECK:STDOUT: imports {
  630. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  631. // CHECK:STDOUT: import Core//prelude
  632. // CHECK:STDOUT: import Core//prelude/...
  633. // CHECK:STDOUT: }
  634. // CHECK:STDOUT: }
  635. // CHECK:STDOUT:
  636. // CHECK:STDOUT: file {
  637. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  638. // CHECK:STDOUT: .Core = imports.%Core
  639. // CHECK:STDOUT: .Base = %Base.decl
  640. // CHECK:STDOUT: .Derived = %Derived.decl
  641. // CHECK:STDOUT: }
  642. // CHECK:STDOUT: %Core.import = import Core
  643. // CHECK:STDOUT: %Base.decl: type = class_decl @Base [template = constants.%Base] {} {}
  644. // CHECK:STDOUT: %Derived.decl: type = class_decl @Derived [template = constants.%Derived] {} {}
  645. // CHECK:STDOUT: }
  646. // CHECK:STDOUT:
  647. // CHECK:STDOUT: class @Base {
  648. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type.1]
  649. // CHECK:STDOUT:
  650. // CHECK:STDOUT: !members:
  651. // CHECK:STDOUT: .Self = constants.%Base
  652. // CHECK:STDOUT: complete_type_witness = %complete_type
  653. // CHECK:STDOUT: }
  654. // CHECK:STDOUT:
  655. // CHECK:STDOUT: class @Derived {
  656. // CHECK:STDOUT: %Base.ref: type = name_ref Base, file.%Base.decl [template = constants.%Base]
  657. // CHECK:STDOUT: %.loc8: %Derived.elem = base_decl %Base.ref, element1 [template]
  658. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {}
  659. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.vptr.base [template = constants.%complete_type.2]
  660. // CHECK:STDOUT:
  661. // CHECK:STDOUT: !members:
  662. // CHECK:STDOUT: .Self = constants.%Derived
  663. // CHECK:STDOUT: .base = %.loc8
  664. // CHECK:STDOUT: .F = %F.decl
  665. // CHECK:STDOUT: extend %Base.ref
  666. // CHECK:STDOUT: complete_type_witness = %complete_type
  667. // CHECK:STDOUT: }
  668. // CHECK:STDOUT:
  669. // CHECK:STDOUT: impl fn @F();
  670. // CHECK:STDOUT: