fail_todo_modifiers.carbon 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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/fail_todo_modifiers.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/fail_todo_modifiers.carbon
  10. // TODO: Test calls to these (member access control is not yet implemented).
  11. class Access {
  12. private fn F();
  13. protected fn G();
  14. private var k: i32;
  15. protected var l: i32;
  16. }
  17. base class Base {
  18. // CHECK:STDERR: fail_todo_modifiers.carbon:[[@LINE+4]]:3: ERROR: Semantics TODO: `method modifier`.
  19. // CHECK:STDERR: virtual fn H();
  20. // CHECK:STDERR: ^~~~~~~
  21. // CHECK:STDERR:
  22. virtual fn H();
  23. // CHECK:STDERR: fail_todo_modifiers.carbon:[[@LINE+4]]:3: ERROR: Semantics TODO: `method modifier`.
  24. // CHECK:STDERR: impl fn I();
  25. // CHECK:STDERR: ^~~~
  26. // CHECK:STDERR:
  27. impl fn I();
  28. }
  29. abstract class Abstract {
  30. // CHECK:STDERR: fail_todo_modifiers.carbon:[[@LINE+4]]:3: ERROR: Semantics TODO: `method modifier`.
  31. // CHECK:STDERR: abstract fn J();
  32. // CHECK:STDERR: ^~~~~~~~
  33. // CHECK:STDERR:
  34. abstract fn J();
  35. // CHECK:STDERR: fail_todo_modifiers.carbon:[[@LINE+4]]:3: ERROR: Semantics TODO: `method modifier`.
  36. // CHECK:STDERR: virtual fn K();
  37. // CHECK:STDERR: ^~~~~~~
  38. // CHECK:STDERR:
  39. virtual fn K();
  40. // CHECK:STDERR: fail_todo_modifiers.carbon:[[@LINE+3]]:3: ERROR: Semantics TODO: `method modifier`.
  41. // CHECK:STDERR: impl fn L();
  42. // CHECK:STDERR: ^~~~
  43. impl fn L();
  44. }
  45. // CHECK:STDOUT: --- fail_todo_modifiers.carbon
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: constants {
  48. // CHECK:STDOUT: %Access: type = class_type @Access [template]
  49. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  50. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  51. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  52. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  53. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  54. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  55. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  56. // CHECK:STDOUT: %.2: type = unbound_element_type %Access, i32 [template]
  57. // CHECK:STDOUT: %.3: type = struct_type {.k: i32, .l: i32} [template]
  58. // CHECK:STDOUT: %Base: type = class_type @Base [template]
  59. // CHECK:STDOUT: %H.type: type = fn_type @H [template]
  60. // CHECK:STDOUT: %H: %H.type = struct_value () [template]
  61. // CHECK:STDOUT: %I.type: type = fn_type @I [template]
  62. // CHECK:STDOUT: %I: %I.type = struct_value () [template]
  63. // CHECK:STDOUT: %.4: type = struct_type {} [template]
  64. // CHECK:STDOUT: %Abstract: type = class_type @Abstract [template]
  65. // CHECK:STDOUT: %J.type: type = fn_type @J [template]
  66. // CHECK:STDOUT: %J: %J.type = struct_value () [template]
  67. // CHECK:STDOUT: %K.type: type = fn_type @K [template]
  68. // CHECK:STDOUT: %K: %K.type = struct_value () [template]
  69. // CHECK:STDOUT: %L.type: type = fn_type @L [template]
  70. // CHECK:STDOUT: %L: %L.type = struct_value () [template]
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: file {
  74. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  75. // CHECK:STDOUT: .Core = %Core
  76. // CHECK:STDOUT: .Access = %Access.decl
  77. // CHECK:STDOUT: .Base = %Base.decl
  78. // CHECK:STDOUT: .Abstract = %Abstract.decl
  79. // CHECK:STDOUT: }
  80. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  81. // CHECK:STDOUT: %Access.decl: type = class_decl @Access [template = constants.%Access] {}
  82. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  83. // CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  84. // CHECK:STDOUT: %Base.decl: type = class_decl @Base [template = constants.%Base] {}
  85. // CHECK:STDOUT: %Abstract.decl: type = class_decl @Abstract [template = constants.%Abstract] {}
  86. // CHECK:STDOUT: }
  87. // CHECK:STDOUT:
  88. // CHECK:STDOUT: class @Access {
  89. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {}
  90. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {}
  91. // CHECK:STDOUT: %int.make_type_32.loc17: init type = call constants.%Int32() [template = i32]
  92. // CHECK:STDOUT: %.loc17_18.1: type = value_of_initializer %int.make_type_32.loc17 [template = i32]
  93. // CHECK:STDOUT: %.loc17_18.2: type = converted %int.make_type_32.loc17, %.loc17_18.1 [template = i32]
  94. // CHECK:STDOUT: %.loc17_16: %.2 = field_decl k, element0 [template]
  95. // CHECK:STDOUT: %int.make_type_32.loc19: init type = call constants.%Int32() [template = i32]
  96. // CHECK:STDOUT: %.loc19_20.1: type = value_of_initializer %int.make_type_32.loc19 [template = i32]
  97. // CHECK:STDOUT: %.loc19_20.2: type = converted %int.make_type_32.loc19, %.loc19_20.1 [template = i32]
  98. // CHECK:STDOUT: %.loc19_18: %.2 = field_decl l, element1 [template]
  99. // CHECK:STDOUT:
  100. // CHECK:STDOUT: !members:
  101. // CHECK:STDOUT: .Self = constants.%Access
  102. // CHECK:STDOUT: .F [private] = %F.decl
  103. // CHECK:STDOUT: .G [protected] = %G.decl
  104. // CHECK:STDOUT: .k [private] = %.loc17_16
  105. // CHECK:STDOUT: .l [protected] = %.loc19_18
  106. // CHECK:STDOUT: }
  107. // CHECK:STDOUT:
  108. // CHECK:STDOUT: class @Base {
  109. // CHECK:STDOUT: %H.decl: %H.type = fn_decl @H [template = constants.%H] {}
  110. // CHECK:STDOUT: %I.decl: %I.type = fn_decl @I [template = constants.%I] {}
  111. // CHECK:STDOUT:
  112. // CHECK:STDOUT: !members:
  113. // CHECK:STDOUT: .Self = constants.%Base
  114. // CHECK:STDOUT: .H = %H.decl
  115. // CHECK:STDOUT: .I = %I.decl
  116. // CHECK:STDOUT: }
  117. // CHECK:STDOUT:
  118. // CHECK:STDOUT: class @Abstract {
  119. // CHECK:STDOUT: %J.decl: %J.type = fn_decl @J [template = constants.%J] {}
  120. // CHECK:STDOUT: %K.decl: %K.type = fn_decl @K [template = constants.%K] {}
  121. // CHECK:STDOUT: %L.decl: %L.type = fn_decl @L [template = constants.%L] {}
  122. // CHECK:STDOUT:
  123. // CHECK:STDOUT: !members:
  124. // CHECK:STDOUT: .Self = constants.%Abstract
  125. // CHECK:STDOUT: .J = %J.decl
  126. // CHECK:STDOUT: .K = %K.decl
  127. // CHECK:STDOUT: .L = %L.decl
  128. // CHECK:STDOUT: }
  129. // CHECK:STDOUT:
  130. // CHECK:STDOUT: fn @F();
  131. // CHECK:STDOUT:
  132. // CHECK:STDOUT: fn @G();
  133. // CHECK:STDOUT:
  134. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  135. // CHECK:STDOUT:
  136. // CHECK:STDOUT: fn @H();
  137. // CHECK:STDOUT:
  138. // CHECK:STDOUT: fn @I();
  139. // CHECK:STDOUT:
  140. // CHECK:STDOUT: fn @J();
  141. // CHECK:STDOUT:
  142. // CHECK:STDOUT: fn @K();
  143. // CHECK:STDOUT:
  144. // CHECK:STDOUT: fn @L();
  145. // CHECK:STDOUT: