From: Ulya Trofimovich Date: Mon, 10 Aug 2015 16:11:01 +0000 (+0100) Subject: A better way to avoid GCC [-Wreturn-type] false positives. X-Git-Tag: 0.15~136 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d6379090ffebbc9c669f4ed30577ddd4957187ee;p=re2c A better way to avoid GCC [-Wreturn-type] false positives. 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. --- diff --git a/re2c/src/ir/regexp/encoding/enc.h b/re2c/src/ir/regexp/encoding/enc.h index ca5399b4..699b406f 100644 --- a/re2c/src/ir/regexp/encoding/enc.h +++ b/re2c/src/ir/regexp/encoding/enc.h @@ -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)