parens.carbon 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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: %Int32.type: type = fn_type @Int32 [template]
  16. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  17. // CHECK:STDOUT: %.1: Core.IntLiteral = int_value 1 [template]
  18. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @ImplicitAs(i32) [template]
  19. // CHECK:STDOUT: %Convert.type.15: type = fn_type @Convert.11 [template]
  20. // CHECK:STDOUT: %Convert.15: %Convert.type.15 = struct_value () [template]
  21. // CHECK:STDOUT: %.25: <witness> = interface_witness (%Convert.15) [template]
  22. // CHECK:STDOUT: %.26: <bound method> = bound_method %.1, %Convert.15 [template]
  23. // CHECK:STDOUT: %.27: i32 = int_value 1 [template]
  24. // CHECK:STDOUT: %.28: Core.IntLiteral = int_value 2 [template]
  25. // CHECK:STDOUT: %.29: <bound method> = bound_method %.28, %Convert.15 [template]
  26. // CHECK:STDOUT: %.30: i32 = int_value 2 [template]
  27. // CHECK:STDOUT: }
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: imports {
  30. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  31. // CHECK:STDOUT: .Int32 = %import_ref.1
  32. // CHECK:STDOUT: .ImplicitAs = %import_ref.2
  33. // CHECK:STDOUT: import Core//prelude
  34. // CHECK:STDOUT: import Core//prelude/...
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: file {
  39. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  40. // CHECK:STDOUT: .Core = imports.%Core
  41. // CHECK:STDOUT: .a = %a
  42. // CHECK:STDOUT: .b = %b
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT: %Core.import = import Core
  45. // CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32]
  46. // CHECK:STDOUT: %.loc11_8.1: type = value_of_initializer %int.make_type_32.loc11 [template = i32]
  47. // CHECK:STDOUT: %.loc11_8.2: type = converted %int.make_type_32.loc11, %.loc11_8.1 [template = i32]
  48. // CHECK:STDOUT: %a.var: ref i32 = var a
  49. // CHECK:STDOUT: %a: ref i32 = bind_name a, %a.var
  50. // CHECK:STDOUT: %int.make_type_32.loc12: init type = call constants.%Int32() [template = i32]
  51. // CHECK:STDOUT: %.loc12_8.1: type = value_of_initializer %int.make_type_32.loc12 [template = i32]
  52. // CHECK:STDOUT: %.loc12_8.2: type = converted %int.make_type_32.loc12, %.loc12_8.1 [template = i32]
  53. // CHECK:STDOUT: %b.var: ref i32 = var b
  54. // CHECK:STDOUT: %b: ref i32 = bind_name b, %b.var
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT:
  57. // CHECK:STDOUT: fn @__global_init() {
  58. // CHECK:STDOUT: !entry:
  59. // CHECK:STDOUT: %.loc11_15: Core.IntLiteral = int_value 1 [template = constants.%.1]
  60. // CHECK:STDOUT: %.loc11_17.1: %Convert.type.2 = interface_witness_access constants.%.25, element0 [template = constants.%Convert.15]
  61. // CHECK:STDOUT: %.loc11_17.2: <bound method> = bound_method %.loc11_15, %.loc11_17.1 [template = constants.%.26]
  62. // CHECK:STDOUT: %int.convert_checked.loc11: init i32 = call %.loc11_17.2(%.loc11_15) [template = constants.%.27]
  63. // CHECK:STDOUT: %.loc11_17.3: init i32 = converted %.loc11_15, %int.convert_checked.loc11 [template = constants.%.27]
  64. // CHECK:STDOUT: assign file.%a.var, %.loc11_17.3
  65. // CHECK:STDOUT: %.loc12_16: Core.IntLiteral = int_value 2 [template = constants.%.28]
  66. // CHECK:STDOUT: %.loc12_19.1: %Convert.type.2 = interface_witness_access constants.%.25, element0 [template = constants.%Convert.15]
  67. // CHECK:STDOUT: %.loc12_19.2: <bound method> = bound_method %.loc12_16, %.loc12_19.1 [template = constants.%.29]
  68. // CHECK:STDOUT: %int.convert_checked.loc12: init i32 = call %.loc12_19.2(%.loc12_16) [template = constants.%.30]
  69. // CHECK:STDOUT: %.loc12_19.3: init i32 = converted %.loc12_16, %int.convert_checked.loc12 [template = constants.%.30]
  70. // CHECK:STDOUT: assign file.%b.var, %.loc12_19.3
  71. // CHECK:STDOUT: return
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT: