parens.carbon 4.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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: %int_32: Core.IntLiteral = int_value 32 [template]
  16. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  17. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [template]
  18. // CHECK:STDOUT: %Convert.type.cd1: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  19. // CHECK:STDOUT: %impl_witness.5b0: <witness> = impl_witness (imports.%import_ref.723), @impl.1(%int_32) [template]
  20. // CHECK:STDOUT: %Convert.type.466: type = fn_type @Convert.2, @impl.1(%int_32) [template]
  21. // CHECK:STDOUT: %Convert.925: %Convert.type.466 = struct_value () [template]
  22. // CHECK:STDOUT: %Convert.bound.afd: <bound method> = bound_method %int_1.5b8, %Convert.925 [template]
  23. // CHECK:STDOUT: %Convert.specific_fn.b73: <specific function> = specific_function %Convert.bound.afd, @Convert.2(%int_32) [template]
  24. // CHECK:STDOUT: %int_1.c60: %i32 = int_value 1 [template]
  25. // CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [template]
  26. // CHECK:STDOUT: %Convert.bound.f0b: <bound method> = bound_method %int_2.ecc, %Convert.925 [template]
  27. // CHECK:STDOUT: %Convert.specific_fn.20e: <specific function> = specific_function %Convert.bound.f0b, @Convert.2(%int_32) [template]
  28. // CHECK:STDOUT: %int_2.166: %i32 = int_value 2 [template]
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT:
  31. // CHECK:STDOUT: imports {
  32. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  33. // CHECK:STDOUT: .Int = %import_ref.187
  34. // CHECK:STDOUT: .ImplicitAs = %import_ref.a69
  35. // CHECK:STDOUT: import Core//prelude
  36. // CHECK:STDOUT: import Core//prelude/...
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT:
  40. // CHECK:STDOUT: file {
  41. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  42. // CHECK:STDOUT: .Core = imports.%Core
  43. // CHECK:STDOUT: .a = %a
  44. // CHECK:STDOUT: .b = %b
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT: %Core.import = import Core
  47. // CHECK:STDOUT: %a.var: ref %i32 = var a
  48. // CHECK:STDOUT: %a: ref %i32 = bind_name a, %a.var
  49. // CHECK:STDOUT: %b.var: ref %i32 = var b
  50. // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: fn @__global_init() {
  54. // CHECK:STDOUT: !entry:
  55. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8]
  56. // CHECK:STDOUT: %impl.elem0.loc11: %Convert.type.cd1 = impl_witness_access constants.%impl_witness.5b0, element0 [template = constants.%Convert.925]
  57. // CHECK:STDOUT: %Convert.bound.loc11: <bound method> = bound_method %int_1, %impl.elem0.loc11 [template = constants.%Convert.bound.afd]
  58. // CHECK:STDOUT: %Convert.specific_fn.loc11: <specific function> = specific_function %Convert.bound.loc11, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.b73]
  59. // CHECK:STDOUT: %int.convert_checked.loc11: init %i32 = call %Convert.specific_fn.loc11(%int_1) [template = constants.%int_1.c60]
  60. // CHECK:STDOUT: %.loc11: init %i32 = converted %int_1, %int.convert_checked.loc11 [template = constants.%int_1.c60]
  61. // CHECK:STDOUT: assign file.%a.var, %.loc11
  62. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc]
  63. // CHECK:STDOUT: %impl.elem0.loc12: %Convert.type.cd1 = impl_witness_access constants.%impl_witness.5b0, element0 [template = constants.%Convert.925]
  64. // CHECK:STDOUT: %Convert.bound.loc12: <bound method> = bound_method %int_2, %impl.elem0.loc12 [template = constants.%Convert.bound.f0b]
  65. // CHECK:STDOUT: %Convert.specific_fn.loc12: <specific function> = specific_function %Convert.bound.loc12, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.20e]
  66. // CHECK:STDOUT: %int.convert_checked.loc12: init %i32 = call %Convert.specific_fn.loc12(%int_2) [template = constants.%int_2.166]
  67. // CHECK:STDOUT: %.loc12: init %i32 = converted %int_2, %int.convert_checked.loc12 [template = constants.%int_2.166]
  68. // CHECK:STDOUT: assign file.%b.var, %.loc12
  69. // CHECK:STDOUT: return
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT: