-Wunused-variable false negative when variable is declared in if-condition
| Bugzilla Link | 31373 |
| Version | trunk |
| OS | Linux |
| CC | @mgehre,@pcc,@rnk,@ZequanWu |
Extended Description
-Wunused-variable does not warn on this case:
bool f(); void g() { if (bool b = f()) { // ... } }
GCC's version of the warning does. Presumably we're marking the variable as 'used' in the condition handling code; while that's technically correct, it doesn't lead to the right outcome here.
while that's technically correct, it doesn't lead to the right outcome here.
Do you mean the right outcome should be that variables declared in condition expression of if/while/switch/for should not be marked as used or referenced?
I think this must be a regression, I get the warning with clang 3.6.
Is this issue still open? I would like to work on this but need some guidance as a first-time contributor.
Is this issue still open? I would like to work on this but need some guidance as a first-time contributor.
Yeah, this issue still open

Hi, I am taking the issue and would like to work on it. I am going through the codebase, any headsup for approaching this issue!?
I'd like to work on this.
@Krishna-13-cyber do you still intend to work on this?
Duplicate of #61681.
As far as I can tell, the commit (https://github.com/llvm/llvm-project/commit/92023b15099012a657da07ebf49dd7d94a260f84) that fixed #61681 (which this issue was marked as a duplicate of even though this issue was created first) was reverted in https://github.com/llvm/llvm-project/commit/f0f395e00e2ec3f1f20ca9021d1554fde73d56c9 and I never saw it relanded, so I think this needs to be reopened. Please feel free to close this if that assessment is incorrect.