Skip to content

[CMake] Infer -Werror=switch via asserts being enabled #11098

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

Conversation

davezarzycki
Copy link
Contributor

LLVM-style projects like Swift make heavy use of switch statements and
therefore -Werror=switch is very useful during feature development. That
being said, if asserts are disabled, then you're probably not actively
hacking on the project and -Werror (or warnings in general) aren't
helpful.

@swift-ci Please smoke test

LLVM-style projects like Swift make heavy use of switch statements and
therefore -Werror=switch is very useful during feature development. That
being said, if asserts are disabled, then you're probably not actively
hacking on the project and -Werror (or warnings in general) aren't
helpful.
@jrose-apple
Copy link
Contributor

Why is -Wswitch more serious than any other warning?

(Also, isn't there some particular difference between -Wswitch and -Wswitch-enum? Which one do we want?)

Hi, Dave!

@rjmccall
Copy link
Contributor

I think I agree that this is a good idea. A missing switch case within the compiler is very likely to be an exhaustiveness failure, i.e. some piece of code was not properly updated for a new feature / representation.

We want -Wswitch. -Wswitch-enum requires an explicit case even when there's a default, and while we don't always use defaults, I don't think we want to change our idioms here.

@rjmccall
Copy link
Contributor

Also yeah, hi Dave! :)

@gottesmm
Copy link
Contributor

Hi Dave!

@davezarzycki
Copy link
Contributor Author

davezarzycki commented Jul 21, 2017 via email

@davezarzycki
Copy link
Contributor Author

davezarzycki commented Jul 21, 2017 via email

@davezarzycki
Copy link
Contributor Author

davezarzycki commented Jul 21, 2017 via email

@CodaFi
Copy link
Contributor

CodaFi commented Jul 24, 2017

(Drive by CI, don't mind me)

@swift-ci please smoke test

@jrose-apple
Copy link
Contributor

Okay, John and Dave both say it's good, let's take it.

@jrose-apple jrose-apple merged commit dc1d094 into swiftlang:master Aug 1, 2017
@atrick
Copy link
Contributor

atrick commented Aug 1, 2017

This broke the incremental bot:
swift-api-digester.cpp:1096:16: error: enumeration value 'Destructor' not handled in switch
https://ci.swift.org/job/oss-swift-incremental-RA-osx/11359

@jrose-apple
Copy link
Contributor

Being fixed in #11288 (and #11287, @ahoppen beat me to the same fix).

@gottesmm
Copy link
Contributor

gottesmm commented Aug 1, 2017

@rjmccall @davezarzycki @atrick @jrose-apple This brings up an issue that has been interesting to me for a while. For some cases we actually don't want to list out all the cases, but we want to be able to have covered switches and update. Specifically, @swiftix and I were discussing (in strawman terms) about some sort of tooling that could mark a switch associated with the state of an enum at a specific revision. If the git blame of the whole enum scope has changed in any way and the git blame of the switch cases is not a descendent of that commit, then emit a warning.

@gottesmm
Copy link
Contributor

gottesmm commented Aug 1, 2017

i.e. I am asking for your thoughts.

@jrose-apple
Copy link
Contributor

My thought is "let's not discuss this on a PR". :-( This is exactly what swift-dev is for.

@gottesmm
Copy link
Contributor

gottesmm commented Aug 1, 2017

SGTM!

@davezarzycki davezarzycki deleted the Werror_switch_during_assert_builds branch August 2, 2017 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants