From: evans1629 Date: Tue, 18 May 2004 19:07:46 +0000 (+0000) Subject: Fixed problem with assertion checking for negative shifts in X-Git-Url: http://andersk.mit.edu/gitweb/splint.git/commitdiff_plain/b8dce3c7c286678208d27713c5380cfe35867101 Fixed problem with assertion checking for negative shifts in preprocessor expressions. (Should add a warning for these). Some problems with make splintme not yet resolved. --- diff --git a/src/Headers/cstringTable.h b/src/Headers/cstringTable.h index 0f798c6..ea3ddf1 100644 --- a/src/Headers/cstringTable.h +++ b/src/Headers/cstringTable.h @@ -39,7 +39,7 @@ typedef /*@only@*/ hbucket o_hbucket; struct s_cstringTable { - int size; + unsigned long size; int nentries; /*@only@*/ o_hbucket *buckets; } ; diff --git a/src/cppexp.c b/src/cppexp.c index 60f16b0..2cdc8a5 100644 --- a/src/cppexp.c +++ b/src/cppexp.c @@ -809,13 +809,14 @@ left_shift (cppReader *pfile, long a, bool unsignedp, unsigned long b) } else { - long l = int_toNonNegative (a) << b; + /*@-shiftimplementation@*/ + long l = a << b; /* int_toNonNegative removed (allow shifts of negative values) */ # ifdef WIN32 # pragma warning( disable : 4018 ) # endif - if (int_toNonNegative (l) >> b != a) + if (l >> b != a) /* int_toNonNegative removed (allow shifts of negative values) */ { integer_overflow (pfile); } @@ -832,7 +833,8 @@ right_shift (long a, bool unsignedp, unsigned long b) else if (unsignedp) return (unsigned long) a >> b; else - return int_toNonNegative (a) >> b; + return a >> b; /* int_toNonNegative removed (allow shifts of negative values) */ + /*@=shiftimplementation@*/ } /* These priorities are all even, so we can handle associatively. */ diff --git a/src/cpplib.c b/src/cpplib.c index 4b4e162..edafd9e 100644 --- a/src/cpplib.c +++ b/src/cpplib.c @@ -3757,7 +3757,9 @@ initialize_builtins (cppReader *pfile) /*drl 1/9/2001/ try to define the right symbol for the architecture We use autoconf to determine the target cpu */ +# ifndef S_SPLINT_S cpplib_installBuiltin ("__" TARGET_CPU, ctype_int, -1, T_CONST, 2, NULL, -1); +# endif /*drl 1/2/2002 set some flags based on uname I'd like to be able to do this with autoconf macro instead... diff --git a/src/cscannerHelp.c b/src/cscannerHelp.c index ae202f4..8ecc211 100644 --- a/src/cscannerHelp.c +++ b/src/cscannerHelp.c @@ -725,12 +725,12 @@ bool cscannerHelp_handleSpecial (char *yyt) cstring_free (exname); } - cscannerHelp_handleNewLine (); // evans 2003-10-27: pragment increments line + (void) cscannerHelp_handleNewLine (); /* evans 2003-10-27: pragment increments line */ } else if (cstring_equalPrefixLit (olc, "ident")) { /* Some pre-processors will leave these in the code. Ignore rest of line */ - cscannerHelp_handleNewLine (); // evans 2003-10-27: ident increments line + (void) cscannerHelp_handleNewLine (); /* evans 2003-10-27: ident increments line */ } /* @@ -839,7 +839,7 @@ bool cscannerHelp_handleSpecial (char *yyt) ** We handle a plain # in the input file, by echoing it, and ignoring it in the post-pp-file. */ mstring_free (ol); - cscannerHelp_handleNewLine (); // evans 2003-10-27: increments line + (void) cscannerHelp_handleNewLine (); /* evans 2003-10-27: increments line */ return FALSE; } else { voptgenerror @@ -847,7 +847,7 @@ bool cscannerHelp_handleSpecial (char *yyt) message ("Unrecognized pre-processor directive: #%s", cstring_fromChars (ol)), g_currentloc); - cscannerHelp_handleNewLine (); // evans 2003-10-27: increments line + (void) cscannerHelp_handleNewLine (); /* evans 2003-10-27: increments line */ } sfree (ol); diff --git a/src/cstringTable.c b/src/cstringTable.c index 61be3f7..d53ab14 100644 --- a/src/cstringTable.c +++ b/src/cstringTable.c @@ -200,7 +200,7 @@ void hbucket_free (/*@only@*/ hbucket h) void cstringTable_free (/*@only@*/ cstringTable h) { - int i; + unsigned int i; llassert (cstringTable_isDefined (h)); @@ -217,7 +217,7 @@ static int cstringTable_countCollisions (cstringTable h) { int nc = 0; - int i; + unsigned int i; llassert (cstringTable_isDefined (h)); @@ -234,7 +234,7 @@ static int cstringTable_countEmpty (cstringTable h) { int nc = 0; - int i; + unsigned int i; llassert (cstringTable_isDefined (h)); @@ -276,7 +276,7 @@ cstringTable_hash (/*@notnull@*/ cstringTable h, cstring key) /*@only@*/ cstringTable -cstringTable_create (int size) +cstringTable_create (unsigned int size) { int i; cstringTable h = (cstringTable) dmalloc (sizeof (*h)); @@ -297,7 +297,7 @@ cstringTable_create (int size) cstring cstringTable_unparse (cstringTable h) { cstring res = cstring_newEmpty (); - int i; + unsigned int i; if (cstringTable_isDefined (h)) { @@ -311,7 +311,7 @@ cstring cstringTable_unparse (cstringTable h) } } - res = message ("%qsize: %d, collisions: %d, empty: %d", + res = message ("%qsize: %u, collisions: %d, empty: %d", res, h->size, cstringTable_countCollisions (h), @@ -331,7 +331,7 @@ cstring cstringTable_unparse (cstringTable h) cstringTable_stats (cstringTable h) { llassert (cstringTable_isDefined (h)); - return (message ("size: %d, collisions: %d, empty: %d\n", + return (message ("size: %u, collisions: %d, empty: %d\n", h->size, cstringTable_countCollisions (h), cstringTable_countEmpty (h))); } @@ -343,9 +343,10 @@ cstringTable_rehash (/*@notnull@*/ cstringTable h) ** rehashing based (loosely) on code by Steve Harrison */ - int i; - int oldsize = h->size; - int newsize = 1 + ((oldsize * 26244) / 10000); /* 26244 = 162^2 */ + unsigned int i; + /* Fix provided by Thomas Mertz (int -> unsigned long), 21 Apr 2004 */ + unsigned long oldsize = h->size; + unsigned long newsize = 1 + ((oldsize * 26244) / 10000); /* 26244 = 162^2 */ hbucket *oldbuckets = h->buckets; h->size = newsize; diff --git a/src/lcllib.c b/src/lcllib.c index 205cbe4..46b028e 100644 --- a/src/lcllib.c +++ b/src/lcllib.c @@ -394,7 +394,8 @@ loadStandardState () *tt = '\0'; lldiagmsg (message ("Standard library: %s", fpath)); - lldiagmsg (message (" (created using %s)", cstring_fromChars (t))); + /* evans 2004-01-13: removed this (it is the libversion which is confusing) */ + /* lldiagmsg (message (" (created using %s)", cstring_fromChars (t))); */ } sfree (ot); diff --git a/src/llmain.c b/src/llmain.c index e2b29b5..40178a3 100644 --- a/src/llmain.c +++ b/src/llmain.c @@ -1221,7 +1221,7 @@ llinterrupt (int i) cstring_toCharsSafe (loc)); cstring_free (loc); printCodePoint (); - fprintf (g_errorstream, "*** Please report bug to %s\n", SPLINT_MAINTAINER); + fprintf (g_errorstream, "*** Please report bug to %s\n*** A useful bug report should include everything we need to reproduce the bug.\n", SPLINT_MAINTAINER); exit (LLGIVEUP); } default: @@ -1231,7 +1231,7 @@ llinterrupt (int i) cstring_toCharsSafe (fileloc_unparse (g_currentloc))); /*@=mustfree@*/ printCodePoint (); - fprintf (g_errorstream, "*** Please report bug to %s ***\n", SPLINT_MAINTAINER); + fprintf (g_errorstream, "*** Please report bug to %s\n*** A useful bug report should include everything we need to reproduce the bug.", SPLINT_MAINTAINER); exit (LLGIVEUP); } } diff --git a/src/osd.c b/src/osd.c index 0014942..d6ca8a5 100644 --- a/src/osd.c +++ b/src/osd.c @@ -514,7 +514,7 @@ osd_getPid () # if defined (WIN32) || defined (OS2) && defined (__IBMC__) int pid = _getpid (); # else - pid_t pid = getpid (); + __pid_t pid = getpid (); # endif return (int) pid;