]> granicus.if.org Git - re2c/commitdiff
A better way to avoid GCC [-Wreturn-type] false positives.
authorUlya Trofimovich <skvadrik@gmail.com>
Mon, 10 Aug 2015 16:11:01 +0000 (17:11 +0100)
committerUlya Trofimovich <skvadrik@gmail.com>
Mon, 10 Aug 2015 16:11:01 +0000 (17:11 +0100)
Though all enum values are handled in switch, GCC still complains
that 'control reaches end of non-void function'. Adding default
clause helps and it's better than returning some spurious constant.

re2c/src/ir/regexp/encoding/enc.h

index ca5399b43a75b1c27016a514fab5c1b9b1f698c4..699b406f9a153412e970c859bed5e1be51ff611b 100644 (file)
@@ -93,9 +93,9 @@ inline uint32_t Enc::nCodePoints() const
                case UCS2:      return 0x10000;
                case UTF16:
                case UTF32:
-               case UTF8:      return 0x110000;
+               case UTF8:
+               default:        return 0x110000;
        }
-       return ~0; // to silence gcc warning
 }
 
 inline uint32_t Enc::nCodeUnits() const
@@ -107,9 +107,9 @@ inline uint32_t Enc::nCodeUnits() const
                case UTF8:      return 0x100;
                case UCS2:
                case UTF16:     return 0x10000;
-               case UTF32:     return 0x110000;
+               case UTF32:
+               default:        return 0x110000;
        }
-       return ~0; // to silence gcc warning
 }
 
 // returns *maximal* code point size for encoding
@@ -122,9 +122,9 @@ inline uint32_t Enc::szCodePoint() const
                case UCS2:      return 2;
                case UTF16:
                case UTF32:
-               case UTF8:      return 4;
+               case UTF8:
+               default:        return 4;
        }
-       return ~0; // to silence gcc warning
 }
 
 inline uint32_t Enc::szCodeUnit() const
@@ -136,9 +136,9 @@ inline uint32_t Enc::szCodeUnit() const
                case UTF8:      return 1;
                case UCS2:
                case UTF16:     return 2;
-               case UTF32:     return 4;
+               case UTF32:
+               default:        return 4;
        }
-       return ~0; // to silence gcc warning
 }
 
 inline bool Enc::set(type_t t)