fail_addr_not_self.carbon 4.9 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. // 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
  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+3]]:8: error: `addr` can only be applied to a `self` parameter
  17. // CHECK:STDERR: fn G(addr b: Class*);
  18. // CHECK:STDERR: ^~~~
  19. fn G(addr b: Class*);
  20. }
  21. // CHECK:STDOUT: --- fail_addr_not_self.carbon
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: constants {
  24. // CHECK:STDOUT: %Class: type = class_type @Class [template]
  25. // CHECK:STDOUT: %.1: type = ptr_type %Class [template]
  26. // CHECK:STDOUT: %a: %.1 = bind_symbolic_name a, 0 [symbolic]
  27. // CHECK:STDOUT: %a.patt: %.1 = symbolic_binding_pattern a, 0 [symbolic]
  28. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  29. // CHECK:STDOUT: %.2: type = tuple_type () [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: %.3: type = struct_type {} [template]
  34. // CHECK:STDOUT: %.4: <witness> = complete_type_witness %.3 [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/operators
  41. // CHECK:STDOUT: import Core//prelude/types
  42. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  43. // CHECK:STDOUT: import Core//prelude/operators/as
  44. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  45. // CHECK:STDOUT: import Core//prelude/operators/comparison
  46. // CHECK:STDOUT: import Core//prelude/types/bool
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT:
  50. // CHECK:STDOUT: file {
  51. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  52. // CHECK:STDOUT: .Core = imports.%Core
  53. // CHECK:STDOUT: .Class = %Class.decl
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT: %Core.import = import Core
  56. // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} {}
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: class @Class {
  60. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  61. // CHECK:STDOUT: %a.patt.loc16_13.2: %.1 = symbolic_binding_pattern a, 0 [symbolic = %a.patt.loc16_13.1 (constants.%a.patt)]
  62. // CHECK:STDOUT: %a.param_patt: %.1 = param_pattern %a.patt.loc16_13.2, runtime_param<invalid> [symbolic = %a.patt.loc16_13.1 (constants.%a.patt)]
  63. // CHECK:STDOUT: } {
  64. // CHECK:STDOUT: %Class.ref: type = name_ref Class, file.%Class.decl [template = constants.%Class]
  65. // CHECK:STDOUT: %.loc16: type = ptr_type %Class [template = constants.%.1]
  66. // CHECK:STDOUT: %param: %.1 = param runtime_param<invalid>
  67. // CHECK:STDOUT: %a.loc16_13.2: %.1 = bind_symbolic_name a, 0, %param [symbolic = %a.loc16_13.1 (constants.%a)]
  68. // CHECK:STDOUT: }
  69. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  70. // CHECK:STDOUT: %b.patt: %.1 = binding_pattern b
  71. // CHECK:STDOUT: %b.param_patt: %.1 = param_pattern %b.patt, runtime_param0
  72. // CHECK:STDOUT: } {
  73. // CHECK:STDOUT: %Class.ref: type = name_ref Class, file.%Class.decl [template = constants.%Class]
  74. // CHECK:STDOUT: %.loc21: type = ptr_type %Class [template = constants.%.1]
  75. // CHECK:STDOUT: %param: %.1 = param runtime_param0
  76. // CHECK:STDOUT: %b: %.1 = bind_name b, %param
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT: %.loc22: <witness> = complete_type_witness %.3 [template = constants.%.4]
  79. // CHECK:STDOUT:
  80. // CHECK:STDOUT: !members:
  81. // CHECK:STDOUT: .Self = constants.%Class
  82. // CHECK:STDOUT: .F = %F.decl
  83. // CHECK:STDOUT: .G = %G.decl
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT:
  86. // CHECK:STDOUT: generic fn @F(%a.loc16_13.2: %.1) {
  87. // CHECK:STDOUT: %a.loc16_13.1: %.1 = bind_symbolic_name a, 0 [symbolic = %a.loc16_13.1 (constants.%a)]
  88. // CHECK:STDOUT: %a.patt.loc16_13.1: %.1 = symbolic_binding_pattern a, 0 [symbolic = %a.patt.loc16_13.1 (constants.%a.patt)]
  89. // CHECK:STDOUT:
  90. // CHECK:STDOUT: fn[%a.param_patt: %.1]();
  91. // CHECK:STDOUT: }
  92. // CHECK:STDOUT:
  93. // CHECK:STDOUT: fn @G(%b.param_patt: %.1);
  94. // CHECK:STDOUT:
  95. // CHECK:STDOUT: specific @F(constants.%a) {
  96. // CHECK:STDOUT: %a.loc16_13.1 => constants.%a
  97. // CHECK:STDOUT: %a.patt.loc16_13.1 => constants.%a
  98. // CHECK:STDOUT: }
  99. // CHECK:STDOUT: