fail_addr_not_self.carbon 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. class Class {
  7. // CHECK:STDERR: fail_addr_not_self.carbon:[[@LINE+4]]:8: ERROR: `addr` can only be applied to a `self` parameter.
  8. // CHECK:STDERR: fn F[addr a: Class*]();
  9. // CHECK:STDERR: ^~~~
  10. // CHECK:STDERR:
  11. fn F[addr a: Class*]();
  12. // CHECK:STDERR: fail_addr_not_self.carbon:[[@LINE+3]]:8: ERROR: `addr` can only be applied to a `self` parameter.
  13. // CHECK:STDERR: fn G(addr b: Class*);
  14. // CHECK:STDERR: ^~~~
  15. fn G(addr b: Class*);
  16. }
  17. // CHECK:STDOUT: --- fail_addr_not_self.carbon
  18. // CHECK:STDOUT:
  19. // CHECK:STDOUT: constants {
  20. // CHECK:STDOUT: %Class: type = class_type @Class [template]
  21. // CHECK:STDOUT: %.1: type = ptr_type Class [template]
  22. // CHECK:STDOUT: %.2: type = struct_type {} [template]
  23. // CHECK:STDOUT: }
  24. // CHECK:STDOUT:
  25. // CHECK:STDOUT: file {
  26. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  27. // CHECK:STDOUT: .Core = %Core
  28. // CHECK:STDOUT: .Class = %Class.decl
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  31. // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {}
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: class @Class {
  35. // CHECK:STDOUT: %F: <function> = fn_decl @F [template] {
  36. // CHECK:STDOUT: %Class.ref.loc12: type = name_ref Class, file.%Class.decl [template = constants.%Class]
  37. // CHECK:STDOUT: %.loc12: type = ptr_type Class [template = constants.%.1]
  38. // CHECK:STDOUT: %a.loc12_13.1: Class* = param a
  39. // CHECK:STDOUT: %a.loc12_13.2: Class* = bind_name a, %a.loc12_13.1
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT: %G: <function> = fn_decl @G [template] {
  42. // CHECK:STDOUT: %Class.ref.loc17: type = name_ref Class, file.%Class.decl [template = constants.%Class]
  43. // CHECK:STDOUT: %.loc17: type = ptr_type Class [template = constants.%.1]
  44. // CHECK:STDOUT: %b.loc17_13.1: Class* = param b
  45. // CHECK:STDOUT: %b.loc17_13.2: Class* = bind_name b, %b.loc17_13.1
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: !members:
  49. // CHECK:STDOUT: .Self = constants.%Class
  50. // CHECK:STDOUT: .F = %F
  51. // CHECK:STDOUT: .G = %G
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT:
  54. // CHECK:STDOUT: fn @F[@Class.%a.loc12_13.2: Class*]();
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: fn @G(@Class.%b.loc17_13.2: Class*);
  57. // CHECK:STDOUT: