// 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 // // EXTRA-ARGS: --no-dump-sem-ir // // AUTOUPDATE // TIP: To test this file alone, run: // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/builtins/int/ssub.carbon // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/int/ssub.carbon // --- int_sub.carbon fn Sub(a: i32, b: i32) -> i32 = "int.ssub"; var arr: [i32; Sub(3, 2)]; let arr_p: [i32; 1]* = &arr; fn RuntimeCallIsValid(a: i32, b: i32) -> i32 { return Sub(a, b); } // --- fail_overflow.carbon package FailOverflow; fn Sub(a: i32, b: i32) -> i32 = "int.ssub"; let a: i32 = Sub(0, 0x7FFFFFFF); let b: i32 = Sub(Sub(0, 0x7FFFFFFF), 1); // CHECK:STDERR: fail_overflow.carbon:[[@LINE+3]]:14: error: integer overflow in calculation `-2147483647 - 2` [CompileTimeIntegerOverflow] // CHECK:STDERR: let c: i32 = Sub(Sub(0, 0x7FFFFFFF), 2); // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~ let c: i32 = Sub(Sub(0, 0x7FFFFFFF), 2);