fail_param_redecl.carbon 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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/function/declaration/fail_param_redecl.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/declaration/fail_param_redecl.carbon
  10. // CHECK:STDERR: fail_param_redecl.carbon:[[@LINE+6]]:14: ERROR: Duplicate name being declared in the same scope.
  11. // CHECK:STDERR: fn F(n: i32, n: i32);
  12. // CHECK:STDERR: ^
  13. // CHECK:STDERR: fail_param_redecl.carbon:[[@LINE+3]]:6: Name is previously declared here.
  14. // CHECK:STDERR: fn F(n: i32, n: i32);
  15. // CHECK:STDERR: ^
  16. fn F(n: i32, n: i32);
  17. // CHECK:STDOUT: --- fail_param_redecl.carbon
  18. // CHECK:STDOUT:
  19. // CHECK:STDOUT: constants {
  20. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  21. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  22. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  23. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  24. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  25. // CHECK:STDOUT: }
  26. // CHECK:STDOUT:
  27. // CHECK:STDOUT: file {
  28. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  29. // CHECK:STDOUT: .Core = %Core
  30. // CHECK:STDOUT: .F = %F.decl
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  33. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  34. // CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  35. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  36. // CHECK:STDOUT: %int.make_type_32.loc17_9: init type = call constants.%Int32() [template = i32]
  37. // CHECK:STDOUT: %.loc17_9.1: type = value_of_initializer %int.make_type_32.loc17_9 [template = i32]
  38. // CHECK:STDOUT: %.loc17_9.2: type = converted %int.make_type_32.loc17_9, %.loc17_9.1 [template = i32]
  39. // CHECK:STDOUT: %n.loc17_6.1: i32 = param n
  40. // CHECK:STDOUT: @F.%n.loc17_6: i32 = bind_name n, %n.loc17_6.1
  41. // CHECK:STDOUT: %int.make_type_32.loc17_17: init type = call constants.%Int32() [template = i32]
  42. // CHECK:STDOUT: %.loc17_17.1: type = value_of_initializer %int.make_type_32.loc17_17 [template = i32]
  43. // CHECK:STDOUT: %.loc17_17.2: type = converted %int.make_type_32.loc17_17, %.loc17_17.1 [template = i32]
  44. // CHECK:STDOUT: %n.loc17_14.1: i32 = param n
  45. // CHECK:STDOUT: @F.%n.loc17_14: i32 = bind_name n, %n.loc17_14.1
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  50. // CHECK:STDOUT:
  51. // CHECK:STDOUT: fn @F(%n.loc17_6: i32, %n.loc17_14: i32);
  52. // CHECK:STDOUT: