Fix MSVC build
authorBehdad Esfahbod <behdad@behdad.org>
Thu, 20 Jun 2019 02:58:24 +0000 (19:58 -0700)
committerBehdad Esfahbod <behdad@behdad.org>
Thu, 20 Jun 2019 02:59:26 +0000 (19:59 -0700)
MSVC warning:

c:\projects\harfbuzz\src\hb-ot-layout-gsubgpos.hh(2732): error C2121: '#': invalid character: possibly the result of a macro expansion [C:\projects\harfbuzz\build\harfbuzz.vcxproj]

Clang warning for it:

./hb-ot-layout-gsubgpos.hh:2729:2: error: embedding a directive within macro arguments has undefined behavior [-Werror,-Wembedded-directive]

src/hb-ot-layout-gsubgpos.hh
src/hb.hh

index dd54c9b..9a82a4d 100644 (file)
@@ -2721,15 +2721,19 @@ struct GSUBGPOS
   {
     TRACE_SANITIZE (this);
     typedef OffsetListOf<TLookup> TLookupList;
-    return_trace (version.sanitize (c) &&
-                 likely (version.major == 1) &&
-                 scriptList.sanitize (c, this) &&
-                 featureList.sanitize (c, this) &&
-                 CastR<OffsetTo<TLookupList>> (lookupList).sanitize (c, this) &&
+    if (unlikely (!(version.sanitize (c) &&
+                   likely (version.major == 1) &&
+                   scriptList.sanitize (c, this) &&
+                   featureList.sanitize (c, this) &&
+                   CastR<OffsetTo<TLookupList>> (lookupList).sanitize (c, this))))
+      return_trace (false);
+
 #ifndef HB_NO_VAR
-                 (version.to_int () < 0x00010001u || featureVars.sanitize (c, this)) &&
+    if (unlikely (!(version.to_int () < 0x00010001u || featureVars.sanitize (c, this))))
+      return_trace (false);
 #endif
-                 true);
+
+    return_trace (true);
   }
 
   template <typename T>
index 3145574..bee39cd 100644 (file)
--- a/src/hb.hh
+++ b/src/hb.hh
@@ -66,6 +66,7 @@
 #pragma GCC diagnostic error   "-Wcast-align"
 #pragma GCC diagnostic error   "-Wcast-function-type"
 #pragma GCC diagnostic error   "-Wdelete-non-virtual-dtor"
+#pragma GCC diagnostic error   "-Wembedded-directive"
 #pragma GCC diagnostic error   "-Wextra-semi-stmt"
 #pragma GCC diagnostic error   "-Wformat-security"
 #pragma GCC diagnostic error   "-Wimplicit-function-declaration"