From f2b6724f9fdd443cbb7cd7db1ddd31c4c54fa5cf Mon Sep 17 00:00:00 2001 From: evans1629 Date: Sun, 30 Dec 2001 20:16:04 +0000 Subject: [PATCH] Fixed loading of rc files, warnrc and showscan. --- config.h | 12 +- config.hin | 10 +- configure | 27 ++--- configure.ac | 9 +- src/Headers/osd.h | 1 + src/fileTable.c | 11 +- src/llerror.c | 1 + src/llmain.c | 247 ++++++++++++++++++++------------------- src/osd.c | 9 ++ src/uentry.c | 67 +++++++++-- test/Makefile.am | 34 +++--- test/Makefile.in | 34 +++--- test/ansireserved.expect | 4 +- test/mergenull.c | 20 ++++ test/mergenull.expect | 2 + test/utypes.c | 27 +++++ test/utypes.expect | 17 +++ 17 files changed, 347 insertions(+), 185 deletions(-) create mode 100644 test/mergenull.c create mode 100644 test/mergenull.expect create mode 100644 test/utypes.c create mode 100644 test/utypes.expect diff --git a/config.h b/config.h index 036fdcc..312e2d7 100644 --- a/config.h +++ b/config.h @@ -9,10 +9,10 @@ /* Splint's imports directory */ #define DEFAULT_LCLIMPORTDIR ".:/usr/local/share/splint/imports:/af10/evans/LCLintDev/imports" -/* gcc's private include directory */ -#define GCC_INCLUDE_DIR "/usr/lib/gcc-lib/i386-linux/2.7.2.1/include" +/* system include directory */ +#define GCC_INCLUDE_DIR "/usr/include" -/* the system's main include directory */ +/* alternate include directory */ #define GCC_INCLUDE_DIR2 "/usr/local/include" /* String describing who compiled this binary and how */ @@ -21,12 +21,12 @@ /* Splint's version number */ #define LCL_PARSE_VERSION "Splint 3.0.0.20" -/* Splint's version number and release date */ -#define LCL_VERSION "Splint 3.0.0.20 --- 5 October 2001" - /* Define to disable support LCL files */ /* #undef NOLCL */ +/* Splint's version number and release date */ +#define SPLINT_VERSION "Splint 3.0.0.20 --- 29 December 2001" + /* The system's main include directory */ #define SYSTEM_LIBDIR "/usr/local/include" diff --git a/config.hin b/config.hin index ae5ab5a..3cff033 100644 --- a/config.hin +++ b/config.hin @@ -8,10 +8,10 @@ /* Splint's imports directory */ #undef DEFAULT_LCLIMPORTDIR -/* gcc's private include directory */ +/* system include directory */ #undef GCC_INCLUDE_DIR -/* the system's main include directory */ +/* alternate include directory */ #undef GCC_INCLUDE_DIR2 /* String describing who compiled this binary and how */ @@ -20,12 +20,12 @@ /* Splint's version number */ #undef LCL_PARSE_VERSION -/* Splint's version number and release date */ -#undef LCL_VERSION - /* Define to disable support LCL files */ #undef NOLCL +/* Splint's version number and release date */ +#undef SPLINT_VERSION + /* The system's main include directory */ #undef SYSTEM_LIBDIR diff --git a/configure b/configure index e2df344..12e6d76 100755 --- a/configure +++ b/configure @@ -2950,7 +2950,8 @@ if test x$ac_cv_c_compiler_gnu = xyes; then # This breaks on gcc-3.0 on redhat fixing drl 11-15-2001 # GCC_INCLUDE_DIR=`LANGUAGE= LANG= $CC -v 2>&1 | sed -e '/^gcc/ d' -e 's/.* \(.*\)specs/\1include/'` - GCC_INCLUDE_DIR=/usr/lib/gcc-lib/i386-linux/2.7.2.1/include +GCC_INCLUDE_DIR=/usr/include +# was /usr/lib/gcc-lib/i386-linux/2.7.2.1/include # GCC_INCLUDE_DIR=`LANGUAGE= LANG= $CC -v 2>&1 | sed -n -e '/^gcc/ d' -e 's/.* \(.*\)specs/\1include/p'` cat >>confdefs.h <>confdefs.h <>confdefs.h <&5 +{ echo "$as_me:3081: creating $CONFIG_STATUS" >&5 echo "$as_me: creating $CONFIG_STATUS" >&6;} cat >$CONFIG_STATUS <<_ACEOF #! $SHELL @@ -3253,7 +3254,7 @@ cat >>$CONFIG_STATUS <<\EOF echo "$ac_cs_version"; exit 0 ;; --he | --h) # Conflict between --help and --header - { { echo "$as_me:3256: error: ambiguous option: $1 + { { echo "$as_me:3257: error: ambiguous option: $1 Try \`$0 --help' for more information." >&5 echo "$as_me: error: ambiguous option: $1 Try \`$0 --help' for more information." >&2;} @@ -3272,7 +3273,7 @@ Try \`$0 --help' for more information." >&2;} ac_need_defaults=false;; # This is an error. - -*) { { echo "$as_me:3275: error: unrecognized option: $1 + -*) { { echo "$as_me:3276: error: unrecognized option: $1 Try \`$0 --help' for more information." >&5 echo "$as_me: error: unrecognized option: $1 Try \`$0 --help' for more information." >&2;} @@ -3324,7 +3325,7 @@ do "test/Makefile" ) CONFIG_FILES="$CONFIG_FILES test/Makefile" ;; "default-1" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;; "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.hin" ;; - *) { { echo "$as_me:3327: error: invalid argument: $ac_config_target" >&5 + *) { { echo "$as_me:3328: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac @@ -3570,7 +3571,7 @@ done; } esac if test x"$ac_file" != x-; then - { echo "$as_me:3573: creating $ac_file" >&5 + { echo "$as_me:3574: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} rm -f "$ac_file" fi @@ -3588,7 +3589,7 @@ echo "$as_me: creating $ac_file" >&6;} -) echo $tmp/stdin ;; [\\/$]*) # Absolute (can't be DOS-style, as IFS=:) - test -f "$f" || { { echo "$as_me:3591: error: cannot find input file: $f" >&5 + test -f "$f" || { { echo "$as_me:3592: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } echo $f;; @@ -3601,7 +3602,7 @@ echo "$as_me: error: cannot find input file: $f" >&2;} echo $srcdir/$f else # /dev/null tree - { { echo "$as_me:3604: error: cannot find input file: $f" >&5 + { { echo "$as_me:3605: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; @@ -3662,7 +3663,7 @@ for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue * ) ac_file_in=$ac_file.in ;; esac - test x"$ac_file" != x- && { echo "$as_me:3665: creating $ac_file" >&5 + test x"$ac_file" != x- && { echo "$as_me:3666: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} # First look for the input files in the build tree, otherwise in the @@ -3673,7 +3674,7 @@ echo "$as_me: creating $ac_file" >&6;} -) echo $tmp/stdin ;; [\\/$]*) # Absolute (can't be DOS-style, as IFS=:) - test -f "$f" || { { echo "$as_me:3676: error: cannot find input file: $f" >&5 + test -f "$f" || { { echo "$as_me:3677: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } echo $f;; @@ -3686,7 +3687,7 @@ echo "$as_me: error: cannot find input file: $f" >&2;} echo $srcdir/$f else # /dev/null tree - { { echo "$as_me:3689: error: cannot find input file: $f" >&5 + { { echo "$as_me:3690: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; @@ -3803,7 +3804,7 @@ cat >>$CONFIG_STATUS <<\EOF rm -f $tmp/in if test x"$ac_file" != x-; then if cmp -s $ac_file $tmp/config.h 2>/dev/null; then - { echo "$as_me:3806: $ac_file is unchanged" >&5 + { echo "$as_me:3807: $ac_file is unchanged" >&5 echo "$as_me: $ac_file is unchanged" >&6;} else ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ diff --git a/configure.ac b/configure.ac index 90d7f0d..9f4d37e 100644 --- a/configure.ac +++ b/configure.ac @@ -104,13 +104,14 @@ if test x$ac_cv_c_compiler_gnu = xyes; then # This breaks on gcc-3.0 on redhat fixing drl 11-15-2001 # GCC_INCLUDE_DIR=`LANGUAGE= LANG= $CC -v 2>&1 | sed -e '/^gcc/ d' -e 's/.* \(.*\)specs/\1include/'` - GCC_INCLUDE_DIR=/usr/lib/gcc-lib/i386-linux/2.7.2.1/include +GCC_INCLUDE_DIR=/usr/include +# was /usr/lib/gcc-lib/i386-linux/2.7.2.1/include # GCC_INCLUDE_DIR=`LANGUAGE= LANG= $CC -v 2>&1 | sed -n -e '/^gcc/ d' -e 's/.* \(.*\)specs/\1include/p'` AC_DEFINE_UNQUOTED(GCC_INCLUDE_DIR, "$GCC_INCLUDE_DIR", - [gcc's private include directory]) + [system include directory]) fi AC_DEFINE_UNQUOTED(GCC_INCLUDE_DIR2, "$myprefix/include", - [the system's main include directory]) + [alternate include directory]) # These used to be in local_constants.h AC_DEFINE_UNQUOTED(SYSTEM_LIBDIR, "$myprefix/include", @@ -123,7 +124,7 @@ AC_DEFINE_UNQUOTED(DEFAULT_LCLIMPORTDIR, ".$PATH_SEPARATOR$myprefix/share/splint # These used to be in herald.h LCL_PARSE_VERSION="AC_PACKAGE_NAME AC_PACKAGE_VERSION" -AC_DEFINE_UNQUOTED(LCL_VERSION, +AC_DEFINE_UNQUOTED(SPLINT_VERSION, "$LCL_PARSE_VERSION --- `cat $srcdir/src/DATE`", [Splint's version number and release date]) AC_DEFINE_UNQUOTED(LCL_PARSE_VERSION, "$LCL_PARSE_VERSION", diff --git a/src/Headers/osd.h b/src/Headers/osd.h index c7e2fbf..11e7d61 100644 --- a/src/Headers/osd.h +++ b/src/Headers/osd.h @@ -93,6 +93,7 @@ extern cstring osd_fixDefine (cstring); extern bool osd_fileIsReadable (cstring); extern bool osd_isConnectChar (char) /*@*/ ; +extern /*@observer@*/ cstring osd_getCurrentDirectory (void) /*@*/ ; # ifdef WIN32 extern int osd_getPid (void) ; diff --git a/src/fileTable.c b/src/fileTable.c index 9b57d95..f7f3e92 100644 --- a/src/fileTable.c +++ b/src/fileTable.c @@ -89,6 +89,7 @@ fileTable_getIndex (fileTable ft, cstring s) cstring abspath; if (ft == NULL) return NOT_FOUND; abspath = osd_absolutePath (cstring_undefined, s); + DPRINTF (("Absolute path: %s: %s", s, abspath)); res = cstringTable_lookup (ft->htable, abspath); cstring_free (abspath); return res; @@ -257,6 +258,7 @@ fileTable_internAddEntry (fileTable ft, /*@only@*/ ftentry e) ft->nspace--; + DPRINTF (("Adding: %s", e->fname)); cstringTable_insert (ft->htable, e->fname, ft->nentries); ft->elements[ft->nentries] = e; @@ -555,9 +557,14 @@ fileTable_exists (fileTable ft, cstring s) int tindex = fileTable_getIndex (ft, s); if (tindex == NOT_FOUND) - return FALSE; + { + DPRINTF (("Not found: %s", s)); + return FALSE; + } else - return TRUE; + { + return TRUE; + } } fileId diff --git a/src/llerror.c b/src/llerror.c index 8a589c7..db6372e 100644 --- a/src/llerror.c +++ b/src/llerror.c @@ -98,6 +98,7 @@ static bool s_needsPrepare = TRUE; void prepareMessage (void) { DPRINTF (("Prepare message: %s", bool_unparse (context_loadingLibrary ()))); + showHerald (); if ((context_isPreprocessing () || context_loadingLibrary ()) && s_needsPrepare diff --git a/src/llmain.c b/src/llmain.c index f8f5a64..ed9072c 100644 --- a/src/llmain.c +++ b/src/llmain.c @@ -91,8 +91,14 @@ static void cleanupFiles (void); static void showHelp (void); static void interrupt (int p_i); +static bool readOptionsFile (cstring p_fname, + cstringSList *p_passThroughArgs, + bool p_report) + /*@modifies fileSystem, internalState, *p_passThroughArgs@*/ ; + static void loadrc (FILE *p_rcfile, cstringSList *p_passThroughArgs) - /*@ensures closed p_rcfile@*/ ; + /*@modifies *p_passThroughArgs@*/ + /*@ensures closed p_rcfile@*/ ; static void describeVars (void); static bool specialFlagsHelp (char *p_next); @@ -778,34 +784,31 @@ int main (int argc, char *argv[]) if (*thisarg == '-' || *thisarg == '+') { + bool set = (*thisarg == '+'); + flagcode opt; + thisarg++; + opt = identifyFlag (cstring_fromChars (thisarg)); - if (mstring_equal (thisarg, "nof")) + if (opt == FLG_NOF) { nof = TRUE; } - else if (mstring_equal (thisarg, "f")) + else if (opt == FLG_SHOWSCAN || opt == FLG_WARNRC) + { + /* + ** Need to set it immediately, so rc file scan is displayed + */ + + context_userSetFlag (opt, set); + } + else if (opt == FLG_OPTF) { if (++i < argc) { defaultf = FALSE; fname = cstring_fromChars (argv[i]); - rcfile = fileTable_openFile (context_fileTable (), fname, "r"); - - if (rcfile != NULL) - { - fileloc oloc = g_currentloc; - - g_currentloc = fileloc_createRc (cstring_fromChars (fname)); - loadrc (rcfile, &passThroughArgs); - fileloc_reallyFree (g_currentloc); - g_currentloc = oloc; - } - else - { - showHerald (); - lldiagmsg (message ("Options file not found: %s", fname)); - } + readOptionsFile (fname, &passThroughArgs, TRUE); } else llfatalerror @@ -818,94 +821,72 @@ int main (int argc, char *argv[]) } } } - - if (cstring_isUndefined (fname)) - { - if (!cstring_isEmpty (home)) { - fname = message ("%s%h%s", home, CONNECTCHAR, - cstring_fromChars (RCFILE)); - cstring_markOwned (fname); - } - } - + setCodePoint (); if (!nof && defaultf) { - if (!cstring_isEmpty (fname)) - { - rcfile = fileTable_openFile (context_fileTable (), fname, "r"); - - if (rcfile != NULL) - { - fileloc oloc = g_currentloc; - - g_currentloc = fileloc_createRc (fname); - loadrc (rcfile, &passThroughArgs); - fileloc_reallyFree (g_currentloc); - g_currentloc = oloc; - } - } - -# if defined(MSDOS) || defined(OS2) - fname = message ("%s",cstring_fromChars (RCFILE)); -# else - fname = message ("./%s", cstring_fromChars (RCFILE)); -# endif - - rcfile = fileTable_openFile (context_fileTable (), fname, "r"); - /* - ** If no RCFILE, try ALTRCFILE + ** No explicit rc file, first try reading ~/.splintrc */ - if (rcfile == NULL) - { - cstring_free (fname); -# if defined(MSDOS) || defined(OS2) - fname = message ("%s", cstring_fromChars (ALTRCFILE)); -# else - fname = message ("./%s", cstring_fromChars (ALTRCFILE)); -# endif - rcfile = fileTable_openFile (context_fileTable (), fname, "r"); - } - else + if (cstring_isUndefined (fname)) { - /* - ** Warn if ALTRCFILE also exists - */ - cstring afname; - FILE *arcfile; - -# if defined(MSDOS) || defined(OS2) - afname = message ("%s", cstring_fromChars (ALTRCFILE)); -# else - afname = message ("./%s", cstring_fromChars (ALTRCFILE)); -# endif - arcfile = fileTable_openFile (context_fileTable (), afname, "r"); - - if (arcfile != NULL) + if (!cstring_isEmpty (home)) { - voptgenerror (FLG_WARNRC, - message ("Found both %s and %s files. Using %s file only.", - fname, afname, fname), - g_currentloc); + bool readhomerc, readaltrc; + cstring homename, altname; + + homename = message ("%s%h%s", home, CONNECTCHAR, + cstring_fromChars (RCFILE)); + readhomerc = readOptionsFile (homename, &passThroughArgs, FALSE); - fileTable_closeFile (context_fileTable (), arcfile); + /* + ** Try ~/.lclintrc also for historical accuracy + */ + + altname = message ("%s%h%s", home, CONNECTCHAR, + cstring_fromChars (ALTRCFILE)); + readaltrc = readOptionsFile (altname, &passThroughArgs, FALSE); + + if (readhomerc && readaltrc) + { + + voptgenerror + (FLG_WARNRC, + message ("Found both %s and %s files. Using both files, " + "but recommend using only %s to avoid confusion.", + homename, altname, homename), + g_currentloc); + } } } - if (rcfile != NULL) - { - fileloc oloc = g_currentloc; - - g_currentloc = fileloc_createRc (cstring_fromChars (fname)); - loadrc (rcfile, &passThroughArgs); - fileloc_reallyFree (g_currentloc); - g_currentloc = oloc; - } + /* + ** Next, read .splintrc in the current working directory + */ + + { + cstring rcname = message ("%s%s",osd_getCurrentDirectory (), cstring_fromChars (RCFILE)); + cstring altname = message ("%s%s",osd_getCurrentDirectory (), cstring_fromChars (ALTRCFILE)); + bool readrc, readaltrc; + + readrc = readOptionsFile (rcname, &passThroughArgs, FALSE); + readaltrc = readOptionsFile (altname, &passThroughArgs, FALSE); + + if (readrc && readaltrc) + { + voptgenerror (FLG_WARNRC, + message ("Found both %s and %s files. Using both files, " + "but recommend using only %s to avoid confusion.", + rcname, altname, rcname), + g_currentloc); + + } - sfree (fname); + cstring_free (rcname); + cstring_free (altname); + } } } @@ -1020,8 +1001,9 @@ int main (int argc, char *argv[]) opt = identifyFlag (flagname); DPRINTF (("Flag: %s", flagcode_unparse (opt))); - if (flagcode_isSkip (opt)) + if (flagcode_isSkip (opt) || opt == FLG_SHOWSCAN || opt == FLG_WARNRC) { + /* showscan already processed */ DPRINTF (("Skipping!")); } else if (flagcode_isInvalid (opt)) @@ -1158,7 +1140,8 @@ int main (int argc, char *argv[]) } setCodePoint (); - + showHerald (); + /* ** create lists of C and LCL files */ @@ -1215,8 +1198,6 @@ int main (int argc, char *argv[]) } } end_cstringSList_elements; - showHerald (); /*@i723 move earlier? */ - if (showhelp) { if (allhelp) @@ -2264,6 +2245,55 @@ llexit (int status) exit ((status == LLSUCCESS) ? EXIT_SUCCESS : EXIT_FAILURE); } +bool readOptionsFile (cstring fname, cstringSList *passThroughArgs, bool report) +{ + bool res = FALSE; + + if (fileTable_exists (context_fileTable (), fname)) + { + if (report) + { + voptgenerror + (FLG_WARNRC, + message ("Multiple attempts to read options file: %s", fname), + g_currentloc); + } + } + else + { + FILE *innerf = fileTable_openFile (context_fileTable (), fname, "r"); + + if (innerf != NULL) + { + fileloc fc = g_currentloc; + g_currentloc = fileloc_createRc (fname); + + if (context_getFlag (FLG_SHOWSCAN)) + { + lldiagmsg (message ("< reading options from %s >", + fileloc_outputFilename (g_currentloc))); + } + + loadrc (innerf, passThroughArgs); + fileloc_reallyFree (g_currentloc); + g_currentloc = fc; + res = TRUE; + } + else + { + if (report) + { + voptgenerror + (FLG_WARNRC, + message ("Cannot open options file: %s", fname), + g_currentloc); + } + } + } + + return res; +} + /* ** This shouldn't be necessary, but Apple Darwin can't handle '"''s. */ @@ -2274,7 +2304,7 @@ loadrc (/*:open:*/ FILE *rcfile, cstringSList *passThroughArgs) { char *s = mstring_create (MAX_LINE_LENGTH); char *os = s; - + DPRINTF (("Pass through: %s", cstringSList_unparse (*passThroughArgs))); s = os; @@ -2499,26 +2529,7 @@ loadrc (/*:open:*/ FILE *rcfile, cstringSList *passThroughArgs) } else if (opt == FLG_OPTF) { - FILE *innerf = fileTable_openFile (context_fileTable (), extra, "r"); - cstring_markOwned (extra); - - if (innerf != NULL) - { - fileloc fc = g_currentloc; - g_currentloc = fileloc_createRc (extra); - loadrc (innerf, passThroughArgs); - fileloc_reallyFree (g_currentloc); - g_currentloc = fc; - } - else - { - showHerald (); - voptgenerror - (FLG_BADFLAG, - message ("Options file not found: %s", - extra), - g_currentloc); - } + (void) readOptionsFile (extra, passThroughArgs, TRUE); } else if (opt == FLG_INIT) { diff --git a/src/osd.c b/src/osd.c index 1ea84ef..1f9a2d7 100644 --- a/src/osd.c +++ b/src/osd.c @@ -1087,5 +1087,14 @@ cstring osd_outputPath (cstring filename) # endif } +cstring osd_getCurrentDirectory () +{ +# if defined(MSDOS) || defined(OS2) + return cstring_makeLiteralTemp (""); +# else + return cstring_makeLiteralTemp ("./"); +# endif +} + diff --git a/src/uentry.c b/src/uentry.c index 7bba3f1..8f23522 100644 --- a/src/uentry.c +++ b/src/uentry.c @@ -43,6 +43,8 @@ static bool uentry_isReallySpecified (uentry p_e) /*@*/ ; static void uentry_checkIterArgs (uentry p_ue); static cstring uentry_dumpAux (uentry p_v, bool p_isParam); +static void uentry_showWhereLastKind (uentry p_spec) /*@*/ ; + static void uentry_combineModifies (uentry p_ue, /*@owned@*/ sRefSet p_sr) /*@modifies p_ue@*/ ; @@ -6822,9 +6824,9 @@ KindConformanceError (/*@unique@*/ uentry old, uentry unew, bool mustConform) uentry_getName (unew), ekind_unparseLong (unew->ukind), unew->utype), - uentry_whereDeclared (unew))) + uentry_whereLast (unew))) /* evans 2001-12-30: was uentry_whereDeclared */ { - uentry_showWhereLast (old); + uentry_showWhereLastKind (old); } } else @@ -6841,9 +6843,9 @@ KindConformanceError (/*@unique@*/ uentry old, uentry unew, bool mustConform) uentry_getName (unew), ekind_unparseLong (unew->ukind), unew->utype), - uentry_whereDeclared (unew))) + uentry_whereLast (unew))) /* evans 2001-12-30: was uentry_whereDeclared */ { - uentry_showWhereLast (old); + uentry_showWhereLastKind (old); } } } @@ -6851,15 +6853,18 @@ KindConformanceError (/*@unique@*/ uentry old, uentry unew, bool mustConform) { llassert (uentry_isDeclared (unew)); + DPRINTF (("Old: \n\t%s", uentry_unparseFull (old))); + DPRINTF (("New: \n\t%s", uentry_unparseFull (unew))); + if (optgenerror (FLG_INCONDEFS, message ("%s %q inconsistently redeclared as %s", ekind_capName (old->ukind), uentry_getName (unew), ekind_unparseLong (unew->ukind)), - uentry_whereDeclared (unew))) + uentry_whereLast (unew))) /* evans 2001-12-30: was uentry_whereDeclared */ { - uentry_showWhereLast (old); + uentry_showWhereLastKind (old); } } } @@ -6883,7 +6888,7 @@ uentry_showWhereLast (uentry spec) { if (fileloc_isDefined (spec->whereDefined) && !fileloc_isLib (spec->whereDefined) - && !fileloc_isPreproc (spec->whereDefined)) + /*!! && !fileloc_isPreproc (spec->whereDefined) */ ) { llgenindentmsg (message ("Previous definition of %q: %t", uentry_getName (spec), @@ -6919,6 +6924,54 @@ uentry_showWhereLast (uentry spec) } } +static void +uentry_showWhereLastKind (uentry spec) +{ + if (uentry_isValid (spec)) + { + if (fileloc_isDefined (spec->whereDefined) + && !fileloc_isLib (spec->whereDefined) + /*!! && !fileloc_isPreproc (spec->whereDefined) */ ) + { + llgenindentmsg (message ("Previous definition of %q as %s: %t", + uentry_getName (spec), + ekind_unparseLong (spec->ukind), + uentry_getType (spec)), + uentry_whereDefined (spec)); + } + else if (uentry_isDeclared (spec)) + { + llgenindentmsg (message ("Previous declaration of %q as %s: %t", + uentry_getName (spec), + ekind_unparseLong (spec->ukind), + uentry_getType (spec)), + uentry_whereDeclared (spec)); + } + else if (uentry_isSpecified (spec)) + { + if (uentry_hasName (spec)) + { + llgenindentmsg (message ("Specification of %q as %s: %t", + uentry_getName (spec), + ekind_unparseLong (spec->ukind), + uentry_getType (spec)), + uentry_whereSpecified (spec)); + } + else + { + llgenindentmsg (message ("Specification as %s: %t", + ekind_unparseLong (spec->ukind), + uentry_getType (spec)), + uentry_whereSpecified (spec)); + } + } + else + { + /* nothing to show */ + } + } +} + void uentry_showDefSpecInfo (uentry ce, fileloc fwhere) { diff --git a/test/Makefile.am b/test/Makefile.am index a7bf2ab..b6fbfa5 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -17,15 +17,15 @@ unexport LCLIMPORTDIR ### This is horrible! Can't we make top_builddir absolute? SPLINTNEST = ../$(top_builddir)/src/splint$(EXEEXT) -SPLINTPNEST = @$(SPLINTNEST) -SPLINTP = @$(SPLINT) +SPLINTPNEST = @$(SPLINTNEST) -nof +SPLINTP = @$(SPLINT) -nof # Make sure .splintrc files are not used so test results do not # depend on local settings. -SPLINTRN = $(SPLINTP) -nof -hints -booltype "bool" +SPLINTRN = $(SPLINTP) -hints -booltype "bool" SPLINTR = $(SPLINTRN) -exportlocal +debugfcnconstraint -SPLINTRNNEST = $(SPLINTPNEST) -nof -hints -booltype "bool" +SPLINTRNNEST = $(SPLINTPNEST) -hints -booltype "bool" SPLINTRNEST = $(SPLINTRNNEST) -exportlocal +debugfcnconstraint ## Currently disabled tests: @@ -33,12 +33,8 @@ SPLINTRNEST = $(SPLINTRNNEST) -exportlocal +debugfcnconstraint ## nullret nullassign warnuse ### -### !!! -### These tests have been temporarily removed because of problems with the new build process: -### fileio tainted mergestate metastate \ -### tests2.2 tests2.2a tests2.4 tests2.5 -### -### maxset strchr for +### rcfiles not included becuase file names will not match exactly +### UNITTESTS = \ help \ @@ -53,10 +49,10 @@ UNITTESTS = \ funcpointer glob globals impabstract init inparam internal iter keep libs \ linked lintcomments list macros macrosef merge mergenull modifies modtest moduncon \ mongoincludes mystrncat noeffect null observer oldstyle outglob outparam \ - postnotnull preds prefixes printflike rc rcfiles refcounts release repexpose \ + postnotnull preds prefixes printflike rc refcounts release repexpose \ returned sharing slovaknames specclauses special stack staticarray strings \ structassign typequals ud ulstypes union unreachable unsignedcompare \ - unused ullint void + unused ullint utypes void UNITEXPECTS = $(addsuffix .expect, $(UNITTESTS)) INTEGTESTS = db1 db2 db3 @@ -75,8 +71,8 @@ version: .PHONY: help help: - -@$(SPLINTP) - -@LARCH_PATH=/dev/null; $(SPLINT) empty.lcl + -@$(SPLINT) + -@LARCH_PATH=/dev/null; $(SPLINT) -nof empty.lcl -@$(SPLINTP) -help -@$(SPLINTP) -asdf -@$(SPLINTP) +boolint +boolint @@ -728,6 +724,16 @@ ullint: ${SPLINTRN} ullint.c -expect 5 ${SPLINTRN} ullint.c +charint +charintliteral -expect 2 +### +### 2001-12-30: Poor warnings reported by Peter Deutsch +### + +.PHONY: utypes +utypes: + ${SPLINTRN} utypes.c -expect 6 + +### + .PHONY: void void: ${SPLINTRN} void.c -expect 2 diff --git a/test/Makefile.in b/test/Makefile.in index 24a6ba8..bbd2857 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -90,25 +90,21 @@ SPLINT = $(top_builddir)/src/splint$(EXEEXT) ### This is horrible! Can't we make top_builddir absolute? SPLINTNEST = ../$(top_builddir)/src/splint$(EXEEXT) -SPLINTPNEST = @$(SPLINTNEST) -SPLINTP = @$(SPLINT) +SPLINTPNEST = @$(SPLINTNEST) -nof +SPLINTP = @$(SPLINT) -nof # Make sure .splintrc files are not used so test results do not # depend on local settings. -SPLINTRN = $(SPLINTP) -nof -hints -booltype "bool" +SPLINTRN = $(SPLINTP) -hints -booltype "bool" SPLINTR = $(SPLINTRN) -exportlocal +debugfcnconstraint -SPLINTRNNEST = $(SPLINTPNEST) -nof -hints -booltype "bool" +SPLINTRNNEST = $(SPLINTPNEST) -hints -booltype "bool" SPLINTRNEST = $(SPLINTRNNEST) -exportlocal +debugfcnconstraint ### -### !!! -### These tests have been temporarily removed because of problems with the new build process: -### fileio tainted mergestate metastate \ -### tests2.2 tests2.2a tests2.4 tests2.5 -### -### maxset strchr for +### rcfiles not included becuase file names will not match exactly +### UNITTESTS = \ help \ fileio tainted mergestate metastate sizeof buffertest \ @@ -122,10 +118,10 @@ UNITTESTS = \ funcpointer glob globals impabstract init inparam internal iter keep libs \ linked lintcomments list macros macrosef merge mergenull modifies modtest moduncon \ mongoincludes mystrncat noeffect null observer oldstyle outglob outparam \ - postnotnull preds prefixes printflike rc rcfiles refcounts release repexpose \ + postnotnull preds prefixes printflike rc refcounts release repexpose \ returned sharing slovaknames specclauses special stack staticarray strings \ structassign typequals ud ulstypes union unreachable unsignedcompare \ - unused ullint void + unused ullint utypes void UNITEXPECTS = $(addsuffix .expect, $(UNITTESTS)) @@ -907,8 +903,8 @@ version: .PHONY: help help: - -@$(SPLINTP) - -@LARCH_PATH=/dev/null; $(SPLINT) empty.lcl + -@$(SPLINT) + -@LARCH_PATH=/dev/null; $(SPLINT) -nof empty.lcl -@$(SPLINTP) -help -@$(SPLINTP) -asdf -@$(SPLINTP) +boolint +boolint @@ -1537,6 +1533,16 @@ ullint: ${SPLINTRN} ullint.c -expect 5 ${SPLINTRN} ullint.c +charint +charintliteral -expect 2 +### +### 2001-12-30: Poor warnings reported by Peter Deutsch +### + +.PHONY: utypes +utypes: + ${SPLINTRN} utypes.c -expect 6 + +### + .PHONY: void void: ${SPLINTRN} void.c -expect 2 diff --git a/test/ansireserved.expect b/test/ansireserved.expect index b7e08a8..0bde7dd 100644 --- a/test/ansireserved.expect +++ b/test/ansireserved.expect @@ -54,11 +54,11 @@ ansireserved.c:9: Name EVANS is reserved for future ANSI library extensions. . (See ANSI, Section 4.13.1) ansireserved.c:1:5: Name decimal_point is reserved for the standard library ansireserved.c:2:5: Function srand inconsistently declared as variable: int - load file ansi.lcd:897:1: Specification of srand: + load file ansi.lcd:897:1: Specification of srand as function: [function (unsigned int) returns void] ansireserved.c:2:5: Name srand is reserved for the standard library ansireserved.c:3:5: Function labs inconsistently declared as variable: int - load file ansi.lcd:919:1: Specification of labs: + load file ansi.lcd:919:1: Specification of labs as function: [function (long int) returns long int] ansireserved.c:3:5: Name labs is reserved for the standard library ansireserved.c:4:5: Name _x is in the implementation name space (any identifier diff --git a/test/mergenull.c b/test/mergenull.c new file mode 100644 index 0000000..0026126 --- /dev/null +++ b/test/mergenull.c @@ -0,0 +1,20 @@ +/* +** Added 2001-12-29 +** Test for branchstate bug reported by Jon Wilson +*/ + +typedef /*@null@*/ struct s_foo *foo; + +struct s_foo { + foo p; +} ; + +void f (foo a) +{ + while ( a != NULL ) { + foo temp = a->p ; + a->p = NULL ; + a = temp ; + } +} + diff --git a/test/mergenull.expect b/test/mergenull.expect new file mode 100644 index 0000000..2b06c77 --- /dev/null +++ b/test/mergenull.expect @@ -0,0 +1,2 @@ + +Finished checking --- no warnings diff --git a/test/utypes.c b/test/utypes.c new file mode 100644 index 0000000..38cda60 --- /dev/null +++ b/test/utypes.c @@ -0,0 +1,27 @@ +/* Define short names for the unsigned types. */ +typedef unsigned char byte; +typedef unsigned char uchar; +typedef unsigned short ushort; +typedef unsigned int uint; +typedef unsigned long ulong; + +/* Since sys/types.h often defines one or more of these (depending on */ +/* the platform), we have to take steps to prevent name clashes. */ +/*** NOTE: This requires that you include std.h *before* any other ***/ +/*** header file that includes sys/types.h. ***/ +#define bool bool_ /* (maybe not needed) */ +#define uchar uchar_ +#define uint uint_ +#define ushort ushort_ +#define ulong ulong_ +#include +#undef bool +#undef uchar +#undef uint +#undef ushort +#undef ulong + +void f (unsigned int width) +{ + uint src_bytes = width >> 3; +} diff --git a/test/utypes.expect b/test/utypes.expect new file mode 100644 index 0000000..008e619 --- /dev/null +++ b/test/utypes.expect @@ -0,0 +1,17 @@ + +utypes.c:16: Include file matches the name of a POSIX library, + but the POSIX library is not being used. Consider using +posixlib or + +posixstrictlib to select the POSIX library, or -warnposix to suppress this + message. +utypes.c:3:23: Variable uchar inconsistently redeclared as datatype + utypes.c:13: Previous definition of uchar as variable: ? +utypes.c:4:24: Variable ushort inconsistently redeclared as datatype + utypes.c:15: Previous definition of ushort as variable: ? +utypes.c:5:22: Variable uint inconsistently redeclared as datatype + utypes.c:14: Previous definition of uint as variable: ? +utypes.c:6:23: Variable ulong inconsistently redeclared as datatype + utypes.c:16: Previous definition of ulong as variable: ? +utypes.c: (in function f) +utypes.c:26:8: Variable src_bytes declared but not used + +Finished checking --- 6 code warnings, as expected -- 2.45.2