]> andersk Git - splint.git/blobdiff - src/exprNode.c
Fixes for win32
[splint.git] / src / exprNode.c
index 1e6da49868544aa2e007426ef547f5cdfe9efe94..578469ad4a7a357753ba32fcb06a6608f82c3b57 100644 (file)
@@ -1247,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); 
+                   }
                }
             }
         }
@@ -1327,6 +1330,15 @@ exprNode_arrayFetch (/*@only@*/ exprNode e1, /*@only@*/ exprNode e2)
                              exprNode_unparse (e1), exprNode_unparse (e2)),
                     arr->loc);
                }
+              else if (ctype_isNumAbstract (rt))
+               {
+                 vnoptgenerror 
+                   (FLG_NUMABSTRACTINDEX,
+                    message ("Array fetch using numabstract type, %t: %s[%s]",
+                             ind->typ, 
+                             exprNode_unparse (e1), exprNode_unparse (e2)),
+                    arr->loc);
+               }
               else
                {
                  voptgenerror 
@@ -1620,11 +1632,9 @@ checkPrintfArgs (/*@notnull@*/ /*@dependent@*/ exprNode f, uentry fcn,
                          expecttype = ctype_makeConj (ctype_int, 
                                                       ctype_makeConj (ctype_char,
                                                                       ctype_uchar));
-                         /*@i231@*/
                          /* evans 2001-10-05 - changed to reflect correct ISO spec:
                             int converted to char */
                          
-                         /* expecttype = ctype_makeConj (ctype_char, ctype_uchar); */
                          /*@switchbreak@*/ break;
                              
                        case 's': /* string */
@@ -2233,7 +2243,7 @@ checkMessageArgs (/*@notnull@*/ /*@dependent@*/ exprNode f,
                                            codetext, expecttype,
                                            a->typ, exprNode_unparse (a)),
                                   a->loc))
-                                 {
+                               {
                                  if (fileloc_isDefined (formatloc)
                                      && context_getFlag (FLG_SHOWCOL))
                                    {
@@ -3698,7 +3708,7 @@ checkRequiresClause (uentry le, exprNode f, exprNodeList args)
                          
                          if (sRef_isResult (sRef_getRootBase (sel)))
                            {
-                             ; /*@i423 what do we do about results */
+                             ; /* what do we do about results? */
                            }
                          else
                            {
@@ -4413,12 +4423,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); */
   
@@ -4452,6 +4456,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
+         {}
       }
     }
     
@@ -4463,7 +4469,6 @@ exprNode_postOp (/*@only@*/ exprNode e, /*@only@*/ lltok op)
       }
     }
   }
-  /*@end@*/
   /* end modifications */
 
   return ret;
@@ -6467,8 +6472,8 @@ exprNode_vaArg (/*@only@*/ lltok tok, /*@only@*/ exprNode arg, /*@only@*/ qtype
       */
 
       if (!ctype_isUA (targ) ||
-         (!usymId_equal (ctype_typeId (targ), 
-                        usymtab_getTypeId (cstring_makeLiteralTemp ("va_list")))))
+         (!typeId_equal (ctype_typeId (targ), 
+                         usymtab_getTypeId (cstring_makeLiteralTemp ("va_list")))))
        {
          voptgenerror
            (FLG_TYPE,
@@ -6779,8 +6784,7 @@ exprNode exprNode_concat (/*@only@*/ exprNode e1, /*@only@*/ exprNode e2)
 
 exprNode exprNode_createTok (/*@only@*/ lltok t)
 {
-  exprNode ret; /*@i23 if on same line, bad things happen...!@*/
-  ret = exprNode_create (ctype_unknown);
+  exprNode ret = exprNode_create (ctype_unknown);
   ret->kind = XPR_TOK;
   ret->edata = exprData_makeTok (t);
   return ret;
@@ -6993,7 +6997,6 @@ exprNode exprNode_if (/*@only@*/ exprNode pred, /*@only@*/ exprNode tclause)
             exprNode_loc (pred));
        }
       
-      /*! exprNode_checkPred (cstring_makeLiteralTemp ("if"), pred); */ /*@i523@*/
       exprNode_checkUse (pred, pred->sref, pred->loc);
       
       if (!exprNode_isError (tclause))
@@ -7122,9 +7125,7 @@ exprNode exprNode_ifelse (/*@only@*/ exprNode pred,
             exprNode_loc (pred));
        }
       
-      /*@i3423 exprNode_checkPred (cstring_makeLiteralTemp ("if"), pred);*/
       exprNode_checkUse (ret, pred->sref, pred->loc);
-      
       exprNode_mergeCondUSs (ret, tclause, eclause);
     }
 
@@ -8498,37 +8499,6 @@ exprNode_makeInitializationAux (/*@temp@*/ idDecl t)
     {
       uentry ue = usymtab_lookup (idDecl_observeId (t));
       ret = exprNode_createId (ue);
-
-      /*@i723 don't do this...but why? */
-# if 0
-      ct = ctype_realishType (ret->typ);
-
-      DPRINTF (("Type: %s", ctype_unparse (ret->typ)));
-
-      if (ctype_isUnknown (ct)) 
-       {
-         if (uentry_isAnyTag (ue))
-           {
-             voptgenerror
-               (FLG_IMPTYPE,
-                message ("%s used but not previously declared: %s",
-                         uentry_ekindName (ue),
-                         idDecl_getName (t)),
-                g_currentloc);
-             
-           }
-         else
-           {
-             voptgenerror
-               (FLG_IMPTYPE,
-                message ("Variable has unknown (implicitly int) type: %s",
-                         idDecl_getName (t)),
-                g_currentloc);
-           }
-
-         ct = ctype_int;
-       }
-# endif
     }
   else
     {
@@ -8537,9 +8507,6 @@ exprNode_makeInitializationAux (/*@temp@*/ idDecl t)
       DPRINTF (("Unrecognized: %s", idDecl_unparse (t)));
 
       ue = uentry_makeUnrecognized (idDecl_observeId (t), fileloc_copy (g_currentloc));
-      /*!! fileloc_copy (g_currentloc)); */
-      /*@i32!!! should get error without this */
-
       ret = exprNode_fromIdentifierAux (ue);
 
       /*
@@ -11109,6 +11076,7 @@ doAssign (/*@notnull@*/ exprNode e1, /*@notnull@*/ exprNode e2, bool isInit)
       ctype ct = sRef_getType (sr);
 
       if (ctype_isAbstract (t2) 
+         && !ctype_isNumAbstract (t2)
          && !(uentry_isMutableDatatype (usymtab_getTypeEntry (ctype_typeId (t2)))))
        {
          /* it is immutable, okay to reference */
@@ -11527,3 +11495,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.042303 seconds and 4 git commands to generate.