duplicate_name_same_line.carbon 4.2 KB

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