]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Work in progress on fixing harmless compiler warnings when using -W4 and MSVC.
authormistachkin <mistachkin@noemail.net>
Mon, 12 Jan 2015 18:02:52 +0000 (18:02 +0000)
committermistachkin <mistachkin@noemail.net>
Mon, 12 Jan 2015 18:02:52 +0000 (18:02 +0000)
FossilOrigin-Name: 856dd245ce037f93d5ae2ddeb4fdf949c1e5c8e9

13 files changed:
Makefile.in
Makefile.msc
Makefile.vxworks
main.mk
manifest
manifest.uuid
src/msvc.h [new file with mode: 0644]
src/shell.c
src/sqliteInt.h
tool/lemon.c
tool/mksqlite3c-noext.tcl
tool/mksqlite3c.tcl
tool/mksqlite3internalh.tcl

index 42caa69835bc665484ebc72c8b57359ff9a3e0bd..168bce66025909ae6edbf09648e2d750ad387d69 100644 (file)
@@ -234,6 +234,7 @@ SRC = \
   $(TOP)/src/mem3.c \
   $(TOP)/src/mem5.c \
   $(TOP)/src/memjournal.c \
+  $(TOP)/src/msvc.h \
   $(TOP)/src/mutex.c \
   $(TOP)/src/mutex.h \
   $(TOP)/src/mutex_noop.c \
@@ -463,6 +464,7 @@ HDR = \
    $(TOP)/src/hash.h \
    $(TOP)/src/hwtime.h \
    keywordhash.h \
+   $(TOP)/src/msvc.h \
    $(TOP)/src/mutex.h \
    opcodes.h \
    $(TOP)/src/os.h \
index 3fc675ee4f8875b1b6d4919fb609d612657a8a06..f301048fae952151916f826e2369d91b202f1721 100644 (file)
@@ -16,6 +16,22 @@ TOP = .
 USE_AMALGAMATION = 1
 !ENDIF
 
+# Set this non-0 to enable full warnings (-W4, etc) when compiling.
+#
+!IFNDEF USE_FULLWARN
+USE_FULLWARN = 0
+!ENDIF
+
+# If necessary, create a list of harmless compiler warnings to disable when
+# compiling the build tools.  For the SQLite source code itself, warnings,
+# if any, will be disabled from within it.
+#
+!IFNDEF NO_WARN
+!IF $(USE_FULLWARN)!=0
+NO_WARN = -wd4054 -wd4055 -wd4100 -wd4210 -wd4702
+!ENDIF
+!ENDIF
+
 # Set this non-0 to use the library paths and other options necessary for
 # Windows Phone 8.1.
 #
@@ -232,7 +248,11 @@ NSDKLIBPATH = $(NSDKLIBPATH:\\=\)
 # C compiler and options for use in building executables that
 # will run on the platform that is doing the build.
 #
+!IF $(USE_FULLWARN)!=0
+BCC = $(NCC) -W4
+!ELSE
 BCC = $(NCC) -W3
+!ENDIF
 
 # Check if assembly code listings should be generated for the source
 # code files to be compiled.
@@ -253,7 +273,13 @@ NLTLIBPATHS = "/LIBPATH:$(NCRTLIBPATH)" "/LIBPATH:$(NSDKLIBPATH)"
 # will run on the target platform.  (BCC and TCC are usually the
 # same unless your are cross-compiling.)
 #
-TCC = $(CC) -W3 -DSQLITE_OS_WIN=1 -I. -I$(TOP) -I$(TOP)\src -fp:precise
+!IF $(USE_FULLWARN)!=0
+TCC = $(CC) -W4
+!ELSE
+TCC = $(CC) -W3
+!ENDIF
+
+TCC = $(TCC) -DSQLITE_OS_WIN=1 -I. -I$(TOP) -I$(TOP)\src -fp:precise
 RCC = $(RC) -DSQLITE_OS_WIN=1 -I$(TOP) -I$(TOP)\src
 
 # Check if assembly code listings should be generated for the source
@@ -706,6 +732,7 @@ SRC = \
   $(TOP)\src\mem3.c \
   $(TOP)\src\mem5.c \
   $(TOP)\src\memjournal.c \
+  $(TOP)\src\msvc.h \
   $(TOP)\src\mutex.c \
   $(TOP)\src\mutex.h \
   $(TOP)\src\mutex_noop.c \
@@ -938,6 +965,7 @@ HDR = \
    $(TOP)\src\hash.h \
    $(TOP)\src\hwtime.h \
    keywordhash.h \
+   $(TOP)\src\msvc.h \
    $(TOP)\src\mutex.h \
    opcodes.h \
    $(TOP)\src\os.h \
@@ -990,7 +1018,7 @@ libtclsqlite3.lib: tclsqlite.lo libsqlite3.lib
 
 sqlite3.exe:   $(TOP)\src\shell.c libsqlite3.lib $(LIBRESOBJS) sqlite3.h
        $(LTLINK) $(READLINE_FLAGS) \
-               $(TOP)\src\shell.c \
+               -DINCLUDE_MSVC_H=1 $(TOP)\src\shell.c \
                /link $(LTLINKOPTS) $(LTLIBPATHS) libsqlite3.lib $(LIBRESOBJS) $(LIBREADLINE) $(LTLIBS) $(TLIBS)
 
 mptester.exe:  $(TOP)\mptest\mptest.c libsqlite3.lib $(LIBRESOBJS) sqlite3.h
@@ -1040,7 +1068,8 @@ lempar.c: $(TOP)\src\lempar.c
        copy $(TOP)\src\lempar.c .
 
 lemon.exe:     $(TOP)\tool\lemon.c lempar.c
-       $(BCC) -Daccess=_access -Fe$@ $(TOP)\tool\lemon.c /link $(NLTLINKOPTS) $(NLTLIBPATHS)
+       $(BCC) $(NO_WARN) -Daccess=_access \
+               -Fe$@ $(TOP)\tool\lemon.c /link $(NLTLINKOPTS) $(NLTLIBPATHS)
 
 # Rules to build individual *.lo files from generated *.c files. This
 # applies to:
@@ -1311,7 +1340,8 @@ sqlite3.h:        $(TOP)\src\sqlite.h.in $(TOP)\manifest.uuid $(TOP)\VERSION
        $(TCLSH_CMD) $(TOP)\tool\mksqlite3h.tcl $(TOP:\=/) > sqlite3.h
 
 mkkeywordhash.exe:     $(TOP)\tool\mkkeywordhash.c
-       $(BCC) -Fe$@ $(REQ_FEATURE_FLAGS) $(OPT_FEATURE_FLAGS) $(OPTS) $(TOP)\tool\mkkeywordhash.c /link $(NLTLINKOPTS) $(NLTLIBPATHS)
+       $(BCC) $(NO_WARN) -Fe$@ $(REQ_FEATURE_FLAGS) $(OPT_FEATURE_FLAGS) $(OPTS) \
+               $(TOP)\tool\mkkeywordhash.c /link $(NLTLINKOPTS) $(NLTLIBPATHS)
 
 keywordhash.h: $(TOP)\tool\mkkeywordhash.c mkkeywordhash.exe
        .\mkkeywordhash.exe > keywordhash.h
index 0d9c27f6359cd2b052d52624970a33ce6f688c49..706261fc009aa67a1eb7a38969d454fce627f4bc 100644 (file)
@@ -253,6 +253,7 @@ SRC = \
   $(TOP)/src/mem3.c \
   $(TOP)/src/mem5.c \
   $(TOP)/src/memjournal.c \
+  $(TOP)/src/msvc.h \
   $(TOP)/src/mutex.c \
   $(TOP)/src/mutex.h \
   $(TOP)/src/mutex_noop.c \
@@ -414,6 +415,7 @@ HDR = \
    $(TOP)/src/hash.h \
    $(TOP)/src/hwtime.h \
    keywordhash.h \
+   $(TOP)/src/msvc.h \
    $(TOP)/src/mutex.h \
    opcodes.h \
    $(TOP)/src/os.h \
diff --git a/main.mk b/main.mk
index e2213bc62c839c677ba583f223763c1d62f6cb0e..61ab533ae26a5a4bed630579a5554cda27bc78cf 100644 (file)
--- a/main.mk
+++ b/main.mk
@@ -112,6 +112,7 @@ SRC = \
   $(TOP)/src/mem3.c \
   $(TOP)/src/mem5.c \
   $(TOP)/src/memjournal.c \
+  $(TOP)/src/msvc.h \
   $(TOP)/src/mutex.c \
   $(TOP)/src/mutex.h \
   $(TOP)/src/mutex_noop.c \
@@ -345,6 +346,7 @@ HDR = \
    $(TOP)/src/hash.h \
    $(TOP)/src/hwtime.h \
    keywordhash.h \
+   $(TOP)/src/msvc.h \
    $(TOP)/src/mutex.h \
    opcodes.h \
    $(TOP)/src/os.h \
index 863ceeeee8f5c601e3e5027d9e2b7b4e4c6e0c5a..b5277634ea275046f0ea703e4f67cc62ec392a2c 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,10 +1,10 @@
-C Add\sSQLITE_ENABLE_STMT_SCANSTATUS\sto\sthe\sUpdate-Delete-Limit\sconfiguration\nin\sthe\sreleasetest.tcl\sscript.
-D 2015-01-09T20:00:21.586
+C Work\sin\sprogress\son\sfixing\sharmless\scompiler\swarnings\swhen\susing\s-W4\sand\sMSVC.
+D 2015-01-12T18:02:52.080
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
-F Makefile.in b40b4c2a3a187c41ee657d3f0e0e0dfe8fd860b5
+F Makefile.in 33a180534a9ba2cf80f5f87e8288c26423d0a8d1
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
-F Makefile.msc b363b90fe1bfc3b87d190f2f728a126c00d9ce09
-F Makefile.vxworks 034289efa9d591b04b1a73598623119c306cbba0
+F Makefile.msc 2ed20e3ee252eb85dea357940a2e5e5649f9dd86
+F Makefile.vxworks e1b65dea203f054e71653415bd8f96dcaed47858
 F README.md d58e3bebc0a4145e0f2a87994015fdb575a8e866
 F VERSION d846487aff892625eb8e75960234e7285f0462fe
 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50
@@ -152,7 +152,7 @@ F ext/userauth/userauth.c 5fa3bdb492f481bbc1709fc83c91ebd13460c69e
 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x
 F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60
-F main.mk 9f8c54fe62b60e0a24a2e65cfc8d2add063dda07
+F main.mk 1d0cf88b6e89249608677215ad36e4f8a231accc
 F mkopcodec.awk c2ff431854d702cdd2d779c9c0d1f58fa16fa4ea
 F mkopcodeh.awk c6b3fa301db6ef7ac916b14c60868aeaec1337b5
 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83
@@ -203,6 +203,7 @@ F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3
 F src/mem3.c 61c9d47b792908c532ca3a62b999cf21795c6534
 F src/mem5.c 61eeb90134f9a5be6c2e68d8daae7628b25953fb
 F src/memjournal.c 3eb2c0b51adbd869cb6a44780323f05fa904dc85
+F src/msvc.h e77df50d66fe9d2845c1692bd415f10ed2da7ea6
 F src/mutex.c 19bf9acba69ca2f367c3761080f8a9f0cf4670a8
 F src/mutex.h 779d588e3b7756ec3ecf7d78cde1d84aba414f85
 F src/mutex_noop.c f3f09fd7a2eb4287cfc799753ffc30380e7b71a1
@@ -229,11 +230,11 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696
 F src/resolve.c f6c46d3434439ab2084618d603e6d6dbeb0d6ada
 F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e
 F src/select.c e4c38c75e36f28aed80a69a725d888751bfd53df
-F src/shell.c 1b7cb3efc5ae6fe82e36407508c4a6b00d8edde1
+F src/shell.c 0cebd04b204051652e969773af70feb42cf9bc2b
 F src/sqlite.h.in 9dfc99d6533d36d6a549c4f3f01cacc8be956ada
 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
 F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d
-F src/sqliteInt.h 5d5716d8b33a61606c6ee10112f4b6df56f42725
+F src/sqliteInt.h f25fe9df72dfee0eedfde4bacd0f02077d557631
 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
 F src/status.c 81712116e826b0089bb221b018929536b2b5406f
 F src/table.c e7a09215315a978057fb42c640f890160dbcc45e
@@ -1193,7 +1194,7 @@ F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439
 F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4
 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5
 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce
-F tool/lemon.c 20f3132a1a150d50b022aa0b1fa26bd46aebf7b5
+F tool/lemon.c 1864c4fe4a72b1bb28f1792b60504804fe82c5d2
 F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc
 F tool/logest.c eef612f8adf4d0993dafed0416064cf50d5d33c6
 F tool/mkautoconfamal.sh 5dc5010e2e748a9e1bba67baca5956a2c2deda7b
@@ -1201,10 +1202,10 @@ F tool/mkkeywordhash.c dfff09dbbfaf950e89af294f48f902181b144670
 F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e
 F tool/mkpragmatab.tcl 07a5124cf2dbafa1b375eefcf8ac4227028b0f8b
 F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97
-F tool/mksqlite3c-noext.tcl 88a1e3b0c769773fb7a9ebb363ffc603a4ac21d8
-F tool/mksqlite3c.tcl e94bdc37b531bba50d421e82efbe3738d0c1e950
+F tool/mksqlite3c-noext.tcl 9ef48e1748dce7b844f67e2450ff9dfeb0fb4ab5
+F tool/mksqlite3c.tcl cfde806851c413db7689b9cb74a4eeb92539c601
 F tool/mksqlite3h.tcl ba24038056f51fde07c0079c41885ab85e2cff12
-F tool/mksqlite3internalh.tcl b6514145a7d5321b47e64e19b8116cc44f973eb1
+F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b
 F tool/mkvsix.tcl 52a4c613707ac34ae9c226e5ccc69cb948556105
 F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091
 F tool/omittest.tcl 34d7ac01fe4fd18e3637f64abe12c40eca0f6b97
@@ -1235,7 +1236,10 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 88a7a967116a48aeb5fa7014613c0134b1b47bb3
-R 366d7baead37fb35af2c9724ea29fa87
-U drh
-Z 19a0bf2d773a4306e8c2ab9a5efe117f
+P c70d5edaf6327cb18df5285c3fc21b610f3d3294
+R 88ff3b896a4782d7ebc798cf681238f7
+T *branch * msvcW4
+T *sym-msvcW4 *
+T -sym-trunk *
+U mistachkin
+Z 8d2294254b24b7823d46df8b0b6fe494
index 2626721cdae4aa9258f38ae576954c3b03420af9..7afa69b53934a7d57f439dc3af725fba65703569 100644 (file)
@@ -1 +1 @@
-c70d5edaf6327cb18df5285c3fc21b610f3d3294
\ No newline at end of file
+856dd245ce037f93d5ae2ddeb4fdf949c1e5c8e9
\ No newline at end of file
diff --git a/src/msvc.h b/src/msvc.h
new file mode 100644 (file)
index 0000000..f5d6752
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+** 2015 January 12
+**
+** The author disclaims copyright to this source code.  In place of
+** a legal notice, here is a blessing:
+**
+**    May you do good and not evil.
+**    May you find forgiveness for yourself and forgive others.
+**    May you share freely, never taking more than you give.
+**
+******************************************************************************
+**
+** This file contains code that is specific to Windows.
+*/
+#ifndef _MSVC_H_
+#define _MSVC_H_
+
+#if defined(_MSC_VER)
+#pragma warning(disable : 4100)
+#pragma warning(disable : 4127)
+#pragma warning(disable : 4232)
+#pragma warning(disable : 4244)
+/* #pragma warning(disable : 4701) */
+/* #pragma warning(disable : 4706) */
+#endif
+
+#endif /* _MSVC_H_ */
index 7f8a9ef3a69c9e17f8db6d5f480c6432da1642aa..b7a8fa8b00b5b28c0415b1457b913aebb3998d81 100644 (file)
 #define _CRT_SECURE_NO_WARNINGS
 #endif
 
+/*
+** If requested, include the SQLite compiler options file for MSVC.
+*/
+#if defined(INCLUDE_MSVC_H)
+#include "msvc.h"
+#endif
+
 /*
 ** Enable large-file support for fopen() and friends on unix.
 */
index 0a1948fef8b14ec4a74b743414b9d8568312572f..3c591ca1cd463da6124e8115a6add602ed6a3a0e 100644 (file)
 #ifndef _SQLITEINT_H_
 #define _SQLITEINT_H_
 
+/*
+** Include the header file used to customize the compiler options for MSVC.
+** This should be done first so that it can successfully prevent spurious
+** compiler warnings due to subsequent content in this file and other files
+** that are included by this file.
+*/
+#include "msvc.h"
+
 /*
 ** These #defines should enable >2GB file support on POSIX if the
 ** underlying operating system supports it.  If the OS lacks
index 54c155204ae30256c6146d4f87b2699626d9033b..4ada425d6931d8af2df8eba63a053a66d3ac8cda 100644 (file)
@@ -2442,7 +2442,7 @@ to follow the previous rule.");
       if( x[0]=='{' || x[0]=='\"' || isalnum(x[0]) ){
         const char *zOld, *zNew;
         char *zBuf, *z;
-        int nOld, n, nLine, nNew, nBack;
+        int nOld, n, nLine = 0, nNew, nBack;
         int addLineMacro;
         char zLine[50];
         zNew = x;
@@ -2641,7 +2641,7 @@ void Parse(struct lemon *gp)
   struct pstate ps;
   FILE *fp;
   char *filebuf;
-  int filesize;
+  unsigned int filesize;
   int lineno;
   int c;
   char *cp, *nextcp;
@@ -2775,7 +2775,7 @@ void Parse(struct lemon *gp)
     c = *cp;
     *cp = 0;                        /* Null terminate the token */
     parseonetoken(&ps);             /* Parse the token */
-    *cp = c;                        /* Restore the buffer */
+    *cp = (char)c;                  /* Restore the buffer */
     cp = nextcp;
   }
   free(filebuf);                    /* Release the buffer after parsing */
@@ -3398,7 +3398,7 @@ PRIVATE char *append_str(const char *zText, int n, int p1, int p2){
       zText++;
       n--;
     }else{
-      z[used++] = c;
+      z[used++] = (char)c;
     }
   }
   z[used] = 0;
index f54b347be140ed19f4728660e96ec2f122f32e10..27522265bb015e499a56742e4652a1ec7ba82746 100644 (file)
@@ -96,6 +96,7 @@ foreach hdr {
    hash.h
    hwtime.h
    keywordhash.h
+   msvc.h
    mutex.h
    opcodes.h
    os_common.h
index 72098c7357bd3d6d6e20c50b4024db1ed40edcf0..1d597a51a09a27d987eb918203340024f41817e3 100644 (file)
@@ -100,6 +100,7 @@ foreach hdr {
    hash.h
    hwtime.h
    keywordhash.h
+   msvc.h
    mutex.h
    opcodes.h
    os_common.h
index 7e92b3ad7dd02e8db09764f2d09c16e27439b2af..8db593fe756316c8236817628f8fb8e4203efa16 100644 (file)
@@ -58,6 +58,7 @@ foreach hdr {
    hash.h
    hwtime.h
    keywordhash.h
+   msvc.h
    opcodes.h
    os_common.h
    os_setup.h