duplicate_name_same_line.carbon 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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/ir/duplicate_name_same_line.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/ir/duplicate_name_same_line.carbon
  10. fn A() { if (true) { var n: i32 = 1; } if (true) { var n: i32 = 2; } }
  11. // CHECK:STDOUT: --- duplicate_name_same_line.carbon
  12. // CHECK:STDOUT:
  13. // CHECK:STDOUT: constants {
  14. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  15. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  16. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  17. // CHECK:STDOUT: %.2: bool = bool_literal true [template]
  18. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  19. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  20. // CHECK:STDOUT: %.3: i32 = int_literal 1 [template]
  21. // CHECK:STDOUT: %.4: i32 = int_literal 2 [template]
  22. // CHECK:STDOUT: }
  23. // CHECK:STDOUT:
  24. // CHECK:STDOUT: file {
  25. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  26. // CHECK:STDOUT: .Core = %Core
  27. // CHECK:STDOUT: .A = %A.decl
  28. // CHECK:STDOUT: }
  29. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  30. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {}
  31. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  32. // CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: fn @A() {
  36. // CHECK:STDOUT: !entry:
  37. // CHECK:STDOUT: %.loc11_14: bool = bool_literal true [template = constants.%.2]
  38. // CHECK:STDOUT: if %.loc11_14 br !if.then.loc11_18 else br !if.else.loc11_18
  39. // CHECK:STDOUT:
  40. // CHECK:STDOUT: !if.then.loc11_18:
  41. // CHECK:STDOUT: %int.make_type_32.loc11_29: init type = call constants.%Int32() [template = i32]
  42. // CHECK:STDOUT: %.loc11_29.1: type = value_of_initializer %int.make_type_32.loc11_29 [template = i32]
  43. // CHECK:STDOUT: %.loc11_29.2: type = converted %int.make_type_32.loc11_29, %.loc11_29.1 [template = i32]
  44. // CHECK:STDOUT: %n.var.loc11_26: ref i32 = var n
  45. // CHECK:STDOUT: %n.loc11_26: ref i32 = bind_name n, %n.var.loc11_26
  46. // CHECK:STDOUT: %.loc11_35: i32 = int_literal 1 [template = constants.%.3]
  47. // CHECK:STDOUT: assign %n.var.loc11_26, %.loc11_35
  48. // CHECK:STDOUT: br !if.else.loc11_18
  49. // CHECK:STDOUT:
  50. // CHECK:STDOUT: !if.else.loc11_18:
  51. // CHECK:STDOUT: %.loc11_44: bool = bool_literal true [template = constants.%.2]
  52. // CHECK:STDOUT: if %.loc11_44 br !if.then.loc11_48 else br !if.else.loc11_48
  53. // CHECK:STDOUT:
  54. // CHECK:STDOUT: !if.then.loc11_48:
  55. // CHECK:STDOUT: %int.make_type_32.loc11_59: init type = call constants.%Int32() [template = i32]
  56. // CHECK:STDOUT: %.loc11_59.1: type = value_of_initializer %int.make_type_32.loc11_59 [template = i32]
  57. // CHECK:STDOUT: %.loc11_59.2: type = converted %int.make_type_32.loc11_59, %.loc11_59.1 [template = i32]
  58. // CHECK:STDOUT: %n.var.loc11_56: ref i32 = var n
  59. // CHECK:STDOUT: %n.loc11_56: ref i32 = bind_name n, %n.var.loc11_56
  60. // CHECK:STDOUT: %.loc11_65: i32 = int_literal 2 [template = constants.%.4]
  61. // CHECK:STDOUT: assign %n.var.loc11_56, %.loc11_65
  62. // CHECK:STDOUT: br !if.else.loc11_48
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: !if.else.loc11_48:
  65. // CHECK:STDOUT: return
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  69. // CHECK:STDOUT: