[前][次][番号順一覧][スレッド一覧]

ruby-changes:61003

From: Nobuyoshi <ko1@a...>
Date: Mon, 4 May 2020 12:38:15 +0900 (JST)
Subject: [ruby-changes:61003] b7e1eda932 (master): Suppress warnings by gcc 10.1.0-RC-20200430

https://git.ruby-lang.org/ruby.git/commit/?id=b7e1eda932

From b7e1eda932c74196d58e6b63644200b764b5453e Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Mon, 4 May 2020 12:10:04 +0900
Subject: 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]
  ```

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, https://github.com/ruby/ruby/blob/trunk/enc/unicode.c#L493
 #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;
 
diff --git a/ext/ripper/eventids2.c b/ext/ripper/eventids2.c
index cdac208..ac38663 100644
--- a/ext/ripper/eventids2.c
+++ b/ext/ripper/eventids2.c
@@ -1,12 +1,20 @@ https://github.com/ruby/ruby/blob/trunk/ext/ripper/eventids2.c#L1
 enum {
     tIGNORED_NL  = tLAST_TOKEN + 1,
+# define tIGNORED_NL ((enum yytokentype)tIGNORED_NL)
     tCOMMENT,
+# define tCOMMENT ((enum yytokentype)tCOMMENT)
     tEMBDOC_BEG,
+# define tEMBDOC_BEG ((enum yytokentype)tEMBDOC_BEG)
     tEMBDOC,
+# define tEMBDOC ((enum yytokentype)tEMBDOC)
     tEMBDOC_END,
+# define tEMBDOC_END ((enum yytokentype)tEMBDOC_END)
     tHEREDOC_BEG,
+# define tHEREDOC_BEG ((enum yytokentype)tHEREDOC_BEG)
     tHEREDOC_END,
-    k__END__
+# define tHEREDOC_END ((enum yytokentype)tHEREDOC_END)
+    k__END__,
+# define k__END__ ((enum yytokentype)k__END__)
 };
 
 typedef struct {
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]