todo_access_modifiers.carbon 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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/todo_access_modifiers.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/todo_access_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. // CHECK:STDOUT: --- todo_access_modifiers.carbon
  18. // CHECK:STDOUT:
  19. // CHECK:STDOUT: constants {
  20. // CHECK:STDOUT: %Access: type = class_type @Access [template]
  21. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  22. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  23. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  24. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  25. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  26. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  27. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  28. // CHECK:STDOUT: %.2: type = unbound_element_type %Access, i32 [template]
  29. // CHECK:STDOUT: %.3: type = struct_type {.k: i32, .l: i32} [template]
  30. // CHECK:STDOUT: %.4: <witness> = complete_type_witness %.3 [template]
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: imports {
  34. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  35. // CHECK:STDOUT: .Int32 = %import_ref
  36. // CHECK:STDOUT: import Core//prelude
  37. // CHECK:STDOUT: import Core//prelude/operators
  38. // CHECK:STDOUT: import Core//prelude/types
  39. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  40. // CHECK:STDOUT: import Core//prelude/operators/as
  41. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  42. // CHECK:STDOUT: import Core//prelude/operators/comparison
  43. // CHECK:STDOUT: import Core//prelude/types/bool
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+9, loaded [template = constants.%Int32]
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: file {
  49. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  50. // CHECK:STDOUT: .Core = imports.%Core
  51. // CHECK:STDOUT: .Access = %Access.decl
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT: %Core.import = import Core
  54. // CHECK:STDOUT: %Access.decl: type = class_decl @Access [template = constants.%Access] {} {}
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT:
  57. // CHECK:STDOUT: class @Access {
  58. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {}
  59. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {} {}
  60. // CHECK:STDOUT: %int.make_type_32.loc17: init type = call constants.%Int32() [template = i32]
  61. // CHECK:STDOUT: %.loc17_18.1: type = value_of_initializer %int.make_type_32.loc17 [template = i32]
  62. // CHECK:STDOUT: %.loc17_18.2: type = converted %int.make_type_32.loc17, %.loc17_18.1 [template = i32]
  63. // CHECK:STDOUT: %.loc17_16: %.2 = field_decl k, element0 [template]
  64. // CHECK:STDOUT: %int.make_type_32.loc19: init type = call constants.%Int32() [template = i32]
  65. // CHECK:STDOUT: %.loc19_20.1: type = value_of_initializer %int.make_type_32.loc19 [template = i32]
  66. // CHECK:STDOUT: %.loc19_20.2: type = converted %int.make_type_32.loc19, %.loc19_20.1 [template = i32]
  67. // CHECK:STDOUT: %.loc19_18: %.2 = field_decl l, element1 [template]
  68. // CHECK:STDOUT: %.loc20: <witness> = complete_type_witness %.3 [template = constants.%.4]
  69. // CHECK:STDOUT:
  70. // CHECK:STDOUT: !members:
  71. // CHECK:STDOUT: .Self = constants.%Access
  72. // CHECK:STDOUT: .F [private] = %F.decl
  73. // CHECK:STDOUT: .G [protected] = %G.decl
  74. // CHECK:STDOUT: .k [private] = %.loc17_16
  75. // CHECK:STDOUT: .l [protected] = %.loc19_18
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT:
  78. // CHECK:STDOUT: fn @F();
  79. // CHECK:STDOUT:
  80. // CHECK:STDOUT: fn @G();
  81. // CHECK:STDOUT:
  82. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  83. // CHECK:STDOUT: