This is an archive of the discontinued LLVM Phabricator instance.

[clang] Warn on implicit boolean casts in more contexts (PR34180)
Needs ReviewPublic

Authored by m4tx on Jun 10 2019, 12:26 PM.

Details

Summary
int x;
return x = 5;

For a code like above, GCC produces a warning suggesting using parentheses about the assignment. This change makes clang produce similar warning to, suggesting either changing the operator to ==, or wrap the expression inside parentheses.

This is based off D45401.

Diff Detail

Event Timeline

m4tx created this revision.Jun 10 2019, 12:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 10 2019, 12:26 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Thanks !

You can check and take tests from my older patch https://reviews.llvm.org/D58878

Please always upload all patches with full context (-U99999)

lebedev.ri requested changes to this revision.Jul 10 2019, 2:56 PM
This revision now requires changes to proceed.Jul 10 2019, 2:56 PM
lebedev.ri resigned from this revision.Jan 12 2023, 4:42 PM

This review seems to be stuck/dead, consider abandoning if no longer relevant.

This revision now requires review to proceed.Jan 12 2023, 4:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 12 2023, 4:42 PM
Herald added a subscriber: StephenFan. · View Herald Transcript