Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing warnings on switch(boolean_expr) #5562

Closed
llvmbot opened this issue Oct 14, 2009 · 8 comments
Closed

missing warnings on switch(boolean_expr) #5562

llvmbot opened this issue Oct 14, 2009 · 8 comments
Labels
bugzilla Issues migrated from bugzilla clang:frontend Language frontend issues, e.g. anything involving "Sema"

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Oct 14, 2009

Bugzilla Link 5190
Resolution FIXED
Resolved on Mar 12, 2010 00:57
Version trunk
OS All
Depends On llvm/llvm-bugzilla-archive#5206
Reporter LLVM Bugzilla Contributor
CC @lattner

Extended Description

Clang should warn on switch(bool) since it's almost certainly wrong
(developers seem okay with using if-statements instead).

int test2(const char foo) {
int success = 0;
switch (foo && foo[0]) { /
XXX */
case 0:
success = 1;
break;
case 1:
break;
}
return success;
}

@llvmbot
Copy link
Collaborator Author

llvmbot commented Oct 14, 2009

This was forked from #4779 filed by nlewycky@google.com.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Oct 16, 2009

This bug depends on llvm/llvm-bugzilla-archive#5206 .

@llvmbot
Copy link
Collaborator Author

llvmbot commented Oct 16, 2009

A patch was sent to cfe-commits for review.

@lattner
Copy link
Collaborator

lattner commented Oct 17, 2009

according to Edward, the patch didn't apply cleanly to mainline, please update and resend when you get a chance, thanks!

@llvmbot
Copy link
Collaborator Author

llvmbot commented Oct 17, 2009

I did an 'svn up' and didn't see any conflict, so I'm not where why the patch wouldn't work for the trunk.

I just tried this in a clean svn checkout:

patch -p 0 -i pr5190.patch

and it worked fine. Could you try again? Thanks.

BTW, this patch adds a new file test/SemaCXX/switch.cpp. Don't know if this has anything to do with what Edward saw.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Oct 17, 2009

proposed fix
Attached the patch file (the same as sent to cfe-commits) to the bug.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Oct 17, 2009

No idea why it was not applying, so I did it by hand.

Committed in revision 84346.

Many thanks,
Edward.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Nov 27, 2021

mentioned in issue llvm/llvm-bugzilla-archive#5206

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
daniel-grumberg pushed a commit to daniel-grumberg/llvm-project that referenced this issue Nov 7, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang:frontend Language frontend issues, e.g. anything involving "Sema"
Projects
None yet
Development

No branches or pull requests

2 participants