redeclaration.carbon 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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/redeclaration.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/redeclaration.carbon
  10. class Class;
  11. class Class {
  12. fn F[self: Self](b: bool);
  13. }
  14. fn Class.F[self: Self](b: bool) {}
  15. // CHECK:STDOUT: --- redeclaration.carbon
  16. // CHECK:STDOUT:
  17. // CHECK:STDOUT: constants {
  18. // CHECK:STDOUT: %Class: type = class_type @Class [template]
  19. // CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template]
  20. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  21. // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template]
  22. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  23. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  24. // CHECK:STDOUT: %.2: type = struct_type {} [template]
  25. // CHECK:STDOUT: %.3: type = ptr_type %.2 [template]
  26. // CHECK:STDOUT: }
  27. // CHECK:STDOUT:
  28. // CHECK:STDOUT: file {
  29. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  30. // CHECK:STDOUT: .Core = %Core
  31. // CHECK:STDOUT: .Class = %Class.decl.loc11
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  34. // CHECK:STDOUT: %Class.decl.loc11: type = class_decl @Class [template = constants.%Class] {}
  35. // CHECK:STDOUT: %Class.decl.loc13: type = class_decl @Class [template = constants.%Class] {}
  36. // CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool]
  37. // CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool]
  38. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  39. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Class [template = constants.%Class]
  40. // CHECK:STDOUT: %self.loc17_12.1: %Class = param self
  41. // CHECK:STDOUT: @F.%self: %Class = bind_name self, %self.loc17_12.1
  42. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  43. // CHECK:STDOUT: %.loc17_27.1: type = value_of_initializer %bool.make_type [template = bool]
  44. // CHECK:STDOUT: %.loc17_27.2: type = converted %bool.make_type, %.loc17_27.1 [template = bool]
  45. // CHECK:STDOUT: %b.loc17_24.1: bool = param b
  46. // CHECK:STDOUT: @F.%b: bool = bind_name b, %b.loc17_24.1
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT:
  50. // CHECK:STDOUT: class @Class {
  51. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  52. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Class [template = constants.%Class]
  53. // CHECK:STDOUT: %self.loc14_8.1: %Class = param self
  54. // CHECK:STDOUT: %self.loc14_8.2: %Class = bind_name self, %self.loc14_8.1
  55. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  56. // CHECK:STDOUT: %.loc14_23.1: type = value_of_initializer %bool.make_type [template = bool]
  57. // CHECK:STDOUT: %.loc14_23.2: type = converted %bool.make_type, %.loc14_23.1 [template = bool]
  58. // CHECK:STDOUT: %b.loc14_20.1: bool = param b
  59. // CHECK:STDOUT: %b.loc14_20.2: bool = bind_name b, %b.loc14_20.1
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: !members:
  63. // CHECK:STDOUT: .Self = constants.%Class
  64. // CHECK:STDOUT: .F = %F.decl
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT:
  67. // CHECK:STDOUT: fn @Bool() -> type = "bool.make_type";
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: fn @F[%self: %Class](%b: bool) {
  70. // CHECK:STDOUT: !entry:
  71. // CHECK:STDOUT: return
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT: