]> andersk Git - splint.git/blobdiff - src/cscanner.l
*** empty log message ***
[splint.git] / src / cscanner.l
index b9c1a88ff6681f77e15993e05b2bb5218a98e201..ad3c04c5a250d29374a99a30cbda3b5ca3ac1daa 100644 (file)
@@ -60,6 +60,7 @@ ULSuffix                ({U}{L}|{L}{U})
 */
 
 # include "lclintMacros.nf"
+# include <unistd.h>
 # include "basic.h"
 
 # include "cgrammar.h"
@@ -79,14 +80,7 @@ static char savechar = '\0';
 /*@notfunction@*/
 # define yyinput() (incColumn (), getc (yyin))
 
-/*@-noparams@*/
-/*@-incondefs@*/
-extern /*@external@*/ int read ();
-/*@=incondefs@*/
-/*@=noparams@*/
-
 static /*@owned@*/ cstring lastidprocessed = cstring_undefined;
-
 static int lminput (void);
 static int tokLength = 0;
 static bool inSpecPart = FALSE;
@@ -114,6 +108,8 @@ static /*@only@*/ cstring makeIdentifier (char *);
 /* yes, this is exported! */
 bool g_expectingTypeName = TRUE; /* beginning of file can be type name! */
 
+static bool expectingMetaStateName = FALSE;
+
 static int returnInt (ctype, long);
 static int returnFloat (ctype, double);
 static int returnChar (char);
@@ -269,6 +265,7 @@ static void setTokLengthT (size_t len)
 "static"       { setTokLength (6); RETURN_TOK (QSTATIC); }
 
 \"(\\.|[^\\"])*\"([ \t\n]*\"(\\.|[^\\"])*\")* { RETURN_EXPR (processString ()); }
+L\"(\\.|[^\\"])*\"([ \t\n]*\"(\\.|[^\\"])*\")* { RETURN_EXPR (processString ()); }
 "out"                   { return (processSpec (QOUT)); }
 "in"                    { return (processSpec (QIN)); }
 "partial"               { return (processSpec (QPARTIAL)); }
@@ -307,7 +304,9 @@ static void setTokLengthT (size_t len)
 "killed"                { return (processSpec (QKILLED)); }
 "nullterminated"        { return (processSpec (QNULLTERMINATED));}
 "MaxSet"                { return (processSpec (QMAXSET));}
-"MaxRead"                { return (processSpec (QMAXREAD));}
+"MaxRead"               { return (processSpec (QMAXREAD));}
+"maxSet"                { return (processSpec (QMAXSET));}
+"maxRead"               { return (processSpec (QMAXREAD));}
 
 {Letter}({Letter}|{Digit})* { int tok; 
                              context_saveLocation (); 
@@ -584,11 +583,9 @@ struct skeyword s_parsetable[] = {
   { "releases", QRELEASES } ,
   { "pre", QPRECLAUSE } ,
   { "post", QPOSTCLAUSE } ,
-  {"setBufferSize", QSETBUFFERSIZE},
-  {"LRequires", QBUFFERCONSTRAINT},
-  {"LEnsures", QENSURESCONSTRAINT},
-  {"setStringLength", QSETSTRINGLENGTH},
-  {"testinRange", QTESTINRANGE},
+  { "setBufferSize", QSETBUFFERSIZE},
+  { "setStringLength", QSETSTRINGLENGTH},
+  { "testinRange", QTESTINRANGE},
   { "requires", QPRECLAUSE } ,
   { "ensures", QPOSTCLAUSE } ,
   { NULL, BADTOK } 
@@ -635,8 +632,6 @@ struct skeyword s_keytable[] = {
   { "relnull", QRELNULL } ,
   { "nullterminated", QNULLTERMINATED }, 
   { "setBufferSize", QSETBUFFERSIZE },
-  { "LRequires", QBUFFERCONSTRAINT },
-  { "LEnsures", QENSURESCONSTRAINT },
   { "testInRange", QTESTINRANGE},
   { "MaxSet", QMAXSET},
   { "MaxRead", QMAXREAD},
@@ -1238,7 +1233,6 @@ static bool processMacro (void)
       e2 = usymtab_lookupExpose (fname);
       ct = uentry_getType (e2);
 
-      
       if (uentry_isCodeDefined (e2) 
          && fileloc_isUser (uentry_whereDefined (e2)))
        {
@@ -1311,7 +1305,7 @@ static bool processMacro (void)
                      
                      uentry_showWhereSpecified (e2);
                      uentry_setType (e2, ctype_unknown);
-                     uentry_makeVarFunction (e2);
+                     uentry_makeConstantFunction (e2);
                      uentry_setDefined (e2, g_currentloc);
                      uentry_setFunctionDefined (e2, g_currentloc);
                      context_enterUnknownMacro (e2); 
@@ -1522,6 +1516,7 @@ static bool processMacro (void)
              && !uentry_isElipsisMarker (uentryList_getN 
                                          (specparams, paramno)))
            {
+             fileloc sloc = context_getSaveLocation ();
              uentry decl = uentryList_getN (specparams, paramno);
              sRef sr;
              
@@ -1529,7 +1524,7 @@ static bool processMacro (void)
 
                              
              uentry_setParam (param);
-             sr = sRef_makeParam (paramno, uentry_getType (param));
+             sr = sRef_makeParam (paramno, uentry_getType (param), stateInfo_makeLoc (sloc));
 
              if (sRef_getNullState (sr) == NS_ABSNULL)
                {
@@ -1546,12 +1541,12 @@ static bool processMacro (void)
                    }
                  else
                    {
-                     sRef_setNullState (sr, NS_UNKNOWN, g_currentloc);
+                     sRef_setNullState (sr, NS_UNKNOWN, sloc);
                    }
                }
 
              uentry_setSref (param, sr);
-             uentry_setDeclaredForceOnly (param, context_getSaveLocation ());
+             uentry_setDeclaredForceOnly (param, sloc);
 
              skipparam = isiter && uentry_isOut (uentryList_getN (specparams, paramno));
            }
@@ -1560,11 +1555,11 @@ static bool processMacro (void)
              fileloc sloc = context_getSaveLocation ();
 
              param = uentry_makeVariableSrefParam 
-               (paramname, ctype_unknown, sRef_makeParam (paramno, ctype_unknown));
+               (paramname, ctype_unknown, fileloc_copy (sloc), 
+                sRef_makeParam (paramno, ctype_unknown, stateInfo_makeLoc (sloc)));
              cstring_free (paramname);
 
              sRef_setPosNull  (uentry_getSref (param), sloc);
-
              uentry_setDeclaredForce (param, sloc);
 
              skipparam = FALSE;
@@ -1818,7 +1813,11 @@ static bool handleSpecial (char *yyt)
       
       if (!(fileId_isValid (fid)))
        {
-         if (isHeaderFile (fname))
+         if (context_inXHFile ())
+           {
+             fid = fileTable_addXHFile (context_fileTable (), fname);
+           }
+         else if (isHeaderFile (fname))
            {
              fid = fileTable_addHeaderFile (context_fileTable (), fname);
            }
@@ -2491,8 +2490,10 @@ static int processIdentifier (cstring id)
 {
   uentry le;
 
-  DPRINTF (("Process identifier: %s / %s / %s", id, fileloc_unparse (g_currentloc),
-           bool_unparse (context_inFunctionHeader ())));
+  if (context_getFlag (FLG_GRAMMAR))
+    {
+      lldiagmsg (message ("Process identifier: %s", id));
+    }
 
   context_clearJustPopped ();
   lastidprocessed = id; 
@@ -2516,7 +2517,24 @@ static int processIdentifier (cstring id)
            }
          else 
            {
-             annotationInfo ainfo = context_lookupAnnotation (id);
+             annotationInfo ainfo;
+
+             if (expectingMetaStateName) 
+               {
+                 metaStateInfo msinfo = context_lookupMetaStateInfo (id);
+
+                 if (metaStateInfo_isDefined (msinfo))
+                   {
+                     yylval.msinfo = msinfo;
+                     return METASTATE_NAME;
+                   }
+                 else
+                   {
+                     DPRINTF (("Not meta state name: %s", cstring_toCharsSafe (id)));
+                   }
+               }
+             
+             ainfo = context_lookupAnnotation (id);
              
              if (annotationInfo_isDefined (ainfo)) 
                {
@@ -2956,3 +2974,16 @@ processSpec (int tok)
       return (processIdentifier (makeIdentifier (yytext)));
     }
 }
+
+void cscanner_expectingMetaStateName ()
+{
+  llassert (!expectingMetaStateName);
+  llassert (context_inFunctionHeader ());
+  expectingMetaStateName = TRUE;
+}
+
+void cscanner_clearExpectingMetaStateName ()
+{
+  llassert (expectingMetaStateName);
+  expectingMetaStateName = FALSE;
+}
This page took 0.198763 seconds and 4 git commands to generate.