Bug 112309 - enhancement: extra flags to let -Wshadow skip if..else and lambda blocks
Summary: enhancement: extra flags to let -Wshadow skip if..else and lambda blocks
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 14.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks: new-warning, new_warning
  Show dependency treegraph
 
Reported: 2023-10-31 10:48 UTC by Joachim Wuttke
Modified: 2023-10-31 22:01 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joachim Wuttke 2023-10-31 10:48:21 UTC
Suggestion: add a flag -Wnoshadow-ifelse to prevent -Wshadow from reporting shadowing in "else if" constructs like

if (auto* p = dynamic_cast<A>(x))
   ...
else if (auto* p = dynamic_cast<B>(x))
   ...
else if (auto* p = dynamic_cast<C>(x))
   ...


A similar approach (-Wnoshadow-lambda) could help to resolve https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79328.