From patchwork Thu Sep 13 14:40:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [C++] PR 53210 Date: Thu, 13 Sep 2012 04:40:53 -0000 From: Paolo Carlini X-Patchwork-Id: 183636 Message-Id: <5051F075.402@oracle.com> To: Jason Merrill Cc: "gcc-patches@gcc.gnu.org" , =?UTF-8?B?TWFudWU=?= =?UTF-8?B?bCBMw7NwZXotSWLDocOxZXo=?= 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