duplicate_name_same_line.carbon 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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: imports {
  25. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  26. // CHECK:STDOUT: .Int32 = %import_ref
  27. // CHECK:STDOUT: import Core//prelude
  28. // CHECK:STDOUT: import Core//prelude/...
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+15, loaded [template = constants.%Int32]
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: file {
  34. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  35. // CHECK:STDOUT: .Core = imports.%Core
  36. // CHECK:STDOUT: .A = %A.decl
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: %Core.import = import Core
  39. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} {}
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: fn @A() {
  43. // CHECK:STDOUT: !entry:
  44. // CHECK:STDOUT: %.loc11_14: bool = bool_literal true [template = constants.%.2]
  45. // CHECK:STDOUT: if %.loc11_14 br !if.then.loc11_18 else br !if.else.loc11_18
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: !if.then.loc11_18:
  48. // CHECK:STDOUT: %int.make_type_32.loc11_29: init type = call constants.%Int32() [template = i32]
  49. // CHECK:STDOUT: %.loc11_29.1: type = value_of_initializer %int.make_type_32.loc11_29 [template = i32]
  50. // CHECK:STDOUT: %.loc11_29.2: type = converted %int.make_type_32.loc11_29, %.loc11_29.1 [template = i32]
  51. // CHECK:STDOUT: %n.var.loc11_26: ref i32 = var n
  52. // CHECK:STDOUT: %n.loc11_26: ref i32 = bind_name n, %n.var.loc11_26
  53. // CHECK:STDOUT: %.loc11_35: i32 = int_literal 1 [template = constants.%.3]
  54. // CHECK:STDOUT: assign %n.var.loc11_26, %.loc11_35
  55. // CHECK:STDOUT: br !if.else.loc11_18
  56. // CHECK:STDOUT:
  57. // CHECK:STDOUT: !if.else.loc11_18:
  58. // CHECK:STDOUT: %.loc11_44: bool = bool_literal true [template = constants.%.2]
  59. // CHECK:STDOUT: if %.loc11_44 br !if.then.loc11_48 else br !if.else.loc11_48
  60. // CHECK:STDOUT:
  61. // CHECK:STDOUT: !if.then.loc11_48:
  62. // CHECK:STDOUT: %int.make_type_32.loc11_59: init type = call constants.%Int32() [template = i32]
  63. // CHECK:STDOUT: %.loc11_59.1: type = value_of_initializer %int.make_type_32.loc11_59 [template = i32]
  64. // CHECK:STDOUT: %.loc11_59.2: type = converted %int.make_type_32.loc11_59, %.loc11_59.1 [template = i32]
  65. // CHECK:STDOUT: %n.var.loc11_56: ref i32 = var n
  66. // CHECK:STDOUT: %n.loc11_56: ref i32 = bind_name n, %n.var.loc11_56
  67. // CHECK:STDOUT: %.loc11_65: i32 = int_literal 2 [template = constants.%.4]
  68. // CHECK:STDOUT: assign %n.var.loc11_56, %.loc11_65
  69. // CHECK:STDOUT: br !if.else.loc11_48
  70. // CHECK:STDOUT:
  71. // CHECK:STDOUT: !if.else.loc11_48:
  72. // CHECK:STDOUT: return
  73. // CHECK:STDOUT: }
  74. // CHECK:STDOUT:
  75. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  76. // CHECK:STDOUT: