]> andersk Git - splint.git/blobdiff - src/constraintGeneration.c
Fixed bug preventing the expression of a return statement from being checked for errors.
[splint.git] / src / constraintGeneration.c
index c28817291abd8ff52b420a02cc654224f56c77a9..e3c0a1f5400ba73daefce377decd84f02cc3aa8a 100644 (file)
@@ -17,8 +17,8 @@
 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 ** MA 02111-1307, USA.
 **
-** For information on splint: splint@cs.virginia.edu
-** To report a bug: splint-bug@cs.virginia.edu
+** For information on splint: info@splint.org
+** To report a bug: splint-bug@splint.org
 ** For more information: http://www.splint.org
 */
 
@@ -42,6 +42,8 @@
 
 static bool exprNode_handleError(/*@dependent@*/ exprNode p_e);
 
+static void exprNode_stmt ( /*@dependent@*/ /*@temp@*/ exprNode p_e);
+
 static bool exprNode_isMultiStatement(/*@dependent@*/ exprNode p_e);
 static void  exprNode_multiStatement (/*@dependent@*/ exprNode p_e);
 
@@ -116,7 +118,7 @@ bool /*@alt void@*/ exprNode_generateConstraints (/*@dependent@*/ exprNode e)
   if (exprNode_isUnhandled (e) )
     {
       DPRINTF((message("Warning ignoring %s", exprNode_unparse (e) ) ) );
-        return FALSE;
+      return FALSE;
     }
 
   DPRINTF((message ("exprNode_generateConstraints Analysising %s at %s", exprNode_unparse( e),
@@ -128,13 +130,16 @@ bool /*@alt void@*/ exprNode_generateConstraints (/*@dependent@*/ exprNode e)
     }
   else
     {
-      fileloc loc;
+/*        fileloc loc; */
       
-      loc = exprNode_getNextSequencePoint(e); 
-      exprNode_exprTraverse(e, FALSE, FALSE, loc);
+/*        loc = exprNode_getNextSequencePoint(e);  */
+/*        exprNode_exprTraverse(e, FALSE, FALSE, loc); */
       
-      fileloc_free(loc);
+/*        fileloc_free(loc); */
+
+      exprNode_stmt(e);
       return FALSE;
+      
     }
   
   {
@@ -213,6 +218,22 @@ static void exprNode_stmt ( /*@dependent@*/ /*@temp@*/ exprNode e)
       constraintList_free(tempList);
       return; 
     }
+
+  /*drl 2/13/002 patched bug so return statement will be checked*/
+  /*return is a stmt not not expression ...*/
+  if (e->kind == XPR_RETURN)
+    {
+      constraintList tempList;
+      
+      loc = exprNode_getNextSequencePoint(e); /* reduces to an expression */
+      
+      exprNode_exprTraverse (exprData_getSingle (e->edata), FALSE, TRUE, loc);
+      fileloc_free(loc);
+      
+      tempList = e->requiresConstraints;
+      e->requiresConstraints = exprNode_traversRequiresConstraints(e);
+      constraintList_free(tempList);
+    }
   
   if (e->kind != XPR_STMT)
     {
@@ -224,9 +245,15 @@ static void exprNode_stmt ( /*@dependent@*/ /*@temp@*/ exprNode e)
        {
          exprNode_multiStatement (e); /* evans 2001-08-21: spurious return removed */
        }
-
-      DPRINTF((message ("Ignoring non-statement %s", exprNode_unparse(e) ) ) );
-      return; 
+      else
+       {
+         loc = exprNode_getNextSequencePoint(e); /* reduces to an expression */
+         
+         exprNode_exprTraverse (e, FALSE, TRUE, loc);
+         fileloc_free(loc);
+         
+         }
+         return; 
     }
  
   DPRINTF (("Stmt") );
@@ -2166,6 +2193,50 @@ constraintList exprNode_getPostConditions (exprNode fcn, exprNodeList arglist, e
   return postconditions;
 }
 
+/*
+comment this out for now
+we'll include it in a production release when its stable...
+
+  void findStructs ( exprNodeList arglist)
+{
+
+  ctype ct, rt;
+  
+  DPRINTF((
+          message("doing findStructs: %s", exprNodeList_unparse(arglist) )
+          ));
+
+
+  exprNodeList_elements(arglist, expr)
+    {
+      ct = exprNode_getType(expr);
+
+      rt =  ctype_realType (ct);
+      
+      if ( ctype_isStruct (rt ) )
+       TPRINTF(( message("Found structure %s", exprNode_unparse(expr) )
+                 ));
+      if (hasInvariants(ct) )
+       {
+         constraintList invars;
+
+         invars = getInvariants(ct);
+
+
+         TPRINTF(( message ("findStructs has invariants %s ", constraintList_print (invars) )
+                   ));
+         
+         invars = constraintList_doSRefFixStructConstraint(invars, exprNode_getSref(expr), ct );
+
+         
+         TPRINTF(( message ("findStructs finded invariants to be %s ", constraintList_print (invars) )
+                   ));
+       }
+    }
+  end_exprNodeList_elements;
+}
+
+*/
 
 /*drl moved out of constraintResolve.c 07-02-001 */
 constraintList checkCall (/*@dependent@*/ exprNode fcn, exprNodeList arglist)
@@ -2191,6 +2262,14 @@ constraintList checkCall (/*@dependent@*/ exprNode fcn, exprNodeList arglist)
     }
   DPRINTF (( message("Done checkCall\n") ));
   DPRINTF (( message("Returning list %q ", constraintList_printDetailed(preconditions) ) ));
+
+  /*
+    drl we're going to comment this out for now
+    we'll include it if we're sure it's working
+    
+    findStructs(arglist);
+  */
+  
   return preconditions;
 }
 
This page took 0.081416 seconds and 4 git commands to generate.