[cfe-dev] Patch: Re: -Wshadow rationale for data members

Axel Naumann Axel.Naumann at cern.ch
Fri Oct 29 15:45:11 PDT 2010


Hi,

On 10/21/10 7:38 PM, John McCall wrote:
> On Oct 21, 2010, at 8:17 AM, Douglas Gregor wrote:
>> On Oct 21, 2010, at 2:43 AM, Axel Naumann wrote:
>>> struct A {
>>>  static void* f; void* g;
>>>  struct B { static void* f; void* g; };
>>> };
>>> struct C { static void* f; void* g;};
>>> struct D: public C { static void* f; void* g; };
>>>
>>> compiled with
>>> clang++ -c -Wall -Wshadow -O2 t.cxx
>>> generates the warning
>>>
>>> t.cxx:3:28: warning: declaration shadows a static data member of 'A'
>>> [-Wshadow]
>>>  struct B { static void* f; void* g; };
>>>                          ^
>>> t.cxx:2:17: note: previous declaration is here
>>>  static void* f; void* g;
>>>               ^
>>
>> It doesn't seem at all useful for Clang to warn about static data members shadowing something else by the same name. Personally, I'd limit -Wshadow to only complain when a local declaration shadows something from the outer scope.
> 
> I agree.

You mean like in the attached patch? The corresponding tests still to be
updated (removed, mostly), i.e. please don't commit :-)

Cheers, Axel.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: clang_Wshadow_locals.diff
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20101030/c3ef7c71/attachment.ksh>


More information about the cfe-dev mailing list