fail_addr_not_self.carbon 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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: %F.type: type = fn_type @F [template]
  27. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  28. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  29. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  30. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  31. // CHECK:STDOUT: %.3: type = struct_type {} [template]
  32. // CHECK:STDOUT: %.4: <witness> = complete_type_witness %.3 [template]
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: imports {
  36. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  37. // CHECK:STDOUT: import Core//prelude
  38. // CHECK:STDOUT: import Core//prelude/operators
  39. // CHECK:STDOUT: import Core//prelude/types
  40. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  41. // CHECK:STDOUT: import Core//prelude/operators/as
  42. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  43. // CHECK:STDOUT: import Core//prelude/operators/comparison
  44. // CHECK:STDOUT: import Core//prelude/types/bool
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: file {
  49. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  50. // CHECK:STDOUT: .Core = imports.%Core
  51. // CHECK:STDOUT: .Class = %Class.decl
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT: %Core.import = import Core
  54. // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} {}
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT:
  57. // CHECK:STDOUT: class @Class {
  58. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  59. // CHECK:STDOUT: %a.patt: %.1 = binding_pattern a
  60. // CHECK:STDOUT: } {
  61. // CHECK:STDOUT: %Class.ref: type = name_ref Class, file.%Class.decl [template = constants.%Class]
  62. // CHECK:STDOUT: %.loc16: type = ptr_type %Class [template = constants.%.1]
  63. // CHECK:STDOUT: %a.param: %.1 = param a, runtime_param0
  64. // CHECK:STDOUT: %a: %.1 = bind_name a, %a.param
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  67. // CHECK:STDOUT: %b.patt: %.1 = binding_pattern b
  68. // CHECK:STDOUT: } {
  69. // CHECK:STDOUT: %Class.ref: type = name_ref Class, file.%Class.decl [template = constants.%Class]
  70. // CHECK:STDOUT: %.loc21: type = ptr_type %Class [template = constants.%.1]
  71. // CHECK:STDOUT: %b.param: %.1 = param b, runtime_param0
  72. // CHECK:STDOUT: %b: %.1 = bind_name b, %b.param
  73. // CHECK:STDOUT: }
  74. // CHECK:STDOUT: %.loc22: <witness> = complete_type_witness %.3 [template = constants.%.4]
  75. // CHECK:STDOUT:
  76. // CHECK:STDOUT: !members:
  77. // CHECK:STDOUT: .Self = constants.%Class
  78. // CHECK:STDOUT: .F = %F.decl
  79. // CHECK:STDOUT: .G = %G.decl
  80. // CHECK:STDOUT: }
  81. // CHECK:STDOUT:
  82. // CHECK:STDOUT: fn @F[%a: %.1]();
  83. // CHECK:STDOUT:
  84. // CHECK:STDOUT: fn @G(%b: %.1);
  85. // CHECK:STDOUT: