todo_access_modifiers.carbon 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/int.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/todo_access_modifiers.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/todo_access_modifiers.carbon
  14. // TODO: Test calls to these (member access control is not yet implemented).
  15. class Access {
  16. private fn F();
  17. protected fn G();
  18. private var k: i32;
  19. protected var l: i32;
  20. }
  21. // CHECK:STDOUT: --- todo_access_modifiers.carbon
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: constants {
  24. // CHECK:STDOUT: %Access: type = class_type @Access [concrete]
  25. // CHECK:STDOUT: %Access.F.type: type = fn_type @Access.F [concrete]
  26. // CHECK:STDOUT: %Access.F: %Access.F.type = struct_value () [concrete]
  27. // CHECK:STDOUT: %Access.G.type: type = fn_type @Access.G [concrete]
  28. // CHECK:STDOUT: %Access.G: %Access.G.type = struct_value () [concrete]
  29. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  30. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  31. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  32. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  33. // CHECK:STDOUT: %Access.elem: type = unbound_element_type %Access, %i32 [concrete]
  34. // CHECK:STDOUT: %struct_type.k.l: type = struct_type {.k: %i32, .l: %i32} [concrete]
  35. // CHECK:STDOUT: %complete_type.48a: <witness> = complete_type_witness %struct_type.k.l [concrete]
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: imports {
  39. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  40. // CHECK:STDOUT: .Int = %Core.Int
  41. // CHECK:STDOUT: import Core//prelude
  42. // CHECK:STDOUT: import Core//prelude/...
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: file {
  48. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  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 [concrete = constants.%Access] {} {}
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: class @Access {
  57. // CHECK:STDOUT: %Access.F.decl: %Access.F.type = fn_decl @Access.F [concrete = constants.%Access.F] {} {}
  58. // CHECK:STDOUT: %Access.G.decl: %Access.G.type = fn_decl @Access.G [concrete = constants.%Access.G] {} {}
  59. // CHECK:STDOUT: %int_32.loc21: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  60. // CHECK:STDOUT: %i32.loc21: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  61. // CHECK:STDOUT: %.loc21: %Access.elem = field_decl k, element0 [concrete]
  62. // CHECK:STDOUT: %int_32.loc23: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  63. // CHECK:STDOUT: %i32.loc23: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  64. // CHECK:STDOUT: %.loc23: %Access.elem = field_decl l, element1 [concrete]
  65. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%struct_type.k.l [concrete = constants.%complete_type.48a]
  66. // CHECK:STDOUT: complete_type_witness = %complete_type
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: !members:
  69. // CHECK:STDOUT: .Self = constants.%Access
  70. // CHECK:STDOUT: .F [private] = %Access.F.decl
  71. // CHECK:STDOUT: .G [protected] = %Access.G.decl
  72. // CHECK:STDOUT: .k [private] = %.loc21
  73. // CHECK:STDOUT: .l [protected] = %.loc23
  74. // CHECK:STDOUT: }
  75. // CHECK:STDOUT:
  76. // CHECK:STDOUT: fn @Access.F();
  77. // CHECK:STDOUT:
  78. // CHECK:STDOUT: fn @Access.G();
  79. // CHECK:STDOUT: