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

Adam Nohejl adam+clang at nohejl.name
Sat Oct 30 07:10:42 PDT 2010


On 2010/10/30, at 13:25, Adam Nohejl wrote:

> Incidentally, I have just added a comment to bug 6808 (other false -Wshadow warnings) yesterday.
> 
> I'm attaching a patch that combines the above changes (as Axel just removed a few things) and also prevents false warnings (1), (2), (3) in the following snippet:
> 
> class A{
>    int a;
>    static void f(int a){ }           // (1) false warning (in contrast to gcc)
>    class X{
>        X(int a){ }                   // (2) false warning (in contrast to gcc)
>        static void g(int a){ }       // (3) false warning (in contrast to gcc)
>    };
> };

I extended the previous patch to cases when a field (as opposed to static member) of class A would be "shadowed" by any variable occurring in a class not derived from A, like in this example:

struct A{
  int a;
  struct X{
    void f(int a){}
  };
};

(Also, the lines in the patch do not exceed 80 columns anymore.)

This probably prevents most false warnings. Any comments on the cases I mentioned in the previous message?

-- 
Adam

-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang_Wshadow_staticmeths_and_notderivedfrom.diff
Type: application/octet-stream
Size: 2392 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20101030/ce7a85b5/attachment.obj>


More information about the cfe-dev mailing list