base_function_unqualified.carbon 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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/base_function_unqualified.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/base_function_unqualified.carbon
  10. base class Base {
  11. fn F();
  12. }
  13. class Derived {
  14. extend base: Base;
  15. fn G() { F(); }
  16. fn H();
  17. }
  18. fn Derived.H() {
  19. F();
  20. }
  21. // CHECK:STDOUT: --- base_function_unqualified.carbon
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: constants {
  24. // CHECK:STDOUT: %Base: type = class_type @Base [template]
  25. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  26. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  27. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  28. // CHECK:STDOUT: %.2: type = struct_type {} [template]
  29. // CHECK:STDOUT: %Derived: type = class_type @Derived [template]
  30. // CHECK:STDOUT: %.3: type = ptr_type %.2 [template]
  31. // CHECK:STDOUT: %.4: type = unbound_element_type %Derived, %Base [template]
  32. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  33. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  34. // CHECK:STDOUT: %H.type: type = fn_type @H [template]
  35. // CHECK:STDOUT: %H: %H.type = struct_value () [template]
  36. // CHECK:STDOUT: %.5: type = struct_type {.base: %Base} [template]
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT:
  39. // CHECK:STDOUT: file {
  40. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  41. // CHECK:STDOUT: .Core = %Core
  42. // CHECK:STDOUT: .Base = %Base.decl
  43. // CHECK:STDOUT: .Derived = %Derived.decl
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT: %Core.import = import Core
  46. // CHECK:STDOUT: %Core: <namespace> = namespace %Core.import, [template] {}
  47. // CHECK:STDOUT: %Base.decl: type = class_decl @Base [template = constants.%Base] {}
  48. // CHECK:STDOUT: %Derived.decl: type = class_decl @Derived [template = constants.%Derived] {}
  49. // CHECK:STDOUT: %H.decl: %H.type = fn_decl @H [template = constants.%H] {}
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: class @Base {
  53. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {}
  54. // CHECK:STDOUT:
  55. // CHECK:STDOUT: !members:
  56. // CHECK:STDOUT: .Self = constants.%Base
  57. // CHECK:STDOUT: .F = %F.decl
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: class @Derived {
  61. // CHECK:STDOUT: %Base.ref: type = name_ref Base, file.%Base.decl [template = constants.%Base]
  62. // CHECK:STDOUT: %.loc16: %.4 = base_decl %Base, element0 [template]
  63. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {}
  64. // CHECK:STDOUT: %H.decl: %H.type = fn_decl @H [template = constants.%H] {}
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: !members:
  67. // CHECK:STDOUT: .Self = constants.%Derived
  68. // CHECK:STDOUT: .base = %.loc16
  69. // CHECK:STDOUT: .G = %G.decl
  70. // CHECK:STDOUT: .H = %H.decl
  71. // CHECK:STDOUT: extend name_scope2
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT:
  74. // CHECK:STDOUT: fn @F();
  75. // CHECK:STDOUT:
  76. // CHECK:STDOUT: fn @G() {
  77. // CHECK:STDOUT: !entry:
  78. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, @Base.%F.decl [template = constants.%F]
  79. // CHECK:STDOUT: %F.call: init %.1 = call %F.ref()
  80. // CHECK:STDOUT: return
  81. // CHECK:STDOUT: }
  82. // CHECK:STDOUT:
  83. // CHECK:STDOUT: fn @H() {
  84. // CHECK:STDOUT: !entry:
  85. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, @Base.%F.decl [template = constants.%F]
  86. // CHECK:STDOUT: %F.call: init %.1 = call %F.ref()
  87. // CHECK:STDOUT: return
  88. // CHECK:STDOUT: }
  89. // CHECK:STDOUT: