]> andersk Git - splint.git/commitdiff
Fixed problem with handleing oldsytle function declarations.
authordrl7x <drl7x>
Mon, 4 Feb 2002 09:19:34 +0000 (09:19 +0000)
committerdrl7x <drl7x>
Mon, 4 Feb 2002 09:19:34 +0000 (09:19 +0000)
(Problem reported by Thomas Nordin)

src/Headers/context.h
src/context.c
src/cstring.c
src/exprNode.c
src/uentry.c
test/Makefile
test/oldstyle.expect
test/oldstyle2.c [new file with mode: 0644]

index 2a1ebb093092c70d385f3faaaa4d8d045180d596..c357e84ed31b51eb544df15b44c677832f644f96 100644 (file)
@@ -346,7 +346,7 @@ extern int context_getBugsLimit (void) /*@*/ ;
 extern bool hasInvariants (ctype p_ct);
 
 /*drl 1/6/2001: I didn't think these functions were solid enough to include in the
-  stable  release of splint.  I coomented them out so that they won't break anything
+  stable  release of splint.  I commented them out so that they won't break anything
   but didn't delete them because they will be fixed and included later
 */
 
@@ -361,7 +361,9 @@ extern bool hasInvariants (ctype p_ct);
 ctype context_setLastStruct (/*@returned@*/ ctype p_s) /*@modifies internalState@*/;
 ctype context_getLastStruct (/*@returned@*/ /*ctype p_s*/) /*@modifies internalState@*/;
 
+/*drl added 2/4/2002*/
 
+  bool context_inOldSytleScope(void);
 # else
 # error "Multiple include"
 # endif
index 6df5dde47519fd6b84355436801a6a9b82e31192..361692a8f820e29f4b778b3336498129c9452504 100644 (file)
@@ -1864,6 +1864,14 @@ context_enterFunction (/*@exposed@*/ uentry e)
   sRef_enterFunctionScope ();
 }
 
+bool context_inOldSytleScope(void)
+{
+  if (gc.kind == CX_OLDSTYLESCOPE)
+    return TRUE;
+  else
+    return FALSE;
+}
+
 void
 context_enterOldStyleScope (void)
 {
index 04fa8a299c9d642ff4b7d198678b5e026e9463ab..987e58b470408185f37c191e2b134b8188d83c1d 100644 (file)
@@ -513,6 +513,9 @@ void cstring_free (/*@only@*/ cstring s)
 {
   if (cstring_isDefined (s)) 
     {
+      /*drl 2/3/2002*/
+      s[0] = '\0';
+      
       sfree (s);
     }
 }
index fbccd3410ff157da05351b7815416238bd7ab7fd..a55acda5c23a3323e059b25ef3a321e09f24d911 100644 (file)
@@ -7035,6 +7035,9 @@ checkSwitchExpr (exprNode test, /*@dependent@*/ exprNode e, /*@out@*/ bool *allp
 
   exprNodeSList_elements (el, current)
     {
+      
+      DPRINTF ((message("checkSwitchExpr current = %s ", exprNode_unparse(current) ) ));
+      
       if (exprNode_isDefined (current))
        {
          switch (current->kind)
index 4c08dc76c2b95ea6cbe8e19ad7c795e363bb89c8..ac39bb6ba577df17170f97cd93e2aca70873a051 100644 (file)
@@ -11061,7 +11061,7 @@ void uentry_checkName (uentry ue)
   fileloc_free (tloc);
   uentry_setHasNameError (ue);
   
-  if (context_getFlag (FLG_REPEATUNRECOG))
+  if (context_getFlag (FLG_REPEATUNRECOG) || (context_inOldSytleScope() ) )
     {
       uentry_markOwned (ue);
     }
index 001119e5c615489a742f592dd590506bd790eba4..e7ab33df43cbcdbc9abdf2b74f40e24d1cd42da0 100644 (file)
@@ -120,7 +120,7 @@ UNITTESTS = \
   funcpointer functionmacro glob globals impabstract info init inparam internal iter keep libs \
   linked lintcomments list loopexec \
   macros macrosef merge mergenull modifies modtest moduncon \
-  mongoincludes mystrncat noeffect null observer oldstyle outglob outparam \
+  mongoincludes mystrncat noeffect null observer oldstyle  outglob outparam \
   postnotnull preds prefixes printflike rc refcounts release repexpose \
   returned sharing shifts slovaknames \
   specclauses \
@@ -377,6 +377,7 @@ EXTRA_DIST = ./abst_t.lcl ./abst_t.lcs  \
               ./nullret.c \
               ./observer.c \
               ./oldstyle.c \
+              ./oldstyle2.c \
               ./outglob.c \
               ./outparam.c \
               ./postnotnull.c \
@@ -1391,7 +1392,7 @@ observer:
 
 .PHONY: oldstyle
 oldstyle:
-       -$(SPLINTR) oldstyle -expect 3
+       -$(SPLINTR) oldstyle oldstyle2.c -expect 5
 
 .PHONY: outglob
 outglob:
index 0af2ab888b96a8e340c96d61096fc782a2939e0a..833ef6d799931007624cb10041452b6036cd59c2 100644 (file)
@@ -6,5 +6,9 @@ oldstyle.c:10:5: Function f2 declared with 1 arg, specified with 2
 oldstyle.c:15:12: Parameter 2, y, of function f3 has inconsistent type:
                      declared char, specified char *
    oldstyle.lcl:4:1: Specification of y: char *
+oldstyle2.c: (in function noShadow)
+oldstyle2.c:15:14: Statement after switch is not a case: int x
+oldstyle2.c: (in function unrecognized)
+oldstyle2.c:29:6: Unrecognized identifier: x
 
-Finished checking --- 3 code warnings, as expected
+Finished checking --- 5 code warnings, as expected
diff --git a/test/oldstyle2.c b/test/oldstyle2.c
new file mode 100644 (file)
index 0000000..38c55ae
--- /dev/null
@@ -0,0 +1,31 @@
+
+void
+oldDec(x)
+     int x; 
+{
+  x = 5;
+} 
+
+
+void
+noShadow()
+{   
+   switch (0)
+         {
+           int   x;
+                 case 0:
+               {  x = 0;}
+        }
+}   
+
+
+
+void
+unrecognized()
+{   
+   switch (0)
+         {
+         case 0:
+               {  x = 0;}
+        }
+}   
This page took 0.086385 seconds and 5 git commands to generate.