fix(scanner): address -Wswitch-outside-range warnings when char is unsigned#42
Open
jamessan wants to merge 1 commit intotree-sitter-grammars:masterfrom
Open
fix(scanner): address -Wswitch-outside-range warnings when char is unsigned#42jamessan wants to merge 1 commit intotree-sitter-grammars:masterfrom
jamessan wants to merge 1 commit intotree-sitter-grammars:masterfrom
Conversation
…signed
C doesn't define the sign of the `char` type, so some architectures
(x86) use `signed char` where as others use `unsigned char`.
On architectures where unsigned char is used or if compiled with
"-funsigned-char", we see the below warnings:
src/scanner.c: In function ‘scn_dir_tag_pfx’:
src/scanner.c:470:13: warning: case label value is less than minimum value for type [-Wswitch-outside-range]
470 | case SCN_FAIL:
| ^~~~
src/scanner.c: In function ‘scn_tag’:
src/scanner.c:512:17: warning: case label value is less than minimum value for type [-Wswitch-outside-range]
512 | case SCN_FAIL:
| ^~~~
src/scanner.c:526:17: warning: case label value is less than minimum value for type [-Wswitch-outside-range]
526 | case SCN_FAIL:
| ^~~~
Define a new `ScanStatus` enum to use instead of independent `#define`s,
and update all the functions which previously returned `char` to instead
return `ScanStatus`.
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.
C doesn't define the sign of the
chartype, so some architectures(x86) use
signed charwhere as others useunsigned char.On architectures where unsigned char is used or if compiled with
"-funsigned-char", we see the below warnings:
Define a new
ScanStatusenum to use instead of independent#defines,and update all the functions which previously returned
charto insteadreturn
ScanStatus.