left_shift_assign.carbon 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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(a: i32*, b: i32) = "int.left_shift_assign";
  15. fn Call(a: i32*, b: i32) {
  16. //@dump-sem-ir-begin
  17. Builtin(a, b);
  18. //@dump-sem-ir-end
  19. }
  20. fn MixedTypes(a: i32*, b: i64) = "int.left_shift_assign";
  21. fn CallMixed(a: i32*, b: i64) {
  22. //@dump-sem-ir-begin
  23. MixedTypes(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(a: Core.IntLiteral()*, b: Core.IntLiteral()) = "int.left_shift_assign";
  30. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  31. // CHECK:STDERR:
  32. fn Builtin(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 NotPtr(a: i32, b: i32) = "int.left_shift_assign";
  37. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  38. // CHECK:STDERR:
  39. fn NotPtr(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: %ptr: type = ptr_type %i32 [concrete]
  47. // CHECK:STDOUT: %Builtin.type: type = fn_type @Builtin [concrete]
  48. // CHECK:STDOUT: %Builtin: %Builtin.type = struct_value () [concrete]
  49. // CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete]
  50. // CHECK:STDOUT: %i64: type = class_type @Int, @Int(%int_64) [concrete]
  51. // CHECK:STDOUT: %MixedTypes.type: type = fn_type @MixedTypes [concrete]
  52. // CHECK:STDOUT: %MixedTypes: %MixedTypes.type = struct_value () [concrete]
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT:
  55. // CHECK:STDOUT: imports {
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT:
  58. // CHECK:STDOUT: fn @Call(%a.param: %ptr, %b.param: %i32) {
  59. // CHECK:STDOUT: !entry:
  60. // CHECK:STDOUT: %Builtin.ref: %Builtin.type = name_ref Builtin, file.%Builtin.decl [concrete = constants.%Builtin]
  61. // CHECK:STDOUT: %a.ref: %ptr = name_ref a, %a
  62. // CHECK:STDOUT: %b.ref: %i32 = name_ref b, %b
  63. // CHECK:STDOUT: %Builtin.call: init %empty_tuple.type = call %Builtin.ref(%a.ref, %b.ref)
  64. // CHECK:STDOUT: <elided>
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT:
  67. // CHECK:STDOUT: fn @CallMixed(%a.param: %ptr, %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: %ptr = name_ref a, %a
  71. // CHECK:STDOUT: %b.ref: %i64 = name_ref b, %b
  72. // CHECK:STDOUT: %MixedTypes.call: init %empty_tuple.type = call %MixedTypes.ref(%a.ref, %b.ref)
  73. // CHECK:STDOUT: <elided>
  74. // CHECK:STDOUT: }
  75. // CHECK:STDOUT: