From patchwork Thu Dec 22 11:49:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 708212 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3tkqb13R3hz9t0J for ; Thu, 22 Dec 2016 22:50:20 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="yybik9t8"; dkim-atps=neutral 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:mime-version :content-type; q=dns; s=default; b=fMYrcr/Cd5d8dbvEdhMCGxxaohIgk brvdHjE/ikbPqbuUvmRtk2lr5eJx3aDhqr00Vv9JThqdtBku/gVhV+qBBxi8kX1I /PxDh9zOpouVCCedYIebL6vwio2f47WPuQAiw8WdQA2y0rWSE/cUdbaBCdc4FrsS JjmBb3U6fMzPps= 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:mime-version :content-type; s=default; bh=geAgFTtH99m0npZAOgRVpsM5hA0=; b=yyb ik9t8KDVM14+NoPRiKCxtHfRY0OFPlQhs4bBaWArkgenSXxJNnDIgNJoSl0/ZWqB 1voVDzysrxDjizk480V0x/m8gPD8mPxPdCveH0BvZuQm47Y9dGDNuJ5Y8MLMLSMf SD4o0WDXCGOvvvEfp/HSlShYMMUqa2fYXHsXkrnY= Received: (qmail 7828 invoked by alias); 22 Dec 2016 11:50:12 -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 7814 invoked by uid 89); 22 Dec 2016 11:50:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.0 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=dg-warning, dgwarning 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, 22 Dec 2016 11:50:02 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D657E37B2D7; Thu, 22 Dec 2016 11:50:00 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-54.ams2.redhat.com [10.36.116.54]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uBMBnwQt009856 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 22 Dec 2016 06:50:00 -0500 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id uBMBntHc006493; Thu, 22 Dec 2016 12:49:56 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id uBMBns2M006492; Thu, 22 Dec 2016 12:49:54 +0100 Date: Thu, 22 Dec 2016 12:49:54 +0100 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Cc: Martin Sebor Subject: [committed] Add two new -Wnonnull tests Message-ID: <20161222114954.GD21933@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.7.1 (2016-10-04) X-IsSubscribed: yes Hi! I've committed following patch as obvious to add two tests that were discussed in the recent thread. 2016-12-22 Jakub Jelinek PR middle-end/78858 * c-c++-common/ubsan/pr78858.c: New test. * gcc.dg/nonnull-5.c: New test. Jakub --- gcc/testsuite/c-c++-common/ubsan/pr78858.c.jj 2016-12-22 12:43:45.347067480 +0100 +++ gcc/testsuite/c-c++-common/ubsan/pr78858.c 2016-12-22 12:43:34.000000000 +0100 @@ -0,0 +1,10 @@ +/* PR middle-end/78858 */ +/* { dg-do compile } */ +/* { dg-options "-fsanitize=undefined -Wnonnull" } */ + +void +foo (char **x, const char *y) +{ + *x = (char *) __builtin_malloc (__builtin_strlen (y) + 1); /* { dg-bogus "argument 1 null where non-null expected" } */ + __builtin_strcpy (*x, y); +} --- gcc/testsuite/gcc.dg/nonnull-5.c.jj 2016-12-22 12:34:34.875208653 +0100 +++ gcc/testsuite/gcc.dg/nonnull-5.c 2016-12-22 12:34:27.924298825 +0100 @@ -0,0 +1,11 @@ +/* Reduced from https://sourceware.org/bugzilla/show_bug.cgi?id=20978 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wnonnull" } */ + +int +foo (const char *name) +{ + if (name) + return 6; + return __builtin_strlen (name); /* { dg-warning "argument 1 null where non-null expected" } */ +}