From patchwork Thu Sep 13 14:40:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 183636 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 E8B802C007B for ; Fri, 14 Sep 2012 00:41:16 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1348152077; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Message-ID:Date:From:User-Agent:MIME-Version: To:CC:Subject:References:In-Reply-To:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=1Evj3aFe640J484UKcKshfEA3K0=; b=B9dklZcbk3KUJCVSRu9Y/CGwc0JDmvTT8FNmsgRYiMc5l1htyU1uOfQI1NodHc rgkK37JYKcsiqkOZgCoJxfe6tcZIirfCZBDrKK00iQK+NqjU9uJxCDIgDrwSJk5b +Jv+HwK6qqTVVr7KD1Yt96UszZSpWklU8cF3jK8Sxac2o= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=yPLE/yWGtnnWboUhisyNzIoEWaIfFCmXjkopjz4w/dRfik3heLg3Ho5DAujc4F LnhZwXQ/BvYhw7eSPMQb2yhXuEpjV5fV0l4k460MKll7jR+BBDBRGuDH7tLYBPtz SbM7vHDbBy7WMTl19a0EznSovsX6S/XJpF3y8h8ct4MAw=; Received: (qmail 21917 invoked by alias); 13 Sep 2012 14:41:13 -0000 Received: (qmail 21907 invoked by uid 22791); 13 Sep 2012 14:41:12 -0000 X-SWARE-Spam-Status: No, hits=-7.8 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_THREADED, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_W, 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; Thu, 13 Sep 2012 14:40:59 +0000 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by acsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q8DEeu3e022690 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 13 Sep 2012 14:40:57 GMT Received: from acsmt356.oracle.com (acsmt356.oracle.com [141.146.40.156]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q8DEeuOG018609 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 13 Sep 2012 14:40:56 GMT Received: from abhmt108.oracle.com (abhmt108.oracle.com [141.146.116.60]) by acsmt356.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q8DEeuwb029241; Thu, 13 Sep 2012 09:40:56 -0500 Received: from [192.168.1.4] (/79.53.13.94) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 13 Sep 2012 07:40:55 -0700 Message-ID: <5051F075.402@oracle.com> Date: Thu, 13 Sep 2012 16:40:53 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120825 Thunderbird/15.0 MIME-Version: 1.0 To: Jason Merrill CC: "gcc-patches@gcc.gnu.org" , =?UTF-8?B?TWFudWU=?= =?UTF-8?B?bCBMw7NwZXotSWLDocOxZXo=?= Subject: Re: [C++ Patch] PR 53210 References: <5051DF82.1050902@oracle.com> <5051E1E2.7050909@redhat.com> In-Reply-To: <5051E1E2.7050909@redhat.com> 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, On 09/13/2012 03:38 PM, Jason Merrill wrote: > On 09/13/2012 09:28 AM, Paolo Carlini wrote: >> Jon noticed that for this testcase we don't warn at all even with -Wall, >> whereas the code doesn't really make much sense. Turns out that the >> warning is currently controlled both by warn_init_self (not part of >> -Wall) and OPT_Wuninitialized. Thus Manuel proposes to simply remove the >> former, because this isn't the specific case of int x = x which we want >> to keep on "supporting" as a GNU extension. Also, as mentioned by Jon, >> the user can always leave 'i' out the mem-initializer-list. >> >> Alternately, one may want to use OPT_Winit_self, but then we still have >> the issue that -Winit-self is not part of -Wall. > > I think my preference would be to add -Winit-self to -Wall for C++; > people can use -Wno-init-self if they don't want the warning. Agreed. Then I'm finishing testing the below (already booted and tested C++, the other languages next). Ok? Thanks, Paolo. /////////////////////// 2012-09-13 Paolo Carlini PR c++/53210 * doc/invoke.texi ([Winit-self]): Document as enabled by -Wall in C++. /c-family 2012-09-13 Paolo Carlini PR c++/53210 * c.opt ([Winit-self]): Enabled by -Wall in C++. /testsuite 2012-09-13 Paolo Carlini PR c++/53210 * g++.dg/warn/Wuninitialized-self.C: New. Index: testsuite/g++.dg/warn/Winit-self.C =================================================================== --- testsuite/g++.dg/warn/Winit-self.C (revision 0) +++ testsuite/g++.dg/warn/Winit-self.C (revision 0) @@ -0,0 +1,8 @@ +// PR c++/53210 +// { dg-options "-Wall" } + +struct S +{ + S(int i) : j(j) { } // { dg-warning "is initialized with itself" } + int j; +}; Index: doc/invoke.texi =================================================================== --- doc/invoke.texi (revision 191245) +++ doc/invoke.texi (working copy) @@ -3348,6 +3348,8 @@ int f() @end group @end smallexample +This warning is enabled by @option{-Wall} in C++. + @item -Wimplicit-int @r{(C and Objective-C only)} @opindex Wimplicit-int @opindex Wno-implicit-int Index: c-family/c.opt =================================================================== --- c-family/c.opt (revision 191245) +++ c-family/c.opt (working copy) @@ -408,7 +408,7 @@ C C++ Var(warn_ignored_qualifiers) Warning Enabled Warn whenever type qualifiers are ignored. Winit-self -C ObjC C++ ObjC++ Var(warn_init_self) Warning +C ObjC C++ ObjC++ Var(warn_init_self) Warning LangEnabledBy(C++ ObjC++,Wall) Warn about variables which are initialized to themselves Wimplicit