fail_addr_not_self.carbon 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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: %F: type = fn_type @F [template]
  23. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  24. // CHECK:STDOUT: %struct.1: F = struct_value () [template]
  25. // CHECK:STDOUT: %G: type = fn_type @G [template]
  26. // CHECK:STDOUT: %struct.2: G = struct_value () [template]
  27. // CHECK:STDOUT: %.3: type = struct_type {} [template]
  28. // CHECK:STDOUT: }
  29. // CHECK:STDOUT:
  30. // CHECK:STDOUT: file {
  31. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  32. // CHECK:STDOUT: .Core = %Core
  33. // CHECK:STDOUT: .Class = %Class.decl
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  36. // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {}
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT:
  39. // CHECK:STDOUT: class @Class {
  40. // CHECK:STDOUT: %F.decl: F = fn_decl @F [template = constants.%struct.1] {
  41. // CHECK:STDOUT: %Class.ref.loc12: type = name_ref Class, file.%Class.decl [template = constants.%Class]
  42. // CHECK:STDOUT: %.loc12: type = ptr_type Class [template = constants.%.1]
  43. // CHECK:STDOUT: %a.loc12_13.1: Class* = param a
  44. // CHECK:STDOUT: %a.loc12_13.2: Class* = bind_name a, %a.loc12_13.1
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT: %G.decl: G = fn_decl @G [template = constants.%struct.2] {
  47. // CHECK:STDOUT: %Class.ref.loc17: type = name_ref Class, file.%Class.decl [template = constants.%Class]
  48. // CHECK:STDOUT: %.loc17: type = ptr_type Class [template = constants.%.1]
  49. // CHECK:STDOUT: %b.loc17_13.1: Class* = param b
  50. // CHECK:STDOUT: %b.loc17_13.2: Class* = bind_name b, %b.loc17_13.1
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: !members:
  54. // CHECK:STDOUT: .Self = constants.%Class
  55. // CHECK:STDOUT: .F = %F.decl
  56. // CHECK:STDOUT: .G = %G.decl
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: fn @F[@Class.%a.loc12_13.2: Class*]();
  60. // CHECK:STDOUT:
  61. // CHECK:STDOUT: fn @G(@Class.%b.loc17_13.2: Class*);
  62. // CHECK:STDOUT: