From patchwork Thu Feb 14 11:08:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1042010 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-496081-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="D3bBVXNG"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 440YYs0t6fz9sMp for ; Thu, 14 Feb 2019 22:09:16 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=TfhWR1f+pkcrEul5v TATleWqiUyDIyg0Tp3RsvUf7bq/fe96foTTvYgqqHVV1HNnAeU/5sEcgtL8SmDCi MYqM3rLOQcVCnpDUJEnbW+++Yaol2RLVp3bBWTs6X1sZMXjkdHth6eRXQ2w9OA+p npyS9amOIPynzSQqHgEQpb0i74= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:references:mime-version :content-type:in-reply-to; s=default; bh=pUBUu2SSII7hyIFsxX5GDF+ bPx4=; b=D3bBVXNGOZ/ZXN49ZY3efkfHn25BL3YIBoE4hH/uXPjfGlsLyZhauji Bw+9vuDz1r/ZhNDkb+x/yYg6E7H9uLuzy32OpZFSBKDjccR0RLDnSX6gVneYhd4C j71STgV6BXwWDfkZGDHnrsQC4bgNUljW+yalSecSvxSN9DWjqGhs= Received: (qmail 1089 invoked by alias); 14 Feb 2019 11:09:09 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 1078 invoked by uid 89); 14 Feb 2019 11:09:09 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=ubsanexp, UD:ubsan.exp, ubsan.exp X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 14 Feb 2019 11:09:07 +0000 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 001DDC079C4C; Thu, 14 Feb 2019 11:09:05 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-88.ams2.redhat.com [10.36.116.88]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8ABA31019601; Thu, 14 Feb 2019 11:09:05 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id x1EB92Qs025663; Thu, 14 Feb 2019 12:09:02 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id x1EB8xXM025662; Thu, 14 Feb 2019 12:08:59 +0100 Date: Thu, 14 Feb 2019 12:08:59 +0100 From: Jakub Jelinek To: Rainer Orth , Mike Stump , "Joseph S. Myers" , "H.J. Lu" Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Add testcases for multiple -fsanitize=, -fno-sanitize= or -fno-sanitize-recover= options Message-ID: <20190214110859.GI2135@tucnak> Reply-To: Jakub Jelinek References: <20190212234028.GS2135@tucnak> <20190213074345.GU2135@tucnak> <20190213080223.GV2135@tucnak> <20190213231553.GF2135@tucnak> <20190214022751.GA27998@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190214022751.GA27998@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-IsSubscribed: yes Hi! The following patch adds testcase coverage to make sure -f{,no-}sanitize{,-recover}= options are all passed to the compiler backend from the driver. All these tests were broken by the earlier option handling patch from H.J.: https://gcc.gnu.org/ml/gcc-patches/2019-02/msg00492.html and as nothing in the testsuite revealed the patch broke this, I think we want to cover this in the testsuite. Tested on x86_64-linux with make check-gcc check-c++-all RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} ubsan.exp=opts*' with current trunk (all tests PASS) and with trunk patched with the above patch (all tests FAIL). Ok for trunk? 2019-02-14 Jakub Jelinek * c-c++-common/ubsan/opts-1.c: New test. * c-c++-common/ubsan/opts-2.c: New test. * c-c++-common/ubsan/opts-3.c: New test. * c-c++-common/ubsan/opts-4.c: New test. Jakub --- gcc/testsuite/c-c++-common/ubsan/opts-1.c.jj 2019-02-14 11:31:33.144895232 +0100 +++ gcc/testsuite/c-c++-common/ubsan/opts-1.c 2019-02-14 11:33:23.049077585 +0100 @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-fsanitize=undefined -fsanitize=shift -fsanitize=float-divide-by-zero -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times "__ubsan_handle_divrem_overflow" 2 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "__ubsan_handle_shift_out_of_bounds" 1 "optimized" } } */ + +int +foo (int x, int y) +{ + return x / y; +} + +int +bar (int x, int y) +{ + return x << y; +} + +float +baz (float x, float y) +{ + return x / y; +} --- gcc/testsuite/c-c++-common/ubsan/opts-2.c.jj 2019-02-14 11:33:29.806965829 +0100 +++ gcc/testsuite/c-c++-common/ubsan/opts-2.c 2019-02-14 11:34:03.169414166 +0100 @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-fsanitize=undefined -fno-sanitize=shift -fsanitize=float-divide-by-zero -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times "__ubsan_handle_divrem_overflow" 2 "optimized" } } */ +/* { dg-final { scan-tree-dump-not "__ubsan_handle_shift_out_of_bounds" "optimized" } } */ + +int +foo (int x, int y) +{ + return x / y; +} + +int +bar (int x, int y) +{ + return x << y; +} + +float +baz (float x, float y) +{ + return x / y; +} --- gcc/testsuite/c-c++-common/ubsan/opts-3.c.jj 2019-02-14 11:34:10.538292322 +0100 +++ gcc/testsuite/c-c++-common/ubsan/opts-3.c 2019-02-14 11:34:35.512879358 +0100 @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-fsanitize=undefined -fno-sanitize=shift -fno-sanitize=float-divide-by-zero -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times "__ubsan_handle_divrem_overflow" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-not "__ubsan_handle_shift_out_of_bounds" "optimized" } } */ + +int +foo (int x, int y) +{ + return x / y; +} + +int +bar (int x, int y) +{ + return x << y; +} + +float +baz (float x, float y) +{ + return x / y; +} --- gcc/testsuite/c-c++-common/ubsan/opts-4.c.jj 2019-02-14 11:40:35.771922337 +0100 +++ gcc/testsuite/c-c++-common/ubsan/opts-4.c 2019-02-14 11:40:29.220030674 +0100 @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-fsanitize=undefined -fno-sanitize-recover=integer-divide-by-zero -fno-sanitize-recover=shift -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times "__ubsan_handle_divrem_overflow_abort" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "__ubsan_handle_shift_out_of_bounds_abort" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "__ubsan_handle_type_mismatch_v1" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-not "__ubsan_handle_type_mismatch_v1_abort" "optimized" } } */ + +int +foo (int x, int y) +{ + return x / y; +} + +int +bar (int x, int y) +{ + return x << y; +} + +enum E { E0, E1, E2, E3 }; + +enum E +baz (enum E *x) +{ + return *x; +}