left_shift_assign.carbon 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/int.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/builtins/int/left_shift_assign.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/int/left_shift_assign.carbon
  12. // --- call.carbon
  13. library "[[@TEST_NAME]]";
  14. fn Builtin(ref a: i32, b: i32) = "int.left_shift_assign";
  15. fn Call(ref a: i32, b: i32) {
  16. //@dump-sem-ir-begin
  17. Builtin(ref a, b);
  18. //@dump-sem-ir-end
  19. }
  20. fn MixedTypes(ref a: i32, b: i64) = "int.left_shift_assign";
  21. fn CallMixed(ref a: i32, b: i64) {
  22. //@dump-sem-ir-begin
  23. MixedTypes(ref a, b);
  24. //@dump-sem-ir-end
  25. }
  26. // --- fail_unsized.carbon
  27. library "[[@TEST_NAME]]";
  28. // CHECK:STDERR: fail_unsized.carbon:[[@LINE+4]]:1: error: invalid signature for builtin function "int.left_shift_assign" [InvalidBuiltinSignature]
  29. // CHECK:STDERR: fn Builtin(ref a: Core.IntLiteral(), b: Core.IntLiteral()) = "int.left_shift_assign";
  30. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  31. // CHECK:STDERR:
  32. fn Builtin(ref a: Core.IntLiteral(), b: Core.IntLiteral()) = "int.left_shift_assign";
  33. // --- fail_bad_decl.carbon
  34. library "[[@TEST_NAME]]";
  35. // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:1: error: invalid signature for builtin function "int.left_shift_assign" [InvalidBuiltinSignature]
  36. // CHECK:STDERR: fn NotRef(a: i32, b: i32) = "int.left_shift_assign";
  37. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  38. // CHECK:STDERR:
  39. fn NotRef(a: i32, b: i32) = "int.left_shift_assign";
  40. // CHECK:STDOUT: --- call.carbon
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: constants {
  43. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  44. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  45. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  46. // CHECK:STDOUT: %Builtin.type: type = fn_type @Builtin [concrete]
  47. // CHECK:STDOUT: %Builtin: %Builtin.type = struct_value () [concrete]
  48. // CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete]
  49. // CHECK:STDOUT: %i64: type = class_type @Int, @Int(%int_64) [concrete]
  50. // CHECK:STDOUT: %MixedTypes.type: type = fn_type @MixedTypes [concrete]
  51. // CHECK:STDOUT: %MixedTypes: %MixedTypes.type = struct_value () [concrete]
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT:
  54. // CHECK:STDOUT: imports {
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT:
  57. // CHECK:STDOUT: fn @Call(%a.param: %i32, %b.param: %i32) {
  58. // CHECK:STDOUT: !entry:
  59. // CHECK:STDOUT: %Builtin.ref: %Builtin.type = name_ref Builtin, file.%Builtin.decl [concrete = constants.%Builtin]
  60. // CHECK:STDOUT: %a.ref: ref %i32 = name_ref a, %a
  61. // CHECK:STDOUT: %.loc8: %i32 = ref_tag %a.ref
  62. // CHECK:STDOUT: %b.ref: %i32 = name_ref b, %b
  63. // CHECK:STDOUT: %Builtin.call: init %empty_tuple.type = call %Builtin.ref(%.loc8, %b.ref)
  64. // CHECK:STDOUT: <elided>
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT:
  67. // CHECK:STDOUT: fn @CallMixed(%a.param: %i32, %b.param: %i64) {
  68. // CHECK:STDOUT: !entry:
  69. // CHECK:STDOUT: %MixedTypes.ref: %MixedTypes.type = name_ref MixedTypes, file.%MixedTypes.decl [concrete = constants.%MixedTypes]
  70. // CHECK:STDOUT: %a.ref: ref %i32 = name_ref a, %a
  71. // CHECK:STDOUT: %.loc16: %i32 = ref_tag %a.ref
  72. // CHECK:STDOUT: %b.ref: %i64 = name_ref b, %b
  73. // CHECK:STDOUT: %MixedTypes.call: init %empty_tuple.type = call %MixedTypes.ref(%.loc16, %b.ref)
  74. // CHECK:STDOUT: <elided>
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT: