summaryrefslogtreecommitdiff
path: root/enc
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-05-04 12:10:04 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-05-04 12:28:24 +0900
commitb7e1eda932c74196d58e6b63644200b764b5453e (patch)
tree6300f14588efa6ec5884d99bebf10cab4d679d25 /enc
parent39bd1244b49aa1fcf93d3163bfd97d94b109f2ee (diff)
Suppress warnings by gcc 10.1.0-RC-20200430
* Folding results should not be empty. If `OnigCodePointCount(to->n)` were 0, `for` loop using `fn` wouldn't execute and `ncs` elements are not initialized. ``` enc/unicode.c:557:21: warning: 'ncs[0]' may be used uninitialized in this function [-Wmaybe-uninitialized] 557 | for (i = 0; i < ncs[0]; i++) { | ~~~^~~ ``` * Cast to `enum yytokentype` Additional enums for scanner events by ripper are not included in `yytokentype`. ``` ripper.y:7274:28: warning: implicit conversion from 'enum <anonymous>' to 'enum yytokentype' [-Wenum-conversion] ```
Diffstat (limited to 'enc')
-rw-r--r--enc/unicode.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/enc/unicode.c b/enc/unicode.c
index 6e8c3d8..18fba02 100644
--- a/enc/unicode.c
+++ b/enc/unicode.c
@@ -493,6 +493,10 @@ onigenc_unicode_get_case_fold_codes_by_str(OnigEncoding enc,
#endif
if ((to = onigenc_unicode_fold_lookup(code)) != 0) {
+ if (OnigCodePointCount(to->n) == 0) {
+ /* any codepoint should not be empty */
+ UNREACHABLE_RETURN(0);
+ }
if (OnigCodePointCount(to->n) == 1) {
OnigCodePoint orig_code = code;