fail_addr_not_self.carbon 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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: }
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: file {
  35. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  36. // CHECK:STDOUT: .Core = %Core
  37. // CHECK:STDOUT: .Class = %Class.decl
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  40. // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {}
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: class @Class {
  44. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  45. // CHECK:STDOUT: %Class.ref.loc16: type = name_ref Class, file.%Class.decl [template = constants.%Class]
  46. // CHECK:STDOUT: %.loc16: type = ptr_type %Class [template = constants.%.1]
  47. // CHECK:STDOUT: %a.loc16_13.1: %.1 = param a
  48. // CHECK:STDOUT: %a.loc16_13.2: %.1 = bind_name a, %a.loc16_13.1
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  51. // CHECK:STDOUT: %Class.ref.loc21: type = name_ref Class, file.%Class.decl [template = constants.%Class]
  52. // CHECK:STDOUT: %.loc21: type = ptr_type %Class [template = constants.%.1]
  53. // CHECK:STDOUT: %b.loc21_13.1: %.1 = param b
  54. // CHECK:STDOUT: %b.loc21_13.2: %.1 = bind_name b, %b.loc21_13.1
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT:
  57. // CHECK:STDOUT: !members:
  58. // CHECK:STDOUT: .Self = constants.%Class
  59. // CHECK:STDOUT: .F = %F.decl
  60. // CHECK:STDOUT: .G = %G.decl
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT:
  63. // CHECK:STDOUT: fn @F[@Class.%a.loc16_13.2: %.1]();
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: fn @G(@Class.%b.loc21_13.2: %.1);
  66. // CHECK:STDOUT: