fail_redef.carbon 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/none.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/function/definition/fail_redef.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/definition/fail_redef.carbon
  14. fn F() {}
  15. // CHECK:STDERR: fail_redef.carbon:[[@LINE+7]]:1: error: redefinition of `fn F` [RedeclRedef]
  16. // CHECK:STDERR: fn F() {}
  17. // CHECK:STDERR: ^~~~~~~~
  18. // CHECK:STDERR: fail_redef.carbon:[[@LINE-4]]:1: note: previously defined here [RedeclPrevDef]
  19. // CHECK:STDERR: fn F() {}
  20. // CHECK:STDERR: ^~~~~~~~
  21. // CHECK:STDERR:
  22. fn F() {}
  23. // CHECK:STDOUT: --- fail_redef.carbon
  24. // CHECK:STDOUT:
  25. // CHECK:STDOUT: constants {
  26. // CHECK:STDOUT: %F.type.b25846.1: type = fn_type @F.loc15 [concrete]
  27. // CHECK:STDOUT: %F.c41931.1: %F.type.b25846.1 = struct_value () [concrete]
  28. // CHECK:STDOUT: %F.type.b25846.2: type = fn_type @F.loc23 [concrete]
  29. // CHECK:STDOUT: %F.c41931.2: %F.type.b25846.2 = struct_value () [concrete]
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT:
  32. // CHECK:STDOUT: file {
  33. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  34. // CHECK:STDOUT: .F = %F.decl.loc15
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT: %F.decl.loc15: %F.type.b25846.1 = fn_decl @F.loc15 [concrete = constants.%F.c41931.1] {} {}
  37. // CHECK:STDOUT: %F.decl.loc23: %F.type.b25846.2 = fn_decl @F.loc23 [concrete = constants.%F.c41931.2] {} {}
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT:
  40. // CHECK:STDOUT: fn @F.loc15() {
  41. // CHECK:STDOUT: !entry:
  42. // CHECK:STDOUT: return
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT:
  45. // CHECK:STDOUT: fn @F.loc23() {
  46. // CHECK:STDOUT: !entry:
  47. // CHECK:STDOUT: return
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: