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

            Bug ID: 31222
           Summary: Produce warning when a derived class shadows a field
                    of the base class with `-Wshadow`
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangb...@nondot.org
          Reporter: vittorio.ro...@outlook.com
                CC: dgre...@apple.com, llvm-bugs@lists.llvm.org
    Classification: Unclassified

struct Base { int a; };
struct Derived : Base  { int a; };
int main() { }

The code snippet above produces no warnings with `-Wshadow` enabled. 
This seems like an unusual situation that could lead to unexpected behavior.

I suggest producing a warning when `-Wshadow` is enabled, to alert that
`Derived::a` is shadowing `Base::a`.

Related SO question:
https://stackoverflow.com/questions/40908402

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to