Enhance -Wshadow to emit a warning when typedefs or type aliases are shadowed, or when it shadows a variable.
Bug:
Paths
| Differential D31235
Enhance -Wshadow to warn when shadowing typedefs or type aliases ClosedPublic Authored by ahmedasadi on Mar 22 2017, 12:55 AM.
Details
Summary Enhance -Wshadow to emit a warning when typedefs or type aliases are shadowed, or when it shadows a variable. Bug:
Diff Detail Event Timeline
ahmedasadi added inline comments.
ahmedasadi marked 4 inline comments as done. Comment Actions Looks good to me
This revision is now accepted and ready to land.Mar 30 2017, 5:46 PM ahmedasadi marked an inline comment as done. Comment ActionsRe-ordered the checks in shouldWarnIfShadowedDecl as suggested by rnk. Comment Actions Thanks for reviewing. Would you be able to commit this patch for me, as I do not have commit access? Closed by commit rL299363: Enhance -Wshadow to warn when shadowing typedefs or type aliases (authored by arphaman). · Explain WhyApr 3 2017, 9:55 AM This revision was automatically updated to reflect the committed changes. Comment Actions This started making the libc++ bots fail, and I'm not convinced the case is reasonable to warn on. That case is: struct path { using value_type = char; struct iterator { using value_type = path; }; }; Obviously both typedefs are necessary, and according to the standard they are both required to have the same name. I would prefer not to have to #pragma disable this diagnostic within <filesystem> Comment Actions Updated diff to address Eric's comment - it's best not to issue a warning if the shadowing declaration is part of a class (this is what GCC currently does). I will need someone to commit this new patch for me. Comment Actions Comitted follow-up diff 94007 as rL299522: Don't issue a warning if the shadowing declaration is in a class now.
Revision Contents
Diff 93342 include/clang/Basic/DiagnosticSemaKinds.td
include/clang/Sema/Sema.h
lib/Sema/SemaDecl.cpp
test/SemaCXX/warn-shadow.cpp |
You don't need to use {} braces here.