From patchwork Mon Oct 17 17:32:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 120273 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]) by ozlabs.org (Postfix) with SMTP id 5D611B70BB for ; Tue, 18 Oct 2011 04:35:04 +1100 (EST) Received: (qmail 8660 invoked by alias); 17 Oct 2011 17:35:01 -0000 Received: (qmail 8528 invoked by uid 22791); 17 Oct 2011 17:35:01 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from acsinet15.oracle.com (HELO acsinet15.oracle.com) (141.146.126.227) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 17 Oct 2011 17:34:34 +0000 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by acsinet15.oracle.com (Switch-3.4.4/Switch-3.4.4) with ESMTP id p9HHYS22003045 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 17 Oct 2011 17:34:30 GMT Received: from acsmt357.oracle.com (acsmt357.oracle.com [141.146.40.157]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id p9HHYRcj017200 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 17 Oct 2011 17:34:28 GMT Received: from abhmt112.oracle.com (abhmt112.oracle.com [141.146.116.64]) by acsmt357.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id p9HHYMEp002846; Mon, 17 Oct 2011 12:34:22 -0500 Received: from [192.168.1.4] (/79.56.212.85) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Oct 2011 10:34:22 -0700 Message-ID: <4E9C66A4.2070900@oracle.com> Date: Mon, 17 Oct 2011 19:32:20 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] PR 50757 X-IsSubscribed: yes 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 Hi, exactly like the recently fixed c++/17212. Tested x86_64-linux. Ok for mainline? Thanks, Paolo. ///////////////////////// /gcc 2011-10-17 Paolo Carlini PR c++/50757 * c-family/c.opt ([Wnonnull]): Add C++ and Objective-C++. * doc/invoke.texi: Update. /testsuite 2011-10-17 Paolo Carlini PR c++/50757 * g++.dg/warn/format7.C: New. * obj-c++.dg/warn7.mm: Likewise. Index: doc/invoke.texi =================================================================== --- doc/invoke.texi (revision 180100) +++ doc/invoke.texi (working copy) @@ -3223,7 +3222,7 @@ Enable @option{-Wformat} plus format checks not in @option{-Wformat}. Currently equivalent to @samp{-Wformat -Wformat-nonliteral -Wformat-security -Wformat-y2k}. -@item -Wnonnull @r{(C and Objective-C only)} +@item -Wnonnull @opindex Wnonnull @opindex Wno-nonnull Warn about passing a null pointer for arguments marked as Index: c-family/c.opt =================================================================== --- c-family/c.opt (revision 180100) +++ c-family/c.opt (working copy) @@ -510,7 +510,7 @@ C++ ObjC++ Var(warn_nonvdtor) Warning Warn about non-virtual destructors Wnonnull -C ObjC Var(warn_nonnull) Warning +C ObjC C++ ObjC++ Var(warn_nonnull) Warning Warn about NULL being passed to argument slots marked as requiring non-NULL Wnormalized= Index: testsuite/g++.dg/warn/format7.C =================================================================== --- testsuite/g++.dg/warn/format7.C (revision 0) +++ testsuite/g++.dg/warn/format7.C (revision 0) @@ -0,0 +1,10 @@ +// PR c++/50757 +// { dg-options "-Wformat -Wno-nonnull" } + +extern void *f (void *__s) __attribute__ ((__nonnull__ (1))); + +int main() +{ + void* const s = 0; + f(s); +} Index: testsuite/obj-c++.dg/warn7.mm =================================================================== --- testsuite/obj-c++.dg/warn7.mm (revision 0) +++ testsuite/obj-c++.dg/warn7.mm (revision 0) @@ -0,0 +1,10 @@ +// PR c++/50757 +// { dg-options "-Wformat -Wno-nonnull" } + +extern void *f (void *__s) __attribute__ ((__nonnull__ (1))); + +int main() +{ + void* const s = 0; + f(s); +}