[llvm-bugs] [Bug 33947] New: Wshadow false positives in function-local classes

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jul 26 04:05:32 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=33947

            Bug ID: 33947
           Summary: Wshadow false positives in function-local classes
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: alexfh at google.com
                CC: llvm-bugs at lists.llvm.org

https://godbolt.org/g/54XRMT

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

3 : <source>:3:16: warning: declaration shadows a local variable [-Wshadow]
    void g(int a) {}
               ^
1 : <source>:1:12: note: previous declaration is here
void f(int a) {
           ^
4 : <source>:4:15: warning: declaration shadows a local variable [-Wshadow]
    A() { int a; }
              ^
1 : <source>:1:12: note: previous declaration is here
void f(int a) {
           ^
2 warnings generated.


The local variable `a` of the function `f` can't be accessed from a method of
the function-local class A, thus no shadowing occurs and no diagnostic is
needed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170726/faade7fd/attachment.html>


More information about the llvm-bugs mailing list