Add -Werror=switch and -Wcovered-switch-default
ClosedPublic

Authored by aaronpuchert on Nov 28 2017, 11:32 PM.

Details

Summary

The former ensures that switch statements are adapted when an
enumeration is changed. The latter encourages to remove the default
label in fully covered switch statements, making the former more
effective. (It is silenced by default labels.)

Diff Detail

Repository
R32 KDevelop
Branch
switch-enum
Lint
No Linters Available
Unit
No Unit Test Coverage
aaronpuchert requested review of this revision.Nov 28 2017, 11:32 PM
aaronpuchert created this revision.
apol added a subscriber: apol.Nov 29 2017, 12:25 AM

Then fix the warnings that appear? Or doesn't it show any issues?

There are no issues with -Wswitch, but some with -Wcovered-switch-default.

Sometimes people cast integers to enumeration types without checking whether it's a valid enumeration value first. So it might not be easy so safely fix all issues that arise. But I'll see what I can do.

Fix -Wcovered-switch-default where it is safe to do so.

mwolff accepted this revision.Nov 30 2017, 9:42 AM
mwolff added a subscriber: mwolff.

just to make this clear: are there any remaining new compiler warnings? if so, fix them first. otherwise lgtm

This revision is now accepted and ready to land.Nov 30 2017, 9:42 AM

Fix remaining occurences of -Wcovered-switch-default.

No functional change intended.

@mwolff Are the additional changes Ok? There are no new warnings anymore.

I used Q_UNREACHABLE() when the enumeration was used safely and a fallback when unchecked static_casts were involved. In an ideal world, I would probably try to make sure that enumerations only ever have valid values, but right now I don't understand enough of the code base to properly fix this.

aaronpuchert added inline comments.Dec 19 2017, 7:54 PM
plugins/debuggercommon/mi/micommand.cpp
259

I'm not sure this is intentional, but I'm going to leave it for now. I promised no functional change.

This revision was automatically updated to reflect the committed changes.