]> andersk Git - splint.git/commitdiff
Fixed problem with assertion checking for negative shifts in
authorevans1629 <evans1629>
Tue, 18 May 2004 19:07:46 +0000 (19:07 +0000)
committerevans1629 <evans1629>
Tue, 18 May 2004 19:07:46 +0000 (19:07 +0000)
preprocessor expressions.  (Should add a warning for these).

Some problems with make splintme not yet resolved.

src/Headers/cstringTable.h
src/cppexp.c
src/cpplib.c
src/cscannerHelp.c
src/cstringTable.c
src/lcllib.c
src/llmain.c
src/osd.c

index 0f798c69f4f5c12d9649d34747c41c98800651a2..ea3ddf1a559b803bb878135e825ddabc95e708dc 100644 (file)
@@ -39,7 +39,7 @@ typedef /*@only@*/ hbucket o_hbucket;
 
 struct s_cstringTable
 {
-  int size;
+  unsigned long size;
   int nentries;
   /*@only@*/ o_hbucket *buckets;
 } ;
index 60f16b015340d9a2c167b41b2b7cd68ee65c1371..2cdc8a50a8bb6657b4363b65d797c939d11b8bcc 100644 (file)
@@ -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.  */
index 4b4e1622b967d8918c902f724e5a1b2d7e85591b..edafd9e7534e0c25fcf91b53b512cd90a8771bd1 100644 (file)
@@ -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...
index ae202f4ecdbd9b2f118811159f62284e149ee573..8ecc2114c74ad6a9e547ab0d77e500cf7a9c08a0 100644 (file)
@@ -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);
index 61be3f776642aaaf3f046a7b93dee6e2ecb021e2..d53ab14f80a9eb55bdc75eb28bab362040f83f53 100644 (file)
@@ -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;  
index 205cbe44e233efd4ddbdf4599b1b028da5cdd61a..46b028ed13f67e875b8176f464818990e3b213d6 100644 (file)
@@ -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);
index e2b29b591d464f87896ed3579442684c3a09c451..40178a3f162f5569f82be1eff35680c7791fdc66 100644 (file)
@@ -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);
     }
 }
index 00149429fa998191e8d753b3bc9027b186eee730..d6ca8a5efc0caa28ff3c2104af76987da4742967 100644 (file)
--- 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;
This page took 0.078054 seconds and 5 git commands to generate.