system, download it from prep.ai.mit.edu.
o standard Unix tools: gzip, tar
-1. Download the LCLint source package (lclint.src.tar.gz).
+You should also have:
- Copy this package to the directory where you want to build LCLint. When
- the tar file is extracted, it will create an lclint-3.0.0.9 subdirectory.
+ o flex
+ o bison version 1.28 or later - bison 1.27 and 1.25 are believed to
+ have bugs that cause problems with lclint's parsers.
+
+If these are unavailable, you may be able to build lclint anyway using
+the derived grammar files. This is not recommended however.
-2. Uncompress the package:
- gzip -d lclint.src.tar.gz
+1. Download the LCLint source package (lclint-<version>.src.tgz).
+
+ Copy this package to the directory where you want to build LCLint. When
+ the tar file is extracted, it will create an lclint-<version> subdirectory.
-3. Extract files from the tar archive:
- tar xf lclint.src.tar
+2. Extract files from the tar archive:
+ tar xzf lclint-<version>.src.tgz
-4. Run: configure
+3. Run: ./configure
This will create a Makefile with settings for your system. If you
want to install LCLint or associated libraries different
directories, edit the Makefile.
-5. Run: gmake
+4. Run: gmake
It is best to do this in an emacs shell or a buffered terminal,
so you can scroll through the output.
(usually ~/.environment).
Set up your PATH to include the directory containing
- lclint-3.0.0.9/bin/lclint, or move the binary to a directory on
+ lclint-<version>/bin/lclint, or move the binary to a directory on
your command path.
7. Run: gmake test
-27 August 2001
+10 September 2001
bool p_caseinsensitive,
bool p_lookalike) /*@*/ ;
-# ifdef WIN32
+/* evans 2001-09-09 - removed conditional compilation on this (for WIN32, OS2) */
extern void cstring_replaceAll (cstring p_s, char p_old, char p_snew) /*@modifies p_s@*/ ;
-# endif
extern void cstring_replaceLit (/*@unique@*/ cstring p_s, char *p_old, char *p_snew);
extern char cstring_firstChar (cstring p_s) /*@*/ ;
extern bool cstring_equalCaseInsensitive (cstring p_c1, cstring p_c2) /*@*/ ;
extern bool cstring_equalLen (cstring p_c1, cstring p_c2, int p_len) /*@*/ ;
extern bool cstring_equalLenCaseInsensitive (cstring p_c1, cstring p_c2, int p_len) /*@*/ ;
-extern bool cstring_equalPrefix (cstring p_c1, char *p_c2) /*@*/ ;
-extern bool cstring_equalCanonicalPrefix (cstring p_c1, char *p_c2) /*@*/ ;
+extern bool cstring_equalPrefix (cstring p_c1, cstring p_c2) /*@*/ ;
+extern bool cstring_equalPrefixLit (cstring p_c1, /*@observer@*/ const char *p_c2) /*@*/ ;
extern bool cstring_equalLit (cstring p_c1, char *p_c2) /*@*/ ;
extern int cstring_compare (cstring p_c1, cstring p_c2) /*@*/ ;
extern int cstring_xcompare (cstring *p_c1, cstring *p_c2) /*@*/ ;
extern void cstring_markOwned (/*@owned@*/ cstring p_s) /*@modifies p_s@*/ ;
extern cstring cstring_beforeChar (cstring p_s, char p_c) /*@*/ ;
+extern /*@exposed@*/ cstring cstring_afterChar (cstring p_s, char p_c) /*@*/ ;
/*@iter cstring_chars (sef cstring s, yield char c);@*/
# define cstring_chars(s, m_c) \
/*@constant observer cstring XH_EXTENSION;@*/
# define XH_EXTENSION cstring_makeLiteralTemp (".xh")
+/* C files that have already been preprocessed */
+/*@constant observer cstring PP_EXTENSION;@*/
+# define PP_EXTENSION cstring_makeLiteralTemp (".pp")
+
# endif
extern int yyleng;
/*@=incondefs@*/
-# ifdef WIN32
-extern int yywrap (void) /*@*/ ;
-# endif
-
extern int yydebug;
/*@=redecl@*/
/*@=namechecks@*/
/* herald.h - created automatically by gmake updateversion */
/*@constant observer char *LCL_VERSION;@*/
-# define LCL_VERSION "LCLint 3.0.0.13 --- 27 August 2001"
+# define LCL_VERSION "LCLint 3.0.0.16 --- 10 September 2001"
/*@constant observer char *LCL_PARSE_VERSION;@*/
-# define LCL_PARSE_VERSION "LCLint 3.0.0.13"
+# define LCL_PARSE_VERSION "LCLint 3.0.0.16"
/*@constant observer char *LCL_COMPILE;@*/
-# define LCL_COMPILE "Compiled using gcc -DSTDC_HEADERS=1 -g -Wall on Linux paisley 2.4.3-12 #1 Fri Jun 8 13:35:30 EDT 2001 i686 unknown by drl7x"
+# define LCL_COMPILE "Compiled using gcc -Wall -g on Linux paisley 2.4.3-12 #1 Fri Jun 8 13:35:30 EDT 2001 i686 unknown by evans"
/* herald.h - created automatically by gmake updateversion */
/*@constant observer char *LCL_VERSION;@*/
-# define LCL_VERSION "LCLint 3.0.0.13 --- 27 August 2001"
+# define LCL_VERSION "LCLint 3.0.0.16 --- 10 September 2001"
/*@constant observer char *LCL_PARSE_VERSION;@*/
-# define LCL_PARSE_VERSION "LCLint 3.0.0.13"
+# define LCL_PARSE_VERSION "LCLint 3.0.0.16"
/*@constant observer char *LCL_COMPILE;@*/
-# define LCL_COMPILE "Compiled using gcc -DSTDC_HEADERS=1 -g -Wall on Linux fowler 2.4.3-12 #1 Fri Jun 8 13:35:30 EDT 2001 i686 unknown by drl7x"
+# define LCL_COMPILE "Compiled using gcc -Wall -g on Linux paisley 2.4.3-12 #1 Fri Jun 8 13:35:30 EDT 2001 i686 unknown by evans"
/*@constant observer char *SYSTEM_LIBDIR;@*/
# define SYSTEM_LIBDIR "/usr/include"
/*@constant observer char *DEFAULT_LARCHPATH;@*/
-# define DEFAULT_LARCHPATH ".:/af9/drl7x/re3/LCLintDev/lib"
+# define DEFAULT_LARCHPATH "/usr/local/lclint/lib"
/*@constant observer char *DEFAULT_LCLIMPORTDIR;@*/
-# define DEFAULT_LCLIMPORTDIR "/af9/drl7x/re3/LCLintDev/imports"
+# define DEFAULT_LCLIMPORTDIR "/usr/local/lclint/imports"
/*@constant observer char *SYSTEM_LIBDIR;@*/
# define SYSTEM_LIBDIR "/usr/include"
/*@constant observer char *DEFAULT_LARCHPATH;@*/
-# define DEFAULT_LARCHPATH ".:/af9/drl7x/re3/LCLintDev/lib"
+# define DEFAULT_LARCHPATH "/usr/local/lclint/lib"
/*@constant observer char *DEFAULT_LCLIMPORTDIR;@*/
-# define DEFAULT_LCLIMPORTDIR "/af9/drl7x/re3/LCLintDev/imports"
+# define DEFAULT_LCLIMPORTDIR "/usr/local/lclint/imports"
extern char *mstring_copy (/*@null@*/ char *p_s1) /*@*/ ;
extern bool mstring_equalPrefix (const char *p_c1, const char *p_c2) /*@*/ ;
extern bool mstring_equal (/*@null@*/ const char *p_s1, /*@null@*/ const char *p_s2) /*@*/ ;
-extern bool mstring_containsChar (const char *p_s, char p_c) /*@*/ ;
+extern bool mstring_containsChar (/*@unique@*/ const char *p_s, char p_c) /*@*/ ;
+extern bool mstring_containsString (/*@unique@*/ const char *p_s, /*@unique@*/ const char *p_c) /*@*/ ;
extern int mstring_length (/*@sef@*/ /*@null@*/ char *p_s) /*@*/ ;
# define mstring_length(s) \
extern int osd_system (cstring p_cmd) /*@modifies fileSystem@*/ ;
# endif
+extern bool osd_equalCanonicalPrefix (cstring p_dirpath, cstring p_prefixpath) /*@*/ ;
+
extern int osd_unlink (cstring) /*@modifies fileSystem@*/ ;
extern cstring osd_fixDefine (cstring);
extern bool osd_fileIsReadable (cstring);
# define S_IFMT (unsigned short)0xFFFF
# endif
+# if defined (OS2) || defined (MSDOS) || defined (WIN32)
+/*@constant observer cstring INCLUDEPATH_VAR@*/
+# define INCLUDEPATH_VAR cstring_makeLiteralTemp ("INCLUDE")
+# else
/*@constant observer cstring INCLUDEPATH_VAR@*/
# define INCLUDEPATH_VAR cstring_makeLiteralTemp ("CPATH")
+# endif
#if defined (VMS)
-/* Connection string inserted between directory and filename to make a */
-/* full path name. */
+
+/*
+** VMS is here, but hasn't been tested for many releases. Not sure if this works.
+*/
+
+/*
+** Connection string inserted between directory and filename to make a
+** full path name.
+*/
# define CONNECTSTR ":"
# define CONNECTCHAR ':'
-
/* Directory separator character for search list. */
/*@constant static char PATH_SEPARATOR; @*/
# define PATH_SEPARATOR ':'
# else
# error "Multiple include"
# endif
+
int p_kind, fileloc p_loc)
/*@modifies p_s@*/ ;
+extern void
+sRef_aliasSetCompleteAlkParam (void (p_predf) (sRef, alkind, fileloc), sRef p_s,
+ alkind p_kind, fileloc p_loc)
+ /*@modifies p_s@*/ ;
+
+
mkdir ~/temp/lclint-`cat ${VERSION_NUMBER}`/src
cp Makefile* ${ALLSRC} ${GRAMS} *.i flags.def ~/temp/lclint-`cat ${VERSION_NUMBER}`/src/
cp cscanner.c ~/temp/lclint-`cat ${VERSION_NUMBER}`/src/cscanner.c.der
- cp lastversion maketags ~/temp/lclint-`cat ${VERSION_NUMBER}`/src/
+ cp DATE lastversion maketags ~/temp/lclint-`cat ${VERSION_NUMBER}`/src/
cp *.head *.reset ~/temp/lclint-`cat ${VERSION_NUMBER}`/src/
cp cgrammar.c ~/temp/lclint-`cat ${VERSION_NUMBER}`/src/cgrammar.c.der
cp llgrammar.c ~/temp/lclint-`cat ${VERSION_NUMBER}`/src/llgrammar.c.der
cp -r Headers ~/temp/lclint-`cat ${VERSION_NUMBER}`/src/
cp -r ../lib ~/temp/lclint-`cat ${VERSION_NUMBER}`/lib
cp -r ../imports ~/temp/lclint-`cat ${VERSION_NUMBER}`/imports
+ cp -r ../os2 ~/temp/lclint-`cat ${VERSION_NUMBER}`/os2
cp -r ../test ~/temp/lclint-`cat ${VERSION_NUMBER}`/test
cp ../configure ../Makefile* ../LICENSE ../README ../BUFFERCHECKING ~/temp/lclint-`cat ${VERSION_NUMBER}`/
cd ~/temp/lclint-`cat ${VERSION_NUMBER}`; mkdir bin
bool
context_isSystemDir (cstring dir)
{
- cstring sysDirs = context_exposeString (FLG_SYSTEMDIRS);
- char *thisdir = cstring_toCharsSafe (sysDirs);
- char *nextdir = strchr (thisdir, PATH_SEPARATOR);
-
- if (nextdir != NULL)
+ cstring thisdir = cstring_copy (context_getString (FLG_SYSTEMDIRS));
+ cstring savedir = thisdir;
+ cstring nextdir = cstring_afterChar (thisdir, PATH_SEPARATOR);
+
+ if (cstring_isDefined (nextdir))
{
- *nextdir = '\0';
+ /*@access cstring@*/
+ *nextdir = '\0'; /* closes thisdir */
nextdir += 1;
+ /*@noaccess cstring@*/
}
- while (thisdir != NULL)
+ /* 2001-09-09: added thisdir[0] != '\0'
+ ** herbert: don't compare with an empty name!
+ ** should return false for empty directory path
+ */
+
+ while (!cstring_isEmpty (thisdir))
{
DPRINTF (("Test: %s / %s", dir, thisdir));
- if (cstring_equalCanonicalPrefix (dir, thisdir))
+ if (osd_equalCanonicalPrefix (dir, thisdir))
{
- if (nextdir != NULL)
- {
- *(nextdir - 1) = PATH_SEPARATOR;
- }
-
+ cstring_free (savedir);
return TRUE;
}
- if (nextdir != NULL)
- {
- *(nextdir - 1) = PATH_SEPARATOR;
- }
-
- if (nextdir != NULL)
+ if (cstring_isDefined (nextdir))
{
thisdir = nextdir;
- nextdir = strchr (thisdir, PATH_SEPARATOR);
+ nextdir = cstring_afterChar (thisdir, PATH_SEPARATOR);
- if (nextdir != NULL)
+ if (cstring_isDefined (nextdir))
{
+ /*@access cstring@*/
*nextdir = '\0';
nextdir += 1;
+ /*@noaccess cstring@*/
}
}
else
}
DPRINTF (("Returns FALSE"));
+ cstring_free (savedir);
return FALSE;
}
struct directive *kt = NULL;
int ident_length;
size_t after_ident = 0;
- char *ident, *line_end = NULL;
+ char *ident = NULL;
+ char *line_end = NULL;
size_t old_written = cppReader_getWritten (pfile);
int nspaces = cppSkipHspace (pfile);
}
if (kt->length == ident_length
- && (cstring_equalPrefix (kt->name, ident)))
+ && (cstring_equalPrefix (kt->name, cstring_fromChars (ident))))
{
break;
}
I.e. in input file specification has been popped by cppReader_handleDirective.
This is safe. */
-# ifdef WIN32
-static void replace_unixdir_with_windir(char *filename)
-{
- int i=0;
-
- while(filename[i] != '\0')
- {
- if(filename[i] == '/')
- filename[i] = '\\';
- i++;
- }
-}
-# endif
-
static int
do_include (cppReader *pfile, struct directive *keyword,
/*@unused@*/ char *unused1, /*@unused@*/ char *unused2)
DPRINTF (("fname: %s", fname));
/* Win32 directory fix from Kay Buschner. */
-#ifdef WIN32
+#if defined (WIN32) || defined (OS2)
/* Fix all unixdir slashes to win dir slashes */
if (searchptr->fname && (searchptr->fname[0] != 0))
{
- replace_unixdir_with_windir(fname);
+ cstring_replaceAll (fname, '/', '\\');
}
#endif /* WIN32 */
{
cppIfStackFrame *temp;
if (ident_length == kt->length
- && cstring_equalPrefix (kt->name, ident))
+ && cstring_equalPrefix (kt->name, cstring_fromChars (ident)))
{
/* If we are asked to return on next directive, do so now. */
if (any)
struct default_include *include_defaults = include_defaults_array;
- /* Add dirs from CPATH after dirs from -I. */
+ /* Add dirs from INCLUDEPATH_VAR after dirs from -I. */
/* There seems to be confusion about what CPATH should do,
so for the moment it is not documented. */
/* Some people say that CPATH should replace the standard include dirs,
int i;
char c = ' ';
char *scomment = start + 2;
+ char savec = start[len];
start[0] = BEFORE_COMMENT_MARKER[0];
start[1] = BEFORE_COMMENT_MARKER[1];
cpp_setLocation (pfile);
+ start[len] = '\0';
+
+ if (mstring_containsString (scomment, "/*"))
+ {
+ (void) cppoptgenerror
+ (FLG_NESTCOMMENT,
+ message ("Comment starts inside syntactic comment: %s",
+ cstring_fromChars (scomment)),
+ pfile);
+ }
+
+ start[len] = savec;
+
if (mstring_equalPrefix (scomment, "ignore"))
{
if (!context_getFlag (FLG_NOCOMMENTS))
fname = removePreDirs (fname);
# if defined (WIN32) || defined (OS2)
- cstring_replaceAll (fname, '\\', '/');
+ cstring_replaceAll (fname, '/', '\\');
# endif
if (fileTable_exists (context_fileTable (), fname))
{
addColumn (len);
tokLength = len;
+ DPRINTF (("Set tok length: %d", len));
}
static void setTokLengthT (size_t len)
[ \t\v\f] { incColumn (); }
\n { context_incLineno ();
+ if (tokLength != 0) {
+ tokLength = 0;
+ /* No error to report
+ voptgenerror
+ (FLG_SYNTAX,
+ message ("Likely parse error: token spans multiple lines."),
+ g_currentloc);
+ */
+ }
+
if (continueLine)
{
continueLine = FALSE;
}
hasParams = (c == '(');
-
if (usymtab_exists (fname))
{
{
uentry ce;
- voptgenerror
- (FLG_MACROMATCHNAME,
- message ("Unexpanded macro %s does not match name of a constant "
- "or iter declaration. The name used in the control "
- "comment on the previous line should match. "
- "(Assuming macro defines a constant.)",
- fname),
- loc);
-
-
- ce = uentry_makeConstant (fname, ctype_unknown, fileloc_undefined);
- uentry_setUsed (ce, loc); /* perhaps bogus? */
- e2 = usymtab_supEntryReturn (ce);
-
- context_enterConstantMacro (e2);
- cstring_free (fname);
- fileloc_free (loc);
- return res;
+ /* evans 2001-09-09 - if it has params, assume a function */
+ if (hasParams)
+ {
+ voptgenerror
+ (FLG_MACROMATCHNAME,
+ message ("Unexpanded macro %s does not match name of a declared "
+ "function. The name used in the control "
+ "comment on the previous line should match.",
+ fname),
+ loc);
+
+ ce = uentry_makeFunction (fname, ctype_unknown,
+ typeId_invalid,
+ globSet_undefined,
+ sRefSet_undefined,
+ warnClause_undefined,
+ fileloc_undefined);
+ uentry_setUsed (ce, loc); /* perhaps bogus? */
+ e2 = usymtab_supEntryReturn (ce);
+ context_enterUnknownMacro (e2);
+ }
+ else
+ {
+ voptgenerror
+ (FLG_MACROMATCHNAME,
+ message ("Unexpanded macro %s does not match name of a constant "
+ "or iter declaration. The name used in the control "
+ "comment on the previous line should match. "
+ "(Assuming macro defines a constant.)",
+ fname),
+ loc);
+
+ ce = uentry_makeConstant (fname, ctype_unknown, fileloc_undefined);
+ uentry_setUsed (ce, loc); /* perhaps bogus? */
+ e2 = usymtab_supEntryReturn (ce);
+
+ context_enterConstantMacro (e2);
+ cstring_free (fname);
+ fileloc_free (loc);
+ return res;
+ }
}
/* in macros, ( must follow immediatetly after name */
sRef sr;
param = uentry_nameCopy (paramname, decl);
-
uentry_setParam (param);
sr = sRef_makeParam (paramno, uentry_getType (param), stateInfo_makeLoc (sloc));
param = uentry_makeVariableSrefParam
(paramname, ctype_unknown, fileloc_copy (sloc),
sRef_makeParam (paramno, ctype_unknown, stateInfo_makeLoc (sloc)));
+ DPRINTF (("Unknown param: %s", uentry_unparseFull (param)));
cstring_free (paramname);
sRef_setPosNull (uentry_getSref (param), sloc);
*l = '\0';
olc = cstring_fromChars (ol);
- if (cstring_equalPrefix (olc, "pragma"))
+ if (cstring_equalPrefixLit (olc, "pragma"))
{
char *pname = mstring_create (longUnsigned_fromInt (MAX_PRAGMA_LEN));
char *opname = pname;
cstring_free (exname);
}
}
- else if (cstring_equalPrefix (olc, "ident"))
+ else if (cstring_equalPrefixLit (olc, "ident"))
{
/* Some pre-processors will leave these in the code. Ignore rest of line */
}
static int handleLlSpecial ()
{
+ bool hasnl = FALSE;
int ic;
char c;
char *s = mstring_createEmpty ();
&& (ic != AFTER_COMMENT_MARKER[0]))
{
c = (char) ic;
+
+ /* evans 2001-09-01 added to prevent assertion failures for uncloses syntactic comments */
+
+ if (c == '\n') {
+ hasnl = TRUE; /* This prevents tokLength from being set later. */
+ tokLength = 0;
+
+ voptgenerror
+ (FLG_SYNTAX,
+ message ("Likely parse error: syntactic comment token spans multiple lines: %s",
+ cstring_fromChars (s)),
+ g_currentloc);
+ }
+
s = mstring_append (s, c);
charsread++;
}
if (macrocode != BADTOK)
{
- tokLength = mstring_length (t);
+ tokLength = hasnl ? 0 : mstring_length (t);
sfree (t);
sfree (os);
processSpec (int tok)
{
size_t length = strlen (yytext);
-
if (inSpecPart)
{
return val;
}
+cstring cstring_afterChar (cstring s, char c)
+{
+ llassert (cstring_isDefined (s));
+ return strchr (s, c);
+}
+
cstring cstring_beforeChar (cstring s, char c)
{
if (cstring_isDefined (s))
** Replaces all occurances of old in s with new.
*/
-# if defined (WIN32) || defined (OS2)
void cstring_replaceAll (cstring s, char old, char snew)
{
}
}
-# endif
void cstring_replaceLit (/*@unique@*/ cstring s, char *old, char *snew)
{
else return (cstring_genericEqual (c1, c2, len, TRUE, FALSE) != CGE_DISTINCT);
}
-bool cstring_equalPrefix (cstring c1, char *c2)
+bool cstring_equalPrefix (cstring c1, cstring c2)
{
llassert (c2 != NULL);
return (strncmp (c1, c2, strlen (c2)) == 0);
}
-bool cstring_equalCanonicalPrefix (cstring c1, char *c2)
+bool cstring_equalPrefixLit (cstring c1, const char *c2)
{
llassert (c2 != NULL);
return (strlen (c2) == 0);
}
-# if defined (WIN32) || defined (OS2)
- /*
- ** If one has a drive specification, but the other doesn't, skip it.
- */
-
- if (strchr (c1, ':') == NULL
- && strchr (c2, ':') != NULL)
- {
- c2 = strchr (c2 + 1, ':');
- }
- else
- {
- if (strchr (c2, ':') == NULL
- && strchr (c1, ':') != NULL)
- {
- c1 = strchr (c1 + 1, ':');
- }
- }
-
- {
- int len = size_toInt (strlen (c2));
- int i = 0;
- int slen = 0;
-
- if (cstring_length (c1) < len)
- {
- return FALSE;
- }
-
- for (i = 0; i < len; i++)
- {
- if (c1[slen] == c2[i]
- || (osd_isConnectChar (c1[slen]) && osd_isConnectChar (c2[i])))
- {
- ;
- }
- else
- {
- /*
- ** We allow \\ to match \ because MS-DOS screws up the directory
- ** names.
- */
-
- if (c1[slen] == '\\'
- && (slen > 0
- && c1[slen - 1] == '\\'
- && c2[i - 1] == '\\'))
- {
- slen++;
- if (c1[slen] != c2[i])
- {
- return FALSE;
- }
- }
- else
- {
- return FALSE;
- }
- }
-
- slen++;
- if (slen >= cstring_length (c1))
- {
- return FALSE;
- }
- }
- }
-
- return TRUE;
-# else
return (strncmp (c1, c2, strlen (c2)) == 0);
-# endif
}
int cstring_xcompare (cstring *c1, cstring *c2)
** error in ind, assume valid and continue
*/
+ DPRINTF (("Array fetch: %s / %s",
+ exprNode_unparse (e1), exprNode_unparse (e2)));
+
if (exprNode_isError (e1))
{
exprNode_free (e2);
** lclint errors. Hence, the i2 comments.
*/
- if (!ctype_isRealArray (crarr)
+ /* evans 2001-09-09 added ctype_isKnown so there is no swap when e1 type is unknown */
+ if (ctype_isKnown (crarr)
+ && !ctype_isRealArray (crarr)
&& ctype_isRealNumeric (crarr)
&& !exprNode_isError (e2)
&& ctype_isRealAP (exprNode_getType (e2))) /* fetch like 3[a] */
ind = e2;
}
+ DPRINTF (("arr: %s", exprNode_unparse (arr)));
+
if (sRef_possiblyNull (arr->sref))
{
if (!usymtab_isGuarded (arr->sref))
exprNode_unparse (arr)),
arr->loc))
{
+ DPRINTF (("ref: %s", sRef_unparseFull (arr->sref)));
sRef_showNullInfo (arr->sref);
/* suppress future messages */
{
cstring ename = uentry_getName (end);
- if (!cstring_equalPrefix (ename, "end_"))
+ if (!cstring_equalPrefixLit (ename, "end_"))
{
llerror (FLG_ITER, message ("Iter %s not balanced with end_%s: %s",
iname, iname, ename));
cstring fileLib_cleanName (cstring s)
{
- if (cstring_equalPrefix (s, "./"))
+ if (cstring_equalPrefixLit (s, "./"))
{
return cstring_copySegment (s, 2, cstring_length (s) - 1);
}
fileId
fileTable_addCTempFile (fileTable ft, fileId fid)
{
-# if FALSE
- /* Can't control output file name for cl preprocessor */
- cstring newname = cstring_concatChars (fileLib_removeAnyExtension (fileName (fid)), ".i");
-# else
cstring newname =
makeTempName (context_tmpdir (), cstring_makeLiteralTemp ("cl"),
C_EXTENSION);
-# endif
llassert (fileTable_isDefined (ft));
{
return (FL_SPEC);
}
- else if (cstring_equalPrefix (fname, SYSTEM_LIBDIR))
+ else if (cstring_equalPrefix (fname, cstring_makeLiteralTemp (SYSTEM_LIBDIR)))
{
return (FL_STDHDR);
}
fileloc_decColumn (fileloc f, int x)
{
fileloc ret = fileloc_copy (f);
+
if (x > 0 && fileloc_isDefined (ret))
{
llassertprint (ret->column > x, ("decColumn: %d", x));
fid = fileTable_addLibraryFile (context_fileTable (), ln);
}
- if (cstring_equalPrefix (ln, SYSTEM_LIBDIR))
+ if (cstring_equalPrefix (ln, cstring_makeLiteralTemp (SYSTEM_LIBDIR)))
{
fk = FL_STDLIB;
}
return FALSE;
}
}
+
+bool mstring_containsString (const char *s, const char *c)
+{
+ if (mstring_isDefined (s))
+ {
+ return (strstr (s, c) != NULL);
+ }
+ else
+ {
+ return FALSE;
+ }
+}
char *mstring_concat (const char *s1, const char *s2)
{
-IHeaders
-DDEBUGPRINT
-## -systemdirs /usr/include:/usr/local/lib/
+-systemdirs /usr/include:/usr/local/lib/:/usr/lib
+allmacros # check all macros
+checks # checks mode (moderately strict checking)
/*@noaccess cstring@*/
}
}
+ else /* 2001-09-09: herbert */
+ {
+ /* Put C_INCLUDE_PATH directories in sysdirs */
+ cstring cincval = osd_getEnvironmentVariable (cstring_makeLiteralTemp ("C_INCLUDE_PATH"));
+ if (cstring_isDefined (cincval))
+ {
+ context_setString (FLG_SYSTEMDIRS, cstring_copy (cincval));
+ }
+ }
+ /* /herbert */
cstring_free (oincval);
}
{
addXHFile (xfiles, cstring_copy (current));
}
+ else if (cstring_equal (ext, PP_EXTENSION))
+ {
+ if (!context_getFlag (FLG_NOPP))
+ {
+ voptgenerror
+ (FLG_FILEEXTENSIONS,
+ message ("File extension %s used without +nopp flag (will be processed as C source code): %s",
+ ext, current),
+ g_currentloc);
+ }
+
+ addFile (cfiles, cstring_copy (current));
+ }
else if (cstring_equal (ext, LCL_EXTENSION))
{
addFile (lclfiles, cstring_copy (current));
llmsglit (" --- path used to find #include'd files");
llmsg (message
- ("systemdirs = %s (set by -systemdirs or envirnoment variable %s)", /*@i413223@*/
+ ("systemdirs = %s (set by -systemdirs or environment variable %s)", /*@i413223@*/
context_getString (FLG_SYSTEMDIRS),
INCLUDEPATH_VAR));
extern ctype mtscanner_lookupType (mttok p_tok) /*@modifies p_tok@*/ ;
# endif
- /*@i523 can't include these here
+ /*@i523@*/ /* can't include these here
# include "mtgrammar.h"
# include "mtscanner.h"
*/
extern ctype mtscanner_lookupType (mttok p_tok) /*@modifies p_tok@*/ ;
# endif
- /*@i523 can't include these here
+ /*@i523@*/ /* can't include these here
# include "mtgrammar.h"
# include "mtscanner.h"
*/
if ((cstring_lastChar (name) == 'f' || cstring_lastChar (name) == 'l')
&&
(((length == 4)
- && ((cstring_equalPrefix (name, "cos") ||
- cstring_equalPrefix (name, "sin") ||
- cstring_equalPrefix (name, "tan") ||
- cstring_equalPrefix (name, "exp") ||
- cstring_equalPrefix (name, "log") ||
- cstring_equalPrefix (name, "pow"))))
+ && ((cstring_equalPrefixLit (name, "cos") ||
+ cstring_equalPrefixLit (name, "sin") ||
+ cstring_equalPrefixLit (name, "tan") ||
+ cstring_equalPrefixLit (name, "exp") ||
+ cstring_equalPrefixLit (name, "log") ||
+ cstring_equalPrefixLit (name, "pow"))))
|| ((length == 5)
- && ((cstring_equalPrefix (name, "acos") ||
- cstring_equalPrefix (name, "asin") ||
- cstring_equalPrefix (name, "atan") ||
- cstring_equalPrefix (name, "cosh") ||
- cstring_equalPrefix (name, "sinh") ||
- cstring_equalPrefix (name, "sqrt") ||
- cstring_equalPrefix (name, "ceil") ||
- cstring_equalPrefix (name, "fabs") ||
- cstring_equalPrefix (name, "fmod") ||
- cstring_equalPrefix (name, "tanh") ||
- cstring_equalPrefix (name, "modf"))))
+ && ((cstring_equalPrefixLit (name, "acos") ||
+ cstring_equalPrefixLit (name, "asin") ||
+ cstring_equalPrefixLit (name, "atan") ||
+ cstring_equalPrefixLit (name, "cosh") ||
+ cstring_equalPrefixLit (name, "sinh") ||
+ cstring_equalPrefixLit (name, "sqrt") ||
+ cstring_equalPrefixLit (name, "ceil") ||
+ cstring_equalPrefixLit (name, "fabs") ||
+ cstring_equalPrefixLit (name, "fmod") ||
+ cstring_equalPrefixLit (name, "tanh") ||
+ cstring_equalPrefixLit (name, "modf"))))
|| ((length == 6)
- && ((cstring_equalPrefix (name, "atan2") ||
- cstring_equalPrefix (name, "floor") ||
- cstring_equalPrefix (name, "frexp") ||
- cstring_equalPrefix (name, "ldexp") ||
- cstring_equalPrefix (name, "log10"))))))
+ && ((cstring_equalPrefixLit (name, "atan2") ||
+ cstring_equalPrefixLit (name, "floor") ||
+ cstring_equalPrefixLit (name, "frexp") ||
+ cstring_equalPrefixLit (name, "ldexp") ||
+ cstring_equalPrefixLit (name, "log10"))))))
{
hasError |= optgenerror2
(flg, FLG_NAMECHECKS,
{
cstring pname = uentry_observeRealName (p);
- if (!cstring_equalPrefix (pname, cstring_toCharsSafe (fpfx)))
+ if (!cstring_equalPrefix (pname, fpfx))
{
if (context_getFlag (FLG_NAMECHECKS))
{
return FALSE;
}
+/*
+** Returns true if c2 starts with the same path as c1
+**
+** This is called by context_isSystemDir to determine if a
+** directory is on the system path.
+**
+** In unix, this is just a string comparison. For Win32 and OS2, we need a more
+** complex comparison.
+*/
+
+bool osd_equalCanonicalPrefix (cstring dirpath, cstring prefixpath)
+{
+ llassert (cstring_isDefined (prefixpath));
+
+ if (cstring_isEmpty (dirpath))
+ {
+ return (cstring_isEmpty (prefixpath));
+ }
+
+# if defined (WIN32) || defined (OS2)
+
+ /*@access cstring@*/ /* Moved this from cstring - should abstract it... */
+
+ /*
+ ** If one has a drive specification, but the other doesn't, skip it.
+ */
+
+ if (strchr (dirpath, ':') == NULL
+ && strchr (prefixpath, ':') != NULL)
+ {
+ prefixpath = strchr (prefixpath, ':') + 1;
+ }
+ else
+ {
+ if (strchr (prefixpath, ':') == NULL
+ && strchr (dirpath, ':') != NULL)
+ {
+ dirpath = strchr (dirpath, ':') + 1;
+ }
+ }
+
+ {
+ int len = size_toInt (strlen (prefixpath));
+ int i = 0;
+ int slen = 0;
+
+ for (i = 0, slen = 0; i < len; i++, slen++)
+ {
+ /* Allow any number of connect characters in any combination:
+ * c:/usr//src\/foo == c:\\usr/src\/foo
+ * After this we'll be at the last of such a sequence */
+
+ if (osd_isConnectChar (dirpath[slen]) && osd_isConnectChar (prefixpath[i]))
+ {
+ /* Skip one or more connect chars */
+
+ for (; osd_isConnectChar (dirpath[slen+1]); ++slen)
+ {
+ ;
+ }
+
+ for (; osd_isConnectChar (prefixpath[i+1]); ++i)
+ {
+ ;
+ }
+ }
+ /* Windows, MSDOS and OS/2 use case-insensitive path specs! */
+ else if (toupper (dirpath[slen]) != toupper (prefixpath[i]))
+ {
+ return FALSE;
+ }
+
+ }
+ }
+
+ /*@noaccess cstring@*/
+
+ return TRUE;
+# else
+ return (cstring_equalPrefix (dirpath, prefixpath));
+# endif
+}
+
void sRef_enterFunctionScope ()
{
+ /* evans 2001-09-09 - cleanup if we are in a macro! */
+ if (context_inMacro ())
+ {
+ if (inFunction) {
+ sRef_exitFunctionScope ();
+ }
+ }
+
llassert (!inFunction);
llassert (sRefTable_isEmpty (allRefs));
inFunction = TRUE;
void sRef_setAliasKindComplete (sRef s, alkind kind, fileloc loc)
{
sRef_checkMutable (s);
- /*@+enumint*/ /* we allow alkind to match int for this */
- sRef_aliasSetCompleteParam (sRef_setAliasKind, s, kind, loc);
- /* gcc give warning for this, should provide typesafe versions of aliasSetCompleteParam */
- /*@=enumint@*/
+ sRef_aliasSetCompleteAlkParam (sRef_setAliasKind, s, kind, loc);
}
void sRef_setAliasKind (sRef s, alkind kind, fileloc loc)
int kind, fileloc loc)
{
sRefSet aliases;
+
+ if (sRef_isDeep (s))
+ {
+ aliases = usymtab_allAliases (s);
+ }
+ else
+ {
+ aliases = usymtab_aliasedBy (s);
+ }
+
+ (*predf)(s, kind, loc);
+
+ sRefSet_realElements (aliases, current)
+ {
+ if (sRef_isValid (current))
+ {
+ current = sRef_updateSref (current);
+ ((*predf)(current, kind, loc));
+ }
+ } end_sRefSet_realElements;
+ sRefSet_free (aliases);
+}
+
+/*
+** Version of aliasSetCompleteParam for alkind parameters
+*/
+
+void
+sRef_aliasSetCompleteAlkParam (void (predf) (sRef, alkind, fileloc), sRef s,
+ alkind kind, fileloc loc)
+{
+ sRefSet aliases;
if (sRef_isDeep (s))
{
p = sRef_makePointer (s);
ret = sRef_makeField (p, f);
+ DPRINTF (("Arrow: %s => %s",
+ sRef_unparseFull (s), sRef_unparseFull (ret)));
return ret;
}
/*@=mustfree@*/
}
- /*@i23 ???
+ /*@i23*/
+ /* ??? - evans 2001-09-09 not sure what's going on here...?
if (globSet_hasStatic (globs))
{
context_recordFileGlobals (globs);
sRef uentry_getOrigSref (uentry e)
{
- /*@i523
+ /*@i523*/ /* evans 2001-09-09 - need to fix this
if (uentry_isValid (e))
{
if (uentry_isVariable (e))
cstring nnamefix;
if (cstring_isDefined (pfx)
- && cstring_equalPrefix (oldname, cstring_toCharsSafe (pfx)))
+ && cstring_equalPrefix (oldname, pfx))
{
oname = cstring_suffix (oldname, cstring_length (pfx));
}
/*@-branchstate@*/ } /*@=branchstate@*/
if (cstring_isDefined (pfx)
- && cstring_equalPrefix (nname, cstring_toCharsSafe (pfx)))
+ && cstring_equalPrefix (nname, pfx))
{
nnamefix = cstring_suffix (nname, cstring_length (pfx));
}
cp1 = p1->elements[index];
cp2 = p2->elements[index];
- /*@i32
- **
+ /*@i32*/
+ /*
** Should compare uentry's --- need to fix report errors too.
*/
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-/* Output from LCLint 3.0.0.13 */
+/* Output from LCLint 3.0.0.16 */
# include "bool.h"
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-/* Output from LCLint 3.0.0.13 */
+/* Output from LCLint 3.0.0.16 */
# include "bool.h"
# include "mut.h"
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-/* Output from LCLint 3.0.0.13 */
+/* Output from LCLint 3.0.0.16 */
# include "bool.h"
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-/* Output from LCLint 3.0.0.13 */
+/* Output from LCLint 3.0.0.16 */
# include "bool.h"
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-/* Output from LCLint 3.0.0.13 */
+/* Output from LCLint 3.0.0.16 */
# include <stdio.h>
# include "bool.h"
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-/* Output from LCLint 3.0.0.13 */
+/* Output from LCLint 3.0.0.16 */
# include "bool.h"
# include "bool.h"
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-/* Output from LCLint 3.0.0.13 */
+/* Output from LCLint 3.0.0.16 */
# include "bool.h"
# include "employee.h"
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-/* Output from LCLint 3.0.0.13 */
+/* Output from LCLint 3.0.0.16 */
# include "bool.h"
# include "eref.h"
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-/* Output from LCLint 3.0.0.13 */
+/* Output from LCLint 3.0.0.16 */
# include "bool.h"
# include "employee.h"
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-/* Output from LCLint 3.0.0.13 */
+/* Output from LCLint 3.0.0.16 */
# include "bool.h"
# include "employee.h"
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-/* Output from LCLint 3.0.0.13 */
+/* Output from LCLint 3.0.0.16 */
# include <stdio.h>
# include "bool.h"
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-/* Output from LCLint 3.0.0.13 */
+/* Output from LCLint 3.0.0.16 */
# include <stdio.h>
# include "bool.h"
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-/* Output from LCLint 3.0.0.13 */
+/* Output from LCLint 3.0.0.16 */
# include "bool.h"
# include "employee.h"
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-/* Output from LCLint 3.0.0.13 */
+/* Output from LCLint 3.0.0.16 */
# include "bool.h"
# include "eref.h"
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-/* Output from LCLint 3.0.0.13 */
+/* Output from LCLint 3.0.0.16 */
# include "bool.h"
# include "employee.h"
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-/* Output from LCLint 3.0.0.13 */
+/* Output from LCLint 3.0.0.16 */
# include "bool.h"
# include "employee.h"
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-/* Output from LCLint 3.0.0.13 */
+/* Output from LCLint 3.0.0.16 */
# include "bool.h"
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-/* Output from LCLint 3.0.0.13 */
+/* Output from LCLint 3.0.0.16 */
# include "bool.h"
# include "bool.h"
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-/* Output from LCLint 3.0.0.13 */
+/* Output from LCLint 3.0.0.16 */
# include <stdio.h>
# include "bool.h"
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-/* Output from LCLint 3.0.0.13 */
+/* Output from LCLint 3.0.0.16 */
# include <stdio.h>
# include "bool.h"
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-/* Output from LCLint 3.0.0.13 */
+/* Output from LCLint 3.0.0.16 */
# include "bool.h"
# include "employee.h"
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-/* Output from LCLint 3.0.0.13 */
+/* Output from LCLint 3.0.0.16 */
# include "bool.h"
# include "eref.h"
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-/* Output from LCLint 3.0.0.13 */
+/* Output from LCLint 3.0.0.16 */
# include "bool.h"
# include "employee.h"
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-/* Output from LCLint 3.0.0.13 */
+/* Output from LCLint 3.0.0.16 */
# include "bool.h"
# include "employee.h"
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
--- /dev/null
+extern FILE *f1;
+
+FILE *f (FILE *fin, FILE *fout)
+ /*@ensures closed fin@*/
+{
+ FILE *res;
+ int x;
+
+ x = fgetc (fin);
+
+ if (x > 65)
+ {
+ (void) fclose (fout);
+ } /* merge incompatible */
+
+ if (x > 65)
+ {
+ ;
+ }
+ else
+ {
+ (void) fclose (fin);
+ } /* merge incompatible */
+
+ return res;
+}
--- /dev/null
+void f (char *fname)
+{
+ FILE *f;
+
+ if (fname != NULL)
+ {
+ f = fopen (fname, "r");
+ if (f != NULL) {
+ (void) fclose (f);
+ }
+ }
+}
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-%FAILED Output from LCLint 3.0.0.13
+%FAILED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
--- /dev/null
+attribute taintedness
+ context reference char *
+ oneof untainted, tainted
+ annotations
+ tainted reference ==> tainted
+ untainted reference ==> untainted
+ transfers
+ tainted as untainted ==> error "Possibly tainted storage used as untainted."
+ untainted as tainted ==> untainted
+ merge
+ tainted + untainted ==> tainted
+ defaults
+ reference ==> tainted
+ parameter ==> tainted
+ result ==> tainted
+ literal ==> untainted
+ null ==> untainted
+end
+
+
+
--- /dev/null
+/*
+** tainted.xh
+*/
+
+# include "taintednm.xh"
--- /dev/null
+char *f (/*@tainted@*/ char *s)
+{
+ char t[50];
+ char t2[20];
+
+ (void) system ("test");
+ strcpy (t, "test");
+ strcpy (t2, "okay");
+
+ (void) system (t);
+
+ t = strcat3 (t, t2, t2);
+ (void) system (t); /* okay */
+
+ t = strcat3 (t, t2, s);
+ (void) system (t); /* error */
+
+ t = strcat3 (t, t2, t2);
+ (void) system (t); /* error */
+
+ t = strcpy (t, s);
+ (void) system (t); /* error */
+
+ return t; /* error - tainted, stack-allocated */
+}
--- /dev/null
+attribute taintedness
+ context reference char *
+ oneof untainted, tainted
+ annotations
+ tainted reference ==> tainted
+ untainted reference ==> untainted
+ transfers
+ tainted as untainted ==> error "Possibly tainted storage used as untainted."
+ untainted as tainted ==> untainted
+ merge
+ tainted + untainted ==> tainted
+ untainted + tainted ==> error "bogus merge"
+ defaults
+ reference ==> tainted
+ parameter ==> tainted
+ result ==> tainted
+ literal ==> untainted
+ null ==> untainted
+end
+
+
+
--- /dev/null
+/*
+** tainted.xh
+*/
+
+/* Library functions annotated for tainted.mts */
+
+extern int remove (/*@untainted@*/ char *filename) /*@modifies fileSystem, errno@*/ ;
+extern int rename (/*@untainted@*/ char *old, /*@untainted@*/ char *new) ;
+
+extern /*@observer@*/ char *tmpnam (/*@untainted@*/ char *s) ;
+
+extern FILE *fopen (/*@untainted@*/ char *filename, char *mode) ;
+
+extern int printf (/*@untainted@*/ char *format, ...) ;
+
+extern /*@null@*/ FILE *freopen (/*@untainted@*/ char *filename, char *mode, FILE *stream) ;
+
+extern /*@null@*/ /*@tainted@*/ char *
+ fgets (/*@returned@*/ /*@out@*/ char *s, int n, FILE *stream)
+ /*@ensures tainted s@*/
+ /*@modifies *s@*/ ;
+
+extern int system (/*@untainted@*/ /*@null@*/ char *s) /*@modifies fileSystem@*/ ;
+
+extern char *strcpy (/*@returned@*/ char *s1, char *s2)
+ /*@ensures s1:taintedness = s2:taintedness@*/ ;
+
+extern char *strcat (/*@returned@*/ char *s1, char *s2)
+ /*@ensures s1:taintedness = s1:taintedness | s2:taintedness@*/
+ /*@ensures result:taintedness = s1:taintedness | s2:taintedness @*/ ;
+
+extern char *strcat3 (/*@returned@*/ char *s1, char *s2, char *s3)
+ /*@ensures s1:taintedness = s1:taintedness | s2:taintedness | s3:taintedness@*/
+ /*@ensures result:taintedness = s1:taintedness | s2:taintedness | s3:taintedness @*/ ;
+
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-/* Output from LCLint 3.0.0.13 */
+/* Output from LCLint 3.0.0.16 */
# include "bool.h"
;;LCLint Dump: null6.lcd
-;;LCLint 3.0.0.13 --- 27 August 2001
+;;LCLint 3.0.0.16 --- 10 September 2001
;;lib:168
;;ctTable
0 u-2 19 38
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
--- /dev/null
+typedef struct {
+ char *x;
+} T;
+
+static void foo(/*@special@*/ T* x)
+ /*@defines x->x@*/
+ /*@post:notnull x->x@*/ ;
+
+static void bar(/*@special@*/ T* x)
+ /*@post:notnull x->x@*/
+{
+ foo(x);
+}
+
+void test()
+{
+ T a;
+ foo(&a);
+ bar(&a);
+}
--- /dev/null
+
+postnotnull.c: (in function test)
+postnotnull.c:20:2: Only storage a.x (type char *) derived from variable
+ declared in this scope is not released (memory leak)
+
+Finished LCLint checking --- 1 code error found, as expected
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-/* Output from LCLint 3.0.0.13 */
+/* Output from LCLint 3.0.0.16 */
# include "bool.h"
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
;;LCLint Dump: newlint.lcd
-;;LCLint 3.0.0.13 --- 27 August 2001
+;;LCLint 3.0.0.16 --- 10 September 2001
;;lib:168
;;ctTable
0 u-2 19 38
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
-%PASSED Output from LCLint 3.0.0.13
+%PASSED Output from LCLint 3.0.0.16
%LCLimports
%LCLSortTable
%LCLsort bool immutable nil nil
--- /dev/null
+void test (int fd, void *buffer, size_t cnt)
+{
+ unsigned long res;
+
+ res = read(fd, buffer, cnt);
+
+ if (res <= 0)
+ {
+ printf ("You lose!");
+ }
+
+ if (res < 0 || res >= 0)
+ {
+ printf ("twice loser");
+ }
+}
--- /dev/null
+lclint +posixlib unsignedcompare.c -expect 2
+
+unsignedcompare.c: (in function test)
+unsignedcompare.c:5:3: Assignment of ssize_t to unsigned long int:
+ res = read(fd, buffer, cnt)
+ To allow arbitrary integral types to match long unsigned, use
+ +longunsignedintegral.
+unsignedcompare.c:7:7: Comparison of unsigned value involving zero: res <= 0
+ An unsigned value is used in a comparison with zero in a way that is either a
+ bug or confusing. (-unsignedcompare will suppress message)
+unsignedcompare.c:12:7: Comparison of unsigned value involving zero: res < 0
+unsignedcompare.c:12:18: Comparison of unsigned value involving zero: res >= 0
+
+Finished LCLint checking --- 4 code errors found, expected 2