Don't use -Wlogical-op if it causes gcc to generate warnings about logical
authorJeff Morriss <jeff.morriss.ws@gmail.com>
Thu, 3 Jan 2013 16:50:54 +0000 (16:50 -0000)
committerJeff Morriss <jeff.morriss.ws@gmail.com>
Thu, 3 Jan 2013 16:50:54 +0000 (16:50 -0000)
operations always evaluating to the same value in (the expansion of)
strchr().

See: https://www.wireshark.org/lists/wireshark-dev/201212/msg00136.html

svn path=/trunk/; revision=46916

configure.ac

index 33c8eca434f8dca884b6a2804e850d5b99fcae3d..93aa3e1720fa3b3512051124cb383e3045945136 100644 (file)
@@ -442,7 +442,6 @@ AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wattributes)
 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wdiv-by-zero)
 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wignored-qualifiers)
 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wpragmas)
-AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wlogical-op)
 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wno-overlength-strings)
 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wwrite-strings)
 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wno-long-long)
@@ -471,6 +470,31 @@ foo(int a)
   ],
   [warns about variables in function declarations shadowing other variables])
 
+# Unfortunately some versions of gcc generate logical-op warnings when strchr()
+# is given a constant seperators list.
+# gcc versions 4.3.2 and 4.4.5 are known to have the problem.
+AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wlogical-op, C,
+  [
+#include <string.h>
+
+int
+foo(char *sep, int c)
+{
+       if (strchr (sep, c) != NULL)
+               return 1;
+       else
+               return 0;
+}
+
+int
+main(int argc, char **argv)
+{
+       return foo(\"<\", 'a');
+}
+  ],
+  [generates warnings from strchr()])
+
+
 ## AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wno-error=unused-but-set-variable)
 
 #