fail_redef.carbon 2.0 KB

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