fail_addr_not_self.carbon 5.0 KB

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