fail_addr_not_self.carbon 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  6. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  7. //
  8. // AUTOUPDATE
  9. // TIP: To test this file alone, run:
  10. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/fail_addr_not_self.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/fail_addr_not_self.carbon
  13. class Class {
  14. // CHECK:STDERR: fail_addr_not_self.carbon:[[@LINE+4]]:8: error: `addr` can only be applied to a `self` parameter [AddrOnNonSelfParam]
  15. // CHECK:STDERR: fn F[addr a:! Class*]();
  16. // CHECK:STDERR: ^~~~
  17. // CHECK:STDERR:
  18. fn F[addr a:! Class*]();
  19. // CHECK:STDERR: fail_addr_not_self.carbon:[[@LINE+4]]:8: error: `addr` can only be applied to a `self` parameter [AddrOnNonSelfParam]
  20. // CHECK:STDERR: fn G(addr b: Class*);
  21. // CHECK:STDERR: ^~~~
  22. // CHECK:STDERR:
  23. fn G(addr b: Class*);
  24. }
  25. // CHECK:STDOUT: --- fail_addr_not_self.carbon
  26. // CHECK:STDOUT:
  27. // CHECK:STDOUT: constants {
  28. // CHECK:STDOUT: %Class: type = class_type @Class [concrete]
  29. // CHECK:STDOUT: %ptr: type = ptr_type %Class [concrete]
  30. // CHECK:STDOUT: %a: %ptr = bind_symbolic_name a, 0 [symbolic]
  31. // CHECK:STDOUT: %pattern_type: type = pattern_type %ptr [concrete]
  32. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  33. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  34. // CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
  35. // CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
  36. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  37. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT:
  40. // CHECK:STDOUT: imports {
  41. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  42. // CHECK:STDOUT: import Core//prelude
  43. // CHECK:STDOUT: import Core//prelude/...
  44. // CHECK:STDOUT: }
  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: .Class = %Class.decl
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT: %Core.import = import Core
  53. // CHECK:STDOUT: %Class.decl: type = class_decl @Class [concrete = constants.%Class] {} {}
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: class @Class {
  57. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  58. // CHECK:STDOUT: %a.patt: %pattern_type = symbolic_binding_pattern a, 0 [concrete]
  59. // CHECK:STDOUT: } {
  60. // CHECK:STDOUT: %.loc19: type = splice_block %ptr [concrete = constants.%ptr] {
  61. // CHECK:STDOUT: %Class.ref: type = name_ref Class, file.%Class.decl [concrete = constants.%Class]
  62. // CHECK:STDOUT: %ptr: type = ptr_type %Class.ref [concrete = constants.%ptr]
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT: %a.loc19_13.2: %ptr = bind_symbolic_name a, 0 [symbolic = %a.loc19_13.1 (constants.%a)]
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {
  67. // CHECK:STDOUT: %b.patt: %pattern_type = binding_pattern b [concrete]
  68. // CHECK:STDOUT: %b.param_patt: %pattern_type = value_param_pattern %b.patt, call_param0 [concrete]
  69. // CHECK:STDOUT: } {
  70. // CHECK:STDOUT: %b.param: %ptr = value_param call_param0
  71. // CHECK:STDOUT: %.loc25: type = splice_block %ptr [concrete = constants.%ptr] {
  72. // CHECK:STDOUT: %Class.ref: type = name_ref Class, file.%Class.decl [concrete = constants.%Class]
  73. // CHECK:STDOUT: %ptr: type = ptr_type %Class.ref [concrete = constants.%ptr]
  74. // CHECK:STDOUT: }
  75. // CHECK:STDOUT: %b: %ptr = bind_name b, %b.param
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  78. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  79. // CHECK:STDOUT: complete_type_witness = %complete_type
  80. // CHECK:STDOUT:
  81. // CHECK:STDOUT: !members:
  82. // CHECK:STDOUT: .Self = constants.%Class
  83. // CHECK:STDOUT: .Class = <poisoned>
  84. // CHECK:STDOUT: .F = %F.decl
  85. // CHECK:STDOUT: .G = %G.decl
  86. // CHECK:STDOUT: }
  87. // CHECK:STDOUT:
  88. // CHECK:STDOUT: generic fn @F(%a.loc19_13.2: %ptr) {
  89. // CHECK:STDOUT: %a.loc19_13.1: %ptr = bind_symbolic_name a, 0 [symbolic = %a.loc19_13.1 (constants.%a)]
  90. // CHECK:STDOUT:
  91. // CHECK:STDOUT: fn();
  92. // CHECK:STDOUT: }
  93. // CHECK:STDOUT:
  94. // CHECK:STDOUT: fn @G(%b.param: %ptr);
  95. // CHECK:STDOUT:
  96. // CHECK:STDOUT: specific @F(constants.%a) {
  97. // CHECK:STDOUT: %a.loc19_13.1 => constants.%a
  98. // CHECK:STDOUT: }
  99. // CHECK:STDOUT: