1*478d831aSmrg# $NetBSD: t_ubsan_int_add_overflow.sh,v 1.5 2019/02/09 00:13:19 mrg Exp $ 2*478d831aSmrg# 39bce57c1Smgorny# Copyright (c) 2018, 2019 The NetBSD Foundation, Inc. 45d8fa03fSkamil# All rights reserved. 55d8fa03fSkamil# 65d8fa03fSkamil# This code is derived from software contributed to The NetBSD Foundation 75d8fa03fSkamil# by Harry Pantazis. 85d8fa03fSkamil# 95d8fa03fSkamil# Redistribution and use in source and binary forms, with or without 105d8fa03fSkamil# modification, are permitted provided that the following conditions 115d8fa03fSkamil# are met: 125d8fa03fSkamil# 1. Redistributions of source code must retain the above copyright 135d8fa03fSkamil# notice, this list of conditions and the following disclaimer. 145d8fa03fSkamil# 2. Redistributions in binary form must reproduce the above copyright 155d8fa03fSkamil# notice, this list of conditions and the following disclaimer in the 165d8fa03fSkamil# documentation and/or other materials provided with the distribution. 175d8fa03fSkamil# 185d8fa03fSkamil# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 195d8fa03fSkamil# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 205d8fa03fSkamil# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 215d8fa03fSkamil# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 225d8fa03fSkamil# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 235d8fa03fSkamil# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 245d8fa03fSkamil# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 255d8fa03fSkamil# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 265d8fa03fSkamil# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 275d8fa03fSkamil# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 285d8fa03fSkamil# POSSIBILITY OF SUCH DAMAGE. 295d8fa03fSkamil# 305d8fa03fSkamil 319bce57c1SmgornyUBSAN_CODE=' 325d8fa03fSkamil#include <limits.h> 335d8fa03fSkamil#include <stdio.h> 345d8fa03fSkamil#include <stdlib.h> 355d8fa03fSkamilint help(int); 369bce57c1Smgorny#ifndef PIC_MAIN 375d8fa03fSkamilint help(int count) {volatile int l = INT_MAX; l+= count; return l;} 389bce57c1Smgorny#endif 399bce57c1Smgorny#ifndef PIC_FOO 405d8fa03fSkamilint main(int argc, char **argv) {volatile int l = INT_MAX; l+=argc; return l;} 419bce57c1Smgorny#endif 429bce57c1Smgorny' 435d8fa03fSkamil 449bce57c1Smgornyubsan_test_case int_add_overflow "int addition overflows" \ 459bce57c1Smgorny "signed integer overflow" 465d8fa03fSkamil 475d8fa03fSkamilatf_init_test_cases() 485d8fa03fSkamil{ 499bce57c1Smgorny ubsan_add_test_cases int_add_overflow 505d8fa03fSkamil} 51