fail_method_redefinition.carbon 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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_method_redefinition.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/fail_method_redefinition.carbon
  10. class Class {
  11. fn F() {}
  12. // CHECK:STDERR: fail_method_redefinition.carbon:[[@LINE+6]]:3: ERROR: Redefinition of `fn F`.
  13. // CHECK:STDERR: fn F() {}
  14. // CHECK:STDERR: ^~~~~~~~
  15. // CHECK:STDERR: fail_method_redefinition.carbon:[[@LINE-4]]:3: Previously defined here.
  16. // CHECK:STDERR: fn F() {}
  17. // CHECK:STDERR: ^~~~~~~~
  18. fn F() {}
  19. }
  20. // CHECK:STDOUT: --- fail_method_redefinition.carbon
  21. // CHECK:STDOUT:
  22. // CHECK:STDOUT: constants {
  23. // CHECK:STDOUT: %Class: type = class_type @Class [template]
  24. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  25. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  26. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  27. // CHECK:STDOUT: %.2: 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.loc12: %F.type = fn_decl @F [template = constants.%F] {}
  41. // CHECK:STDOUT: %F.decl.loc19: %F.type = fn_decl @F [template = constants.%F] {}
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: !members:
  44. // CHECK:STDOUT: .Self = constants.%Class
  45. // CHECK:STDOUT: .F = %F.decl.loc12
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: fn @F() {
  49. // CHECK:STDOUT: !entry:
  50. // CHECK:STDOUT: return
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: !.loc19:
  53. // CHECK:STDOUT: return
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT: