]> andersk Git - splint.git/blobdiff - src/exprNode.c
Fixed /*@i@*/ warning in splintme
[splint.git] / src / exprNode.c
index 828ef6c8d0df8a5d1aa3fc5aeab62a333624c3df..403dbabab809c52e87b9cdaada8190b68f0be9a4 100644 (file)
@@ -1,6 +1,6 @@
 /*
 ** Splint - annotation-assisted static program checker
-** Copyright (C) 1994-2002 University of Virginia,
+** Copyright (C) 1994-2003 University of Virginia,
 **         Massachusetts Institute of Technology
 **
 ** This program is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
 # include "basic.h"
 # include "cgrammar.h"
 # include "cscanner.h"
+# include "cscannerHelp.h"
 # include "cgrammar_tokens.h"
 
 # include "exprChecks.h"
@@ -1036,7 +1037,7 @@ exprNode_fromIdentifier (/*@observer@*/ uentry c)
 
   if (context_justPopped ()) /* watch out! c could be dead */
     { 
-      uentry ce = usymtab_lookupSafe (cscanner_observeLastIdentifier ());
+      uentry ce = usymtab_lookupSafe (cscannerHelp_observeLastIdentifier ());
 
       if (uentry_isValid (ce)) 
         {
@@ -1246,18 +1247,21 @@ exprNode_arrayFetch (/*@only@*/ exprNode e1, /*@only@*/ exprNode e2)
         {
           if (!usymtab_isGuarded (arr->sref))
             {
-              if (optgenerror (FLG_NULLDEREF,
-                              message ("Index of %s pointer %q: %s", 
-                                       sRef_nullMessage (arr->sref),
-                                       sRef_unparse (arr->sref),
-                                       exprNode_unparse (arr)),
-                              arr->loc))
-               {
-                 DPRINTF (("ref: %s", sRef_unparseFull (arr->sref)));
-                 sRef_showNullInfo (arr->sref);
-
-                 /* suppress future messages */
-                 sRef_setNullError (arr->sref); 
+             if (!context_inSizeof() )
+               {
+                 if (optgenerror (FLG_NULLDEREF,
+                                  message ("Index of %s pointer %q: %s", 
+                                           sRef_nullMessage (arr->sref),
+                                           sRef_unparse (arr->sref),
+                                           exprNode_unparse (arr)),
+                                  arr->loc))
+                   {
+                     DPRINTF (("ref: %s", sRef_unparseFull (arr->sref)));
+                     sRef_showNullInfo (arr->sref);
+                     
+                     /* suppress future messages */
+                     sRef_setNullError (arr->sref); 
+                   }
                }
             }
         }
@@ -4412,12 +4416,6 @@ exprNode_postOp (/*@only@*/ exprNode e, /*@only@*/ lltok op)
   exprNode_checkModify (e, ret);
 
   /* added 7/11/2000 D.L */
-  /*@i223*/ 
-  /*DRL 6/8/01 I decided to disable all Splint warnings here since the code 
-    probably needs a rewrite any way */
-
-  /*@i65234@*/
-  /*@ignore@*/
 
   /* updateEnvironmentForPostOp (e); */
   
@@ -4451,6 +4449,8 @@ exprNode_postOp (/*@only@*/ exprNode e, /*@only@*/ lltok op)
          printf ("ret->sref is Possibly Null Terminated\n");
        else if (sRef_isNotNullTerminated (ret->sref))
          printf ("ret->sref is Not Null Terminated\n");
+       else
+         {}
       }
     }
     
@@ -4462,7 +4462,6 @@ exprNode_postOp (/*@only@*/ exprNode e, /*@only@*/ lltok op)
       }
     }
   }
-  /*@end@*/
   /* end modifications */
 
   return ret;
@@ -10192,16 +10191,20 @@ exprNode_checkUse (exprNode e, /*@exposed@*/ sRef s, fileloc loc)
                    {
                      lastRef = errorRef;
                      errorRef = s;
+                     DPRINTF (("Setting ERROR: %s", sRef_unparseFull (s)));
                      deadRef = sRef_isDead (errorRef);
                      unuseable = sRef_isUnuseable (errorRef);
                      errorMaybe = FALSE;
                    }
 
+                 /*
                  if (!sRef_isPartial (s))
                    {
                      DPRINTF (("Defining! %s", sRef_unparseFull (s)));
-                     sRef_setDefined (s, fileloc_undefined);
+                     sRef_setDefined (s, loc);
+                     DPRINTF (("Defining! %s", sRef_unparseFull (s)));
                    }
+                 */
                }
 
              s = sRef_getBaseSafe (s);
@@ -10213,6 +10216,7 @@ exprNode_checkUse (exprNode e, /*@exposed@*/ sRef s, fileloc loc)
                  && sRef_isPointer (errorRef))
                {
                  errorRef = lastRef;
+                 DPRINTF (("errorRef: %s", sRef_unparseFull (errorRef)));
                }
              
              if (deadRef)
@@ -10236,7 +10240,7 @@ exprNode_checkUse (exprNode e, /*@exposed@*/ sRef s, fileloc loc)
                    }
                  else
                    {
-                     DPRINTF (("HERE: %s", sRef_unparse (errorRef)));
+                     DPRINTF (("HERE: %s", sRef_unparseFull (errorRef)));
 
                      if (optgenerror
                          (FLG_USERELEASED,
@@ -10273,13 +10277,16 @@ exprNode_checkUse (exprNode e, /*@exposed@*/ sRef s, fileloc loc)
                {
                  DPRINTF (("HERE: %s", sRef_unparseFull (errorRef)));
 
-                 voptgenerror 
-                   (FLG_USEDEF,
-                    message ("%q %q%qused before definition", 
-                             sRef_unparseKindName (errorRef),
-                             sRef_unparseOpt (errorRef),
-                             cstring_makeLiteral (errorMaybe ? "may be " : "")),
-                    loc);
+                 if (optgenerror 
+                     (FLG_USEDEF,
+                      message ("%q %q%qused before definition", 
+                               sRef_unparseKindName (errorRef),
+                               sRef_unparseOpt (errorRef),
+                               cstring_makeLiteral (errorMaybe ? "may be " : "")),
+                      loc))
+                   {
+                     ;
+                   }
 
                  DPRINTF (("Error: %s", sRef_unparseFull (errorRef)));
                }
@@ -10875,12 +10882,24 @@ abstractOpError (ctype tr1, ctype tr2, lltok op,
            } 
          else 
            {
-             return optgenerror
-               (FLG_ABSTRACT,
-                message ("Operands of %s are abstract type (%t): %s %s %s",
-                         lltok_unparse (op), tr1, 
-                         exprNode_unparse (e1), lltok_unparse (op), exprNode_unparse (e2)),
-                loc1);
+             if (lltok_isEqOp (op) || lltok_isNotEqOp (op))
+               {
+                 return optgenerror
+                   (FLG_ABSTRACTCOMPARE,
+                    message ("Object equality comparison (%s) on objects of abstract type (%t): %s %s %s",
+                             lltok_unparse (op), tr1, 
+                             exprNode_unparse (e1), lltok_unparse (op), exprNode_unparse (e2)),
+                    loc1);
+               }
+             else
+               {
+                 return optgenerror
+                   (FLG_ABSTRACT,
+                    message ("Operands of %s are abstract type (%t): %s %s %s",
+                             lltok_unparse (op), tr1, 
+                             exprNode_unparse (e1), lltok_unparse (op), exprNode_unparse (e2)),
+                    loc1);
+               }
            }
        }
       else
@@ -11506,3 +11525,22 @@ bool exprNode_isInitBlock (exprNode e)
 {
   return (exprNode_isDefined(e) && e->kind == XPR_INITBLOCK);
 }
+
+/*drl 3/2/2003 moved this function out of constraint.c */
+exprNode exprNode_copyConstraints (/*@returned@*/ exprNode dst, exprNode src)
+{
+    
+  llassert (exprNode_isDefined (dst) );
+  llassert (exprNode_isDefined (src) ); 
+
+  constraintList_free (dst->ensuresConstraints);
+  constraintList_free (dst->requiresConstraints);
+  constraintList_free (dst->trueEnsuresConstraints);
+  constraintList_free (dst->falseEnsuresConstraints);
+  
+  dst->ensuresConstraints = constraintList_copy (src->ensuresConstraints);
+  dst->requiresConstraints = constraintList_copy (src->requiresConstraints);
+  dst->trueEnsuresConstraints = constraintList_copy (src->trueEnsuresConstraints);
+  dst->falseEnsuresConstraints = constraintList_copy (src->falseEnsuresConstraints);
+  return dst;
+}
This page took 0.126929 seconds and 4 git commands to generate.