mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-24 02:32:42 +00:00
Also add SemIR ranges to observe test, removing 5K lines of uninteresting SemIR output.
87 lines
3.6 KiB
Plaintext
87 lines
3.6 KiB
Plaintext
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/int.carbon
|
|
//
|
|
// AUTOUPDATE
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/builtins/int/left_shift_assign.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/int/left_shift_assign.carbon
|
|
|
|
// --- call.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
fn Builtin(ref a: i32, b: i32) = "int.left_shift_assign";
|
|
|
|
fn Call(ref a: i32, b: i32) {
|
|
//@dump-sem-ir-begin
|
|
Builtin(ref a, b);
|
|
//@dump-sem-ir-end
|
|
}
|
|
|
|
fn MixedTypes(ref a: i32, b: i64) = "int.left_shift_assign";
|
|
|
|
fn CallMixed(ref a: i32, b: i64) {
|
|
//@dump-sem-ir-begin
|
|
MixedTypes(ref a, b);
|
|
//@dump-sem-ir-end
|
|
}
|
|
|
|
// --- fail_unsized.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
// CHECK:STDERR: fail_unsized.carbon:[[@LINE+4]]:1: error: invalid signature for builtin function "int.left_shift_assign" [InvalidBuiltinSignature]
|
|
// CHECK:STDERR: fn Builtin(ref a: Core.IntLiteral, b: Core.IntLiteral) = "int.left_shift_assign";
|
|
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// CHECK:STDERR:
|
|
fn Builtin(ref a: Core.IntLiteral, b: Core.IntLiteral) = "int.left_shift_assign";
|
|
|
|
// --- fail_bad_decl.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:1: error: invalid signature for builtin function "int.left_shift_assign" [InvalidBuiltinSignature]
|
|
// CHECK:STDERR: fn NotRef(a: i32, b: i32) = "int.left_shift_assign";
|
|
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// CHECK:STDERR:
|
|
fn NotRef(a: i32, b: i32) = "int.left_shift_assign";
|
|
|
|
// CHECK:STDOUT: --- call.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
|
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
|
|
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
|
|
// CHECK:STDOUT: %Builtin.type: type = fn_type @Builtin [concrete]
|
|
// CHECK:STDOUT: %Builtin: %Builtin.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete]
|
|
// CHECK:STDOUT: %i64: type = class_type @Int, @Int(%int_64) [concrete]
|
|
// CHECK:STDOUT: %MixedTypes.type: type = fn_type @MixedTypes [concrete]
|
|
// CHECK:STDOUT: %MixedTypes: %MixedTypes.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Call(%a.param: ref %i32, %b.param: %i32) {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %Builtin.ref: %Builtin.type = name_ref Builtin, file.%Builtin.decl [concrete = constants.%Builtin]
|
|
// CHECK:STDOUT: %a.ref: ref %i32 = name_ref a, %a
|
|
// CHECK:STDOUT: %.loc8: %i32 = ref_tag %a.ref
|
|
// CHECK:STDOUT: %b.ref: %i32 = name_ref b, %b
|
|
// CHECK:STDOUT: %Builtin.call: init %empty_tuple.type = call %Builtin.ref(%a.ref, %b.ref)
|
|
// CHECK:STDOUT: <elided>
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @CallMixed(%a.param: ref %i32, %b.param: %i64) {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %MixedTypes.ref: %MixedTypes.type = name_ref MixedTypes, file.%MixedTypes.decl [concrete = constants.%MixedTypes]
|
|
// CHECK:STDOUT: %a.ref: ref %i32 = name_ref a, %a
|
|
// CHECK:STDOUT: %.loc16: %i32 = ref_tag %a.ref
|
|
// CHECK:STDOUT: %b.ref: %i64 = name_ref b, %b
|
|
// CHECK:STDOUT: %MixedTypes.call: init %empty_tuple.type = call %MixedTypes.ref(%a.ref, %b.ref)
|
|
// CHECK:STDOUT: <elided>
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|