]> andersk Git - splint.git/blobdiff - src/flags.c
Updated copyright date.
[splint.git] / src / flags.c
index 4b70fa6132a1cdc7bef64e8bfba25dc261cbb897..bec4b3c7bcde306f1e7f20e99d90fc3dde319b7d 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
@@ -19,7 +19,7 @@
 **
 ** 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 more information: http://www.splint.org
 */
 /*
 ** flags.c
@@ -54,9 +54,10 @@ static flagcatinfo categories[] =
   { FK_ANSI, "ansi", "violations of constraints imposed by ANSI/ISO standard" } ,
   { FK_ARRAY, "arrays", "special checking involving arrays" } ,
   { FK_BOOL, "booleans", "checking and naming of boolean types" } ,
-  { FK_COMMENTS, "comments", "interpretation of stylized comments" } ,
+  { FK_COMMENTS, "comments", "interpretation of semantic comments" } ,
   { FK_COMPLETE, "complete", "completely defined, used, or specified system" } ,
   { FK_CONTROL, "controlflow", "suspicious control structures" } ,
+  { FK_DEBUG, "debug", "flags for debugging lclint" } ,
   { FK_DECL, "declarations", "consistency of declarations" } ,
   { FK_DEF, "definition", "undefined storage errors" } ,
   { FK_DIRECT, "directories", "set directores" } ,
@@ -92,13 +93,14 @@ static flagcatinfo categories[] =
   { FK_PROTOS, "prototypes", "function prototypes" } ,
   { FK_DEAD, "released", "using storage that has been deallocated" } ,
   { FK_IGNORERET, "returnvals", "ignored return values" },
+  { FK_SECURITY, "security", "possible security vulnerability" },
   { FK_SPEC, "specifications", "checks involving .lcl specifications" } ,
   { FK_SUPPRESS, "suppress", "local and global suppression of messages" } ,
   { FK_TYPEEQ, "typeequivalence", "control what types are equivalent" } ,
   { FK_BEHAVIOR, "undefined", "code with undefined or implementation-defined behavior" } ,
   { FK_UNRECOG, "unrecognized", "unrecognized identifiers" } ,
   { FK_UNSPEC, "unconstrained", "checking in the presence of unconstrained functions" } ,
-  { FK_DEBUG, NULL, NULL } ,
+  { FK_WARNUSE, "warnuse", "use of possibly problematic function" } ,
   { FK_SYNTAX, NULL, NULL } ,
   { FK_TYPE, NULL, NULL } ,
   { FK_SECRET, NULL, NULL } ,
@@ -155,7 +157,10 @@ static bn_mstring mode_names[] =
 static cstring describeFlagCode (flagcode p_flag) /*@*/ ;
 static cstringSList sortedFlags (void) /*@*/ ;
 static /*@observer@*/ cstring categoryName (flagkind p_kind) /*@*/ ;
+
+# if 0
 static /*@unused@*/ cstring listModes (void) /*@*/ ;
+# endif
 
 bool flagcode_isSpecialFlag (flagcode f)
 {
@@ -193,6 +198,11 @@ void flags_initMod ()
       /*@+enumint@*/
       if (flags[code].code != code)
        {
+         fprintf (stderr, 
+                  "*** ERROR: inconsistent flag %s / %d / %d", 
+                  flags[code].flag,
+                  flags[code].code, code);
+         
          llbug (message ("*** ERROR: inconsistent flag %s / %d / %d", 
                          cstring_fromChars (flags[code].flag),
                          flags[code].code, code));
@@ -626,9 +636,15 @@ void printAlphaFlags ()
   cstringSList_printSpaced (fl, 3, 1, context_getLineLen () - 25); 
   cstringSList_free (fl);
 }
+
 /*@observer@*/ cstring
-flagcode_name (flagcode code)
+flagcode_unparse (flagcode code)
 {
+  if (code == INVALID_FLAG)
+    {
+      return cstring_makeLiteralTemp ("<invalid flag>");
+    }
+
   return cstring_fromChars (flags[code].flag);
 }
 
@@ -878,10 +894,9 @@ identifyFlag (cstring s)
   
   if (cstring_equalLit (s, "accessunspec"))
     {
-      flagWarning 
-       (cstring_makeLiteralTemp
-        ("accessunspec flag is not supported by LCLint version 2.0 or "
-         "later.  It has been replaced by accessmodule, accessfile and "
+      llerror_flagWarning 
+       (cstring_makeLiteral
+        ("accessunspec flag is no longer supported.  It has been replaced by accessmodule, accessfile and "
          "accessfunction to provide more precise control of accessibility "
          "of representations.  For more information, "
          "see lclint -help accessmodule"));
@@ -891,8 +906,8 @@ identifyFlag (cstring s)
 
   if (cstring_equalLit (s, "staticmods"))
     {
-      flagWarning 
-       (cstring_makeLiteralTemp
+      llerror_flagWarning 
+       (cstring_makeLiteral
         ("staticmods flag is obsolete.  You probably "
          "want impcheckmodstatics.  For more information, "
          "see lclint -help impcheckmodstatics"));
@@ -902,26 +917,26 @@ identifyFlag (cstring s)
 
   if (cstring_equalLit (s, "bool"))
     {
-      flagWarning
-       (cstring_makeLiteralTemp ("bool flag is obsolete.  It never really "
-                                 "made sense in the first place."));
+      llerror_flagWarning
+       (cstring_makeLiteral ("bool flag is obsolete.  It never really "
+                             "made sense in the first place."));
       
       return SKIP_FLAG;
     }
   
   if (cstring_equalLit (s, "ansi"))
     {
-      flagWarning
-       (cstring_makeLiteralTemp ("ansi flag is obsolete.  You probably "
-                                 "want noparams and/or oldstyle."));
+      llerror_flagWarning
+       (cstring_makeLiteral ("ansi flag is obsolete.  You probably "
+                             "want noparams and/or oldstyle."));
       
       return SKIP_FLAG;
     }
     
   if (cstring_equalLit (s, "stdio"))
     {
-      flagWarning 
-       (cstring_makeLiteralTemp
+      llerror_flagWarning 
+       (cstring_makeLiteral
         ("stdio flag is obsolete.  You may "
          "want strictlib or one of the gloabls "
          "checking flags.  For more information, "
@@ -941,6 +956,8 @@ void setValueFlag (flagcode opt, cstring arg)
     case FLG_LCLEXPECT:
     case FLG_LIMIT:  
     case FLG_LINELEN:
+    case FLG_INDENTSPACES:
+    case FLG_BUGSLIMIT:
     case FLG_EXTERNALNAMELEN:
     case FLG_INTERNALNAMELEN:
     case FLG_CONTROLNESTDEPTH:
@@ -962,7 +979,7 @@ void setValueFlag (flagcode opt, cstring arg)
          }
        else
          {
-                   context_setValueAndFlag (opt, val);
+           context_setValueAndFlag (opt, val);
          }
       }
       break;
@@ -1057,7 +1074,8 @@ describeModes ()
   return (s);
 }
 
-static cstring
+# if 0
+static /*@unused@*/ cstring
 listModes (void)
 {
   cstring s = cstring_makeLiteral ("\t");
@@ -1078,6 +1096,7 @@ listModes (void)
 
   return s;
 }
+# endif
 
 bool
 isMode (cstring s)
@@ -1116,7 +1135,6 @@ extern int flagcode_valueIndex (flagcode f)
   /*@unchecked@*/ static bool initialized = FALSE;
   int i;
   /*@unchecked@*/ static flagcode valueFlags[NUMVALUEFLAGS];
-
   
   if (!initialized)
     {
@@ -1127,14 +1145,15 @@ extern int flagcode_valueIndex (flagcode f)
          if (flagcode_hasValue (code))
            {
              llassert (nv < NUMVALUEFLAGS);
+             DPRINTF (("Value flag: %s [%d]", flagcode_unparse (code), (int) code));
              valueFlags[nv] = code;
-                     nv++;
+             nv++;
            }
        } end_allFlagCodes;
 
       llassertprint (nv == NUMVALUEFLAGS,
-                    ("number of value flags: %d (expected %d)",
-                     nv, NUMVALUEFLAGS));
+                    ("Number of value flags: %d (expected %d)",
+                     nv, (int) NUMVALUEFLAGS));
       initialized = TRUE;
     }
 
@@ -1147,7 +1166,12 @@ extern int flagcode_valueIndex (flagcode f)
        }
     }
 
+  fprintf (stderr, "Cannot find value flag: %d", (int) f);
+  exit (EXIT_FAILURE);
+  /* Cannot do this...might call recursively...
+  llfatalbug (message ("Cannot fine value flag: %d", (int) f));
   BADEXIT;
+  */
 }
 
 extern int flagcode_stringIndex (flagcode f)
This page took 0.043872 seconds and 4 git commands to generate.