]> andersk Git - splint.git/blobdiff - src/usymtab_interface.c
Fixed but with multiple globals clauses reported by Gayath Ratnayaka.
[splint.git] / src / usymtab_interface.c
index 9d486d22607598080c6e88bd8fe01b8049020292..62bc37d9743544ea57e4e95c64f73acc2dc89a64 100644 (file)
@@ -1,6 +1,6 @@
 /*
-** LCLint - annotation-assisted static program checker
-** Copyright (C) 1994-2000 University of Virginia,
+** Splint - annotation-assisted static program checker
+** Copyright (C) 1994-2002 University of Virginia,
 **         Massachusetts Institute of Technology
 **
 ** This program is free software; you can redistribute it and/or modify it
 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 ** MA 02111-1307, USA.
 **
-** For information on lclint: lclint-request@cs.virginia.edu
-** To report a bug: lclint-bug@cs.virginia.edu
-** For more information: http://lclint.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
 */
 /*
 ** usymtab_interface.c
 **
 ** Grammar interface to symtab.
 **
-** The LCLint parser will build symbol tables for abstract types and
+** The Splint parser will build symbol tables for abstract types and
 ** function declarations.
 **
 */
 
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
 # include "llbasic.h"
 # include "gram.h"
 # include "lclscan.h"
@@ -553,7 +553,7 @@ static /*@only@*/ qtype
       
       result = qtype_addQualList (result, n->quals);
 
-      if (n->pointers > 0)
+      if (pointers_isDefined (n->pointers))
        {
          qtype_adjustPointers (n->pointers, result);
        }
@@ -586,11 +586,11 @@ static /*@only@*/ multiVal
   
   if /*@-usedef@*/ (first == '\"') /*@=usedef@*/
     {
-      int len = cstring_length (text) - 2;
+      size_t len = cstring_length (text) - 2;
       char *val = mstring_create (len);
       
       llassert (cstring_lastChar (text) == '\"');
-      strncpy (val, cstring_toCharsSafe (text) + 1, size_fromInt (len));
+      strncpy (val, cstring_toCharsSafe (text) + 1, len);
       return (multiVal_makeString (cstring_fromCharsO (val)));
     }
 
@@ -655,16 +655,14 @@ doDeclareConstant (constDeclarationNode c, bool priv)
          if (i->value != (termNode)0 &&
              i->value->kind == TRM_LITERAL)
            {
-             ue = uentry_makeConstantAux (s, ct, loc, priv, 
-                                          literalValue (ct, i->value->literal));
+             ue = uentry_makeConstantValue (s, ct, loc, priv, literalValue (ct, i->value->literal));
            }
          else
            {
-             ue = uentry_makeConstantAux (s, ct, loc, priv, multiVal_unknown ());
+             ue = uentry_makeConstantValue (s, ct, loc, priv, multiVal_unknown ());
            }
-
-                 uentry_reflectQualifiers (ue, qtype_getQuals (qt));
-
+         
+         uentry_reflectQualifiers (ue, qtype_getQuals (qt));
          
          if (context_inLCLLib () && !priv)
            {
@@ -1073,7 +1071,7 @@ declareFcnAux (fcnNode f, /*@only@*/ qtype qt, ctype ct,
     {
       globals = f->globals;
       
-            sl = fixModifies (f, args);
+      sl = fixModifies (f, args);
 
       /*
       ** Bind let declarations in modifies list 
@@ -1113,9 +1111,8 @@ declareFcnAux (fcnNode f, /*@only@*/ qtype qt, ctype ct,
          
          ue = usymtab_lookupGlob (cstring_makeLiteralTemp ("stderr"));
          
-                 globlist = globSet_insert (globlist, sRef_copy (uentry_getSref (ue)));
+         globlist = globSet_insert (globlist, sRef_copy (uentry_getSref (ue)));
          sl = sRefSet_insert (sl, sRef_buildPointer (uentry_getSref (ue)));
-
        }
     }
 
@@ -1127,7 +1124,7 @@ declareFcnAux (fcnNode f, /*@only@*/ qtype qt, ctype ct,
     {
       acct = typeIdSet_single (tn);
     }
-  
+
   if (usymtab_exists (s))
     {
       uentry l = usymtab_lookup (s);
@@ -1160,7 +1157,6 @@ declareFcnAux (fcnNode f, /*@only@*/ qtype qt, ctype ct,
            }
 
          uentry_reflectQualifiers (ue, qtype_getQuals (qt));
-
          usymtab_supEntry (ue);
        }
       else
@@ -1173,7 +1169,6 @@ declareFcnAux (fcnNode f, /*@only@*/ qtype qt, ctype ct,
          **          loc);
           */
 
-         
          fileloc_free (loc);
          sRefSet_free (sl);
          globSet_free (globlist);
@@ -1209,14 +1204,17 @@ declareFcnAux (fcnNode f, /*@only@*/ qtype qt, ctype ct,
 
       uentry_reflectQualifiers (le, qtype_getQuals (qt));
 
-      switch (f->special)
-       {
-       case QU_UNKNOWN:     break;
-       case QU_PRINTFLIKE:  uentry_setPrintfLike (le); break;
-       case QU_SCANFLIKE:   uentry_setScanfLike (le); break;
-       case QU_MESSAGELIKE: uentry_setMessageLike (le); break;
-       BADDEFAULT;
-       }
+      if (qual_isUnknown (f->special)) {
+       ;
+      } else if (qual_isPrintfLike (f->special)) {
+       uentry_setPrintfLike (le); 
+      } else if (qual_isScanfLike (f->special)) {
+       uentry_setScanfLike (le); 
+      } else if (qual_isMessageLike (f->special)) {
+       uentry_setMessageLike (le); 
+      } else {
+       BADBRANCH;
+      }
 
       usymtab_supEntry (le);
     }
@@ -1230,7 +1228,7 @@ doDeclareFcn (fcnNode f, typeId tn, bool priv, bool spec)
   qtype qt = convertLclTypeSpecNode (f->typespec);
   ctype ct = convertTypeExpr (qtype_getType (qt), f->declarator->type);
 
-    declareFcnAux (f, qt, ct, tn, priv, spec);
+  declareFcnAux (f, qt, ct, tn, priv, spec);
 }
 
 /*
@@ -1577,14 +1575,13 @@ static /*@exposed@*/ sRef fixTermNode (termNode n, fcnNode f, uentryList cl)
                          }
                      }
                    else
-                     return (sRef_makeGlobal (usym, ctype_unknown));
+                     return (sRef_makeGlobal (usym, ctype_unknown, stateInfo_currentLoc ()));
                  }
                
                else
                  {
-                   sRef p = sRef_makeParam (i, ctype_unknown);
-
-                                   return (p);
+                   sRef p = sRef_makeParam (i, ctype_unknown, stateInfo_currentLoc ());
+                   return (p);
                  }
              }
          }
@@ -1648,7 +1645,7 @@ static
                  
                      llmsg (message
                             ("%q: Warning: object and type modifications "
-                             "not understood by LCLint",
+                             "not understood by Splint",
                              fileloc_unparse (loc)));
                      fileloc_free (loc);
                      shownWarning = TRUE;
@@ -1700,7 +1697,7 @@ paramNode_toUentry (paramNode p)
          ctype cr = convertTypeExpr (qtype_getType (ct), p->paramdecl);
          cstring pname = (p->paramdecl == (typeExpr)0) ? cstring_undefined 
                                                        : paramNode_name (p);
-         uentry ue = uentry_makeVariableParam (pname, cr);
+         uentry ue = uentry_makeVariableParam (pname, cr, g_currentloc);
 
          uentry_reflectQualifiers (ue, qtype_getQuals (ct));
          qtype_free (ct);
This page took 0.040883 seconds and 4 git commands to generate.