[flang] fix warning
authorpeter klausler <pklausler@nvidia.com>
Mon, 5 Nov 2018 22:08:17 +0000 (14:08 -0800)
committerpeter klausler <pklausler@nvidia.com>
Thu, 8 Nov 2018 17:38:03 +0000 (09:38 -0800)
Original-commit: flang-compiler/f18@92003070de18bc7f4b78a8b00d72c324a554d523
Reviewed-on: https://github.com/flang-compiler/f18/pull/225
Tree-same-pre-rewrite: false

flang/lib/parser/characters.cc

index 80ac9fe..57da9ee 100644 (file)
@@ -23,16 +23,16 @@ std::optional<int> UTF8CharacterBytes(const char *p) {
     return {1};
   }
   if ((*p & 0xf8) == 0xf0) {
-    if (*p != 0xf0 && (p[1] & 0xc0) == 0x80 && (p[2] & 0xc0) == 0x80 &&
+    if ((*p & 0x07) != 0 && (p[1] & 0xc0) == 0x80 && (p[2] & 0xc0) == 0x80 &&
         (p[3] & 0xc0) == 0x80) {
       return {4};
     }
   } else if ((*p & 0xf0) == 0xe0) {
-    if (*p != 0xe0 && (p[1] & 0xc0) == 0x80 && (p[2] & 0xc0) == 0x80) {
+    if ((*p & 0x0f) != 0 && (p[1] & 0xc0) == 0x80 && (p[2] & 0xc0) == 0x80) {
       return {3};
     }
   } else if ((*p & 0xe0) == 0xc0) {
-    if (*p != 0xc0 && (p[1] & 0xc0) == 0x80) {
+    if ((*p & 0x1f) != 0 && (p[1] & 0xc0) == 0x80) {
       return {2};
     }
   }