todo_access_modifiers.carbon 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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: }
  31. // CHECK:STDOUT:
  32. // CHECK:STDOUT: imports {
  33. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  34. // CHECK:STDOUT: .Int32 = %import_ref
  35. // CHECK:STDOUT: import Core//prelude
  36. // CHECK:STDOUT: import Core//prelude/operators
  37. // CHECK:STDOUT: import Core//prelude/types
  38. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  39. // CHECK:STDOUT: import Core//prelude/operators/as
  40. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  41. // CHECK:STDOUT: import Core//prelude/operators/comparison
  42. // CHECK:STDOUT: import Core//prelude/types/bool
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: file {
  48. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  49. // CHECK:STDOUT: .Core = imports.%Core
  50. // CHECK:STDOUT: .Access = %Access.decl
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT: %Core.import = import Core
  53. // CHECK:STDOUT: %Access.decl: type = class_decl @Access [template = constants.%Access] {}
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: class @Access {
  57. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {}
  58. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {}
  59. // CHECK:STDOUT: %int.make_type_32.loc17: init type = call constants.%Int32() [template = i32]
  60. // CHECK:STDOUT: %.loc17_18.1: type = value_of_initializer %int.make_type_32.loc17 [template = i32]
  61. // CHECK:STDOUT: %.loc17_18.2: type = converted %int.make_type_32.loc17, %.loc17_18.1 [template = i32]
  62. // CHECK:STDOUT: %.loc17_16: %.2 = field_decl k, element0 [template]
  63. // CHECK:STDOUT: %int.make_type_32.loc19: init type = call constants.%Int32() [template = i32]
  64. // CHECK:STDOUT: %.loc19_20.1: type = value_of_initializer %int.make_type_32.loc19 [template = i32]
  65. // CHECK:STDOUT: %.loc19_20.2: type = converted %int.make_type_32.loc19, %.loc19_20.1 [template = i32]
  66. // CHECK:STDOUT: %.loc19_18: %.2 = field_decl l, element1 [template]
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: !members:
  69. // CHECK:STDOUT: .Self = constants.%Access
  70. // CHECK:STDOUT: .F [private] = %F.decl
  71. // CHECK:STDOUT: .G [protected] = %G.decl
  72. // CHECK:STDOUT: .k [private] = %.loc17_16
  73. // CHECK:STDOUT: .l [protected] = %.loc19_18
  74. // CHECK:STDOUT: }
  75. // CHECK:STDOUT:
  76. // CHECK:STDOUT: fn @F();
  77. // CHECK:STDOUT:
  78. // CHECK:STDOUT: fn @G();
  79. // CHECK:STDOUT:
  80. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  81. // CHECK:STDOUT: