Disable some clang conversion warnings in cpp2util.h and cppfront itself#1212
Merged
hsutter merged 4 commits intohsutter:mainfrom Aug 9, 2024
Merged
Conversation
cppfront and cpp2util.h use signed integer types for indices and container sizes so disable signed-to-unsigned conversion warnings. cppfront also uses implicit conversions from string literal to bool for: `assert(!"message")` so disable those warnings too.
Using the answer we recommend for everyone else, so model the right behavior here
Owner
|
Thanks! I've taken a pass and actually just removed the This seems to build clean and pass regression, but I don't have Clang 18+ installed -- before merging, please confirm that this looks right to you and still builds clean on the newer Clang with high warnings? |
Contributor
Author
|
Looks good, no warnings with clang 18. |
Owner
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR disables some clang conversion warnings in 2 places:
cpp2util.hfor Cpp2 usersThe warnings appear when compiling with clang with
-Wconversion(as recommend by Jason Turner).cpp2util.hdisablesWsign-conversion(only in that header) to allow warning-free signed integer types for indices and sizes.The cppfront translation unit (via
common.h) disables the above and alsoWstring-conversionto enable implicit conversions of string literals to bools forassert(!"message").Some regression tests are updated because the line numbers have changed in
cpp2util.h.Note: there are some other 64-bit to 32-bit precision loss conversion warnings in cppfront itself (which this PR doesn't address) but I think we should fix them via casts rather than disabling the warning, since that warning may find other issues in the future.