[LLVMbugs] [Bug 13840] New: false positive -Wshadow diagnostic on nested struct

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Sep 13 13:51:52 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=13840

             Bug #: 13840
           Summary: false positive -Wshadow diagnostic on nested struct
           Product: clang
           Version: 3.1
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: fang at csl.cornell.edu
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


The following code triggers a -Wshadow diagnostic when (I think) it shouldn't:

struct foo {
        struct bar {
                void
                fun(int);
        }; 
        int width;
}; 

void
foo::bar::fun(int width) {
}

gives:
(fang at host) % clang++ -Wshadow -c nested-shadow.cc -o nested-shadow.o
nested-shadow.cc:10:19: warning: declaration shadows a field of 'foo'
[-Wshadow]
foo::bar::fun(int width) {
                  ^
nested-shadow.cc:6:6: note: previous declaration is here
        int width;
            ^
1 warning generated.

The foo::width member should not be reference-able within foo::bar::fun().

(fang at host) % clang++ --version
clang version 3.1 (branches/release_31)
Target: i386-pc-linux-gnu
Thread model: posix

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list