parens.carbon 5.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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/basics/parens.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/basics/parens.carbon
  10. var a: i32 = (1);
  11. var b: i32 = ((2));
  12. // CHECK:STDOUT: --- parens.carbon
  13. // CHECK:STDOUT:
  14. // CHECK:STDOUT: constants {
  15. // CHECK:STDOUT: %.1: Core.IntLiteral = int_value 32 [template]
  16. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  17. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  18. // CHECK:STDOUT: %i32: type = int_type signed, %.1 [template]
  19. // CHECK:STDOUT: %.2: Core.IntLiteral = int_value 1 [template]
  20. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  21. // CHECK:STDOUT: %Convert.type.14: type = fn_type @Convert.2, @impl.1(%.1) [template]
  22. // CHECK:STDOUT: %Convert.14: %Convert.type.14 = struct_value () [template]
  23. // CHECK:STDOUT: %.26: <witness> = interface_witness (%Convert.14) [template]
  24. // CHECK:STDOUT: %.27: <bound method> = bound_method %.2, %Convert.14 [template]
  25. // CHECK:STDOUT: %.28: <specific function> = specific_function %.27, @Convert.2(%.1) [template]
  26. // CHECK:STDOUT: %.29: %i32 = int_value 1 [template]
  27. // CHECK:STDOUT: %.30: Core.IntLiteral = int_value 2 [template]
  28. // CHECK:STDOUT: %.31: <bound method> = bound_method %.30, %Convert.14 [template]
  29. // CHECK:STDOUT: %.32: <specific function> = specific_function %.31, @Convert.2(%.1) [template]
  30. // CHECK:STDOUT: %.33: %i32 = int_value 2 [template]
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: imports {
  34. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  35. // CHECK:STDOUT: .Int = %import_ref.1
  36. // CHECK:STDOUT: .ImplicitAs = %import_ref.2
  37. // CHECK:STDOUT: import Core//prelude
  38. // CHECK:STDOUT: import Core//prelude/...
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: file {
  43. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  44. // CHECK:STDOUT: .Core = imports.%Core
  45. // CHECK:STDOUT: .a = %a
  46. // CHECK:STDOUT: .b = %b
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT: %Core.import = import Core
  49. // CHECK:STDOUT: %.loc11_8.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  50. // CHECK:STDOUT: %int.make_type_signed.loc11: init type = call constants.%Int(%.loc11_8.1) [template = constants.%i32]
  51. // CHECK:STDOUT: %.loc11_8.2: type = value_of_initializer %int.make_type_signed.loc11 [template = constants.%i32]
  52. // CHECK:STDOUT: %.loc11_8.3: type = converted %int.make_type_signed.loc11, %.loc11_8.2 [template = constants.%i32]
  53. // CHECK:STDOUT: %a.var: ref %i32 = var a
  54. // CHECK:STDOUT: %a: ref %i32 = bind_name a, %a.var
  55. // CHECK:STDOUT: %.loc12_8.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  56. // CHECK:STDOUT: %int.make_type_signed.loc12: init type = call constants.%Int(%.loc12_8.1) [template = constants.%i32]
  57. // CHECK:STDOUT: %.loc12_8.2: type = value_of_initializer %int.make_type_signed.loc12 [template = constants.%i32]
  58. // CHECK:STDOUT: %.loc12_8.3: type = converted %int.make_type_signed.loc12, %.loc12_8.2 [template = constants.%i32]
  59. // CHECK:STDOUT: %b.var: ref %i32 = var b
  60. // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT:
  63. // CHECK:STDOUT: fn @__global_init() {
  64. // CHECK:STDOUT: !entry:
  65. // CHECK:STDOUT: %.loc11_15: Core.IntLiteral = int_value 1 [template = constants.%.2]
  66. // CHECK:STDOUT: %.loc11_17.1: %Convert.type.2 = interface_witness_access constants.%.26, element0 [template = constants.%Convert.14]
  67. // CHECK:STDOUT: %.loc11_17.2: <bound method> = bound_method %.loc11_15, %.loc11_17.1 [template = constants.%.27]
  68. // CHECK:STDOUT: %.loc11_17.3: <specific function> = specific_function %.loc11_17.2, @Convert.2(constants.%.1) [template = constants.%.28]
  69. // CHECK:STDOUT: %int.convert_checked.loc11: init %i32 = call %.loc11_17.3(%.loc11_15) [template = constants.%.29]
  70. // CHECK:STDOUT: %.loc11_17.4: init %i32 = converted %.loc11_15, %int.convert_checked.loc11 [template = constants.%.29]
  71. // CHECK:STDOUT: assign file.%a.var, %.loc11_17.4
  72. // CHECK:STDOUT: %.loc12_16: Core.IntLiteral = int_value 2 [template = constants.%.30]
  73. // CHECK:STDOUT: %.loc12_19.1: %Convert.type.2 = interface_witness_access constants.%.26, element0 [template = constants.%Convert.14]
  74. // CHECK:STDOUT: %.loc12_19.2: <bound method> = bound_method %.loc12_16, %.loc12_19.1 [template = constants.%.31]
  75. // CHECK:STDOUT: %.loc12_19.3: <specific function> = specific_function %.loc12_19.2, @Convert.2(constants.%.1) [template = constants.%.32]
  76. // CHECK:STDOUT: %int.convert_checked.loc12: init %i32 = call %.loc12_19.3(%.loc12_16) [template = constants.%.33]
  77. // CHECK:STDOUT: %.loc12_19.4: init %i32 = converted %.loc12_16, %int.convert_checked.loc12 [template = constants.%.33]
  78. // CHECK:STDOUT: assign file.%b.var, %.loc12_19.4
  79. // CHECK:STDOUT: return
  80. // CHECK:STDOUT: }
  81. // CHECK:STDOUT: