]> andersk Git - splint.git/blobdiff - src/exprNode.c
Fixed problem with shadow parameters.
[splint.git] / src / exprNode.c
index b8a3c056dca8d3283f8d5a386e1eb9562b8e52dd..f082ecda733ecb445a8eee13cd708d045be97a71 100644 (file)
@@ -5009,8 +5009,8 @@ exprNode_cast (/*@only@*/ lltok tok, /*@only@*/ exprNode e, /*@only@*/ qtype q)
   ret->edata = exprData_makeCast (tok, e, q);
 
   ret->sref = sRef_copy (e->sref);
-  
-  DPRINTF (("Cast 2: -> %s", sRef_unparseFull (ret->sref)));
+
+  DPRINTF (("Cast: -> %s", sRef_unparseFull (ret->sref)));
 
   if (!sRef_isConst (e->sref))
     {
@@ -5594,34 +5594,38 @@ exprNode_makeOp (/*@keep@*/ exprNode e1, /*@keep@*/ exprNode e2,
             status */
          
          if ((sRef_isPossiblyNullTerminated (e2->sref)) || (sRef_isNullTerminated(e2->sref))) {
-           int val = (int) multiVal_forceInt (e1->val);
-           
-           /* Operator : + or += */
-           if ((lltok_getTok (op) == TPLUS) || (lltok_getTok(op) == ADD_ASSIGN)) {
-             if (sRef_getSize(e2->sref) >= val) {/* Incrementing the pointer by 
-                                                    val should not result in a 
-                                                    size < 0 (size = 0 is ok !) */
+           if (multiVal_isDefined (e1->val)) 
+             {
+               int val = (int) multiVal_forceInt (e1->val);
                
-               sRef_setSize (ret->sref, sRef_getSize(e2->sref) - val);
+               /* Operator : + or += */
+               if ((lltok_getTok (op) == TPLUS) || (lltok_getTok(op) == ADD_ASSIGN)) {
+                 if (sRef_getSize(e2->sref) >= val) {/* Incrementing the pointer by 
+                                                        val should not result in a 
+                                                        size < 0 (size = 0 is ok !) */
+                   
+                   sRef_setSize (ret->sref, sRef_getSize(e2->sref) - val);
+                   
+                   if (sRef_getLen(e2->sref) == val) { /* i.e. the character at posn val is \0 */
+                     sRef_setNotNullTerminatedState(ret->sref);
+                     sRef_resetLen (ret->sref);
+                   } else {
+                     sRef_setNullTerminatedState(ret->sref);
+                     sRef_setLen (ret->sref, sRef_getLen(e2->sref) - val);
+                   }
+                 }
+               }
                
-               if (sRef_getLen(e2->sref) == val) { /* i.e. the character at posn val is \0 */
-                 sRef_setNotNullTerminatedState(ret->sref);
-                 sRef_resetLen (ret->sref);
-               } else {
-                 sRef_setNullTerminatedState(ret->sref);
-                 sRef_setLen (ret->sref, sRef_getLen(e2->sref) - val);
+               /* Operator : - or -= */
+               if ((lltok_getTok (op) == TMINUS) || (lltok_getTok (op) == SUB_ASSIGN)) {
+                 if (sRef_getSize(e2->sref) >= 0) {
+                   sRef_setSize (ret->sref, sRef_getSize(e2->sref) + val);
+                   sRef_setLen (ret->sref, sRef_getLen(e2->sref) + val);
+                 }
                }
              }
-           }
-           
-           /* Operator : - or -= */
-           if ((lltok_getTok (op) == TMINUS) || (lltok_getTok (op) == SUB_ASSIGN)) {
-             if (sRef_getSize(e2->sref) >= 0) {
-               sRef_setSize (ret->sref, sRef_getSize(e2->sref) + val);
-               sRef_setLen (ret->sref, sRef_getLen(e2->sref) + val);
-             }
-           }
          }
+
          /* end modifications */
          
          sRef_setNullError (ret->sref);
@@ -10679,8 +10683,20 @@ static ctype
          DPRINTF (("No error: [%s] %s / [%s]  %s",
                    exprNode_unparse (e1), ctype_unparse (tr1),
                    exprNode_unparse (e2), ctype_unparse (tr2)));
+         
+         /*
+         ** evans 2003-06-15: changed this so if either type is a literal,
+         **    the other type is used.
+         **    (Need to look at the ISO C99 rules on this...)
+         */
 
-         ret = ctype_biggerType (tr1, tr2);
+         if (exprNode_isNumLiteral (e1)) {
+           ret = tr2;
+         } else if (exprNode_isNumLiteral (e2)) {
+           ret = tr1;
+         } else {
+           ret = ctype_biggerType (tr1, tr2);
+         }
        }
       else
        {
@@ -11505,3 +11521,13 @@ exprNode exprNode_copyConstraints (/*@returned@*/ exprNode dst, exprNode src)
   dst->falseEnsuresConstraints = constraintList_copy (src->falseEnsuresConstraints);
   return dst;
 }
+
+void exprNode_revealState (exprNode e)
+{
+  if (exprNode_isDefined (e)) {
+    llmsg (message ("%s: State of %s: %s", fileloc_unparse (exprNode_loc (e)), 
+                   exprNode_unparse (e), sRef_unparseFull (e->sref)));
+  } else {
+    llmsg (message ("%s: Reveal state undefined", fileloc_unparse (g_currentloc)));
+  }
+}
This page took 0.036294 seconds and 4 git commands to generate.