X-Git-Url: http://andersk.mit.edu/gitweb/splint.git/blobdiff_plain/7ac543fa1ffcb930d63a610110fa05949421f860..3dabb0778770a6ee8a2af1a104325e2651933ce1:/src/usymtab.c diff --git a/src/usymtab.c b/src/usymtab.c index 3b60b21..cf207a3 100644 --- a/src/usymtab.c +++ b/src/usymtab.c @@ -105,6 +105,10 @@ static bool usymtab_isAltDefinitelyNull (sRef p_s) /*@globals utab@*/ ; static void refTable_free (/*@only@*/ /*@null@*/ refTable p_x, int p_nentries); static ctype usymtab_suFieldsType (uentryList p_f, bool p_isStruct) /*@globals globtab@*/ ; +static void usymtab_freeAux (/*@only@*/ usymtab p_u) + /*@globals globtab, utab, filetab@*/ + /*@modifies p_u@*/ ; + extern int usymtab_getCurrentDepth (void) /*@globals utab@*/ { return utab->lexlevel; @@ -148,7 +152,7 @@ static /*@exposed@*/ /*@dependent@*/ uentry static /*@exposed@*/ /*@dependent@*/ uentry usymtab_lookupQuietNoAlt (usymtab p_s, cstring p_k); -static void usymtab_printAllAux (usymtab p_s) /*@modifies g_msgstream@*/ ; +static void usymtab_printAllAux (usymtab p_s) /*@modifies g_warningstream@*/ ; static int usymtab_getIndex (/*@notnull@*/ usymtab p_s, cstring p_k); static /*@exposed@*/ uentry usymtab_fetchIndex (/*@notnull@*/ usymtab p_s, int p_i); static /*@exposed@*/ uentry @@ -297,7 +301,8 @@ static /*@notnull@*/ /*@special@*/ usymtab t->mustBreak = FALSE; t->exitCode = XK_NEVERESCAPE; - + + DPRINTF (("Create usymtab [%p]", t)); return t; } @@ -339,6 +344,14 @@ usymtab_initMod (void) oldtab = usymtab_undefined; } +void +usymtab_destroyMod (void) /*@modifies utab, globtab, filetab@*/ /*@globals killed utab@*/ +{ + DPRINTF (("Destroy usymtab [%p]: %d", utab, utab->nentries)); + usymtab_freeAux (utab); + utab = usymtab_undefined; + /*@-globstate@*/ +} /*@=globstate@*/ void usymtab_initGlobalMarker () /*@globals globtab@*/ @@ -363,6 +376,8 @@ usymtab_initGlobalMarker () /*@globals globtab@*/ void usymtab_initBool () { + DPRINTF (("Init bool!")); + if (context_getFlag (FLG_NOLIB)) { ctype boolt = ctype_bool; @@ -889,7 +904,8 @@ usymtab_supEntryAux (/*@notnull@*/ usymtab st, if (!(st->lexlevel > fileScope || !sRef_modInFunction ())) { if (uentry_isDatatype (e) || uentry_isAnyTag (e) - || uentry_isEnumConstant (e)) + || uentry_isEnumConstant (e) + || uentry_isStatic (e)) /* bug fix from Brian St. Pierre */ { ; /* ** Not a bug. Code like, @@ -1016,7 +1032,6 @@ usymtab_supEntryAux (/*@notnull@*/ usymtab st, return (staticEntry ? USYMIDINVALID : eindex); } -# ifndef NOLCL static void usymtab_replaceEntryAux (/*@notnull@*/ usymtab st, /*@only@*/ uentry e) /*@globals globtab@*/ /*@modifies st, e@*/ @@ -1045,7 +1060,6 @@ usymtab_replaceEntryAux (/*@notnull@*/ usymtab st, /*@only@*/ uentry e) eindex = usymtab_addEntryAux (st, e, FALSE); } } -# endif /*@=deparrays@*/ @@ -1263,7 +1277,6 @@ usymtab_supAbstractTypeEntry (/*@only@*/ uentry e, bool dodef) return (uid); } -# ifndef NOLCL usymId usymtab_supExposedTypeEntry (/*@only@*/ uentry e, bool dodef) /*@globals globtab, filetab@*/ @@ -1287,7 +1300,6 @@ usymtab_supExposedTypeEntry (/*@only@*/ uentry e, bool dodef) return (uid); } -# endif ctype usymtab_supForwardTypeEntry (/*@only@*/ uentry e) @@ -1313,7 +1325,6 @@ void /*@modifies utab, globtab, e@*/ { sRef old = uentry_getSref (e); - if (sRef_isType (old)) { @@ -1595,7 +1606,7 @@ usymtab_rehash (/*@notnull@*/ usymtab s) cstringTable_free (s->htable); } - s->htable = cstringTable_create (LLHASHSIZE); + s->htable = cstringTable_create (LLAHSHSIZE); for (i = 0; i < s->nentries; i++) { @@ -1799,6 +1810,17 @@ void usymtab_dump (FILE *fout) lastekind = KINVALID; fprintf(fout, ";; Library constraints\n"); + + /*drl July 27 added this so that libraries without + buffer constraints would be handled correctly. + I'm trying to do this without breaking older libraries. + + Splint should still be able to handle libraries without this message. + */ + + + fprintf(fout, "start_Buffer_Constraints\n"); + for (i = 0; i < utab->nentries; i++) { uentry thisentry = utab->entries[i]; @@ -1990,6 +2012,17 @@ void usymtab_load (FILE *f) { ; /* ignore ;-comments */ } + + /*drl July 27 added this so that libraries without + buffer constraints would be handled correctly. + I'm trying to do this without breaking older libraries*/ + + /*check for "optional" start buffer constraints message*/ + + if (mstring_equalPrefix (s, "start_Buffer_Constraints")) + { + (void) fgets (s, MAX_DUMP_LINE_LENGTH, f); + } while (s != NULL && *s != ';') { @@ -2068,8 +2101,8 @@ usymtab_enterFile () { if (sRef_hasDerived (uentry_getSref (ue))) { - fprintf (g_msgstream, "Derived Global: %s\n", uentry_unparse (ue)); - fprintf (g_msgstream, "sRef: %s\n", sRef_unparseFull (ue->sref)); + fprintf (g_warningstream, "Derived Global: %s\n", uentry_unparse (ue)); + fprintf (g_warningstream, "sRef: %s\n", sRef_unparseFull (ue->sref)); } } end_usymtab_entries ; @@ -2327,6 +2360,8 @@ usymtab_enterFunctionScope (uentry fcn) { usymtab t = usymtab_create (US_NORMAL, utab, TRUE); + DPRINTF (("Enter function: %s", uentry_unparse (fcn))); + if (utab->lexlevel != fileScope) { if (utab->lexlevel > fileScope) @@ -2424,6 +2459,9 @@ usymtab_enterFunctionScope (uentry fcn) } end_globSet_allElements; DPRINTF (("Globs after: %s", globSet_unparse (uentry_getGlobs (fcn)))); +# ifdef DEBUGSPLINT + usymtab_checkAllValid (); +# endif } static void @@ -2905,13 +2943,17 @@ updateNullState (sRef el, /*@notnull@*/ usymtab ttab, if (!guardSet_isGuarded (ttab->guards, el) && !sRef_isNotNull (sr)) { + DPRINTF (("Here! %s / %s", + sRef_unparseFull (sr), + sRef_unparseFull (el))); sRef_setDerivNullState (sr, el, NS_DEFNULL); - } + } } } else { - } + ; + } ue = usymtab_getRefTab (ftab, level, index); @@ -2919,7 +2961,6 @@ updateNullState (sRef el, /*@notnull@*/ usymtab ttab, { sRef sr = uentry_getSref (ue); - if (!trueGuard) /* yikes! forgot the ! */ { sRef_setDerivNullState (sr, el, NS_NOTNULL); @@ -2931,7 +2972,7 @@ updateNullState (sRef el, /*@notnull@*/ usymtab ttab, && !sRef_isNotNull (sr)) { sRef_setDerivNullState (sr, el, NS_DEFNULL); - } + } } } else @@ -3693,7 +3734,7 @@ checkGlobalReturn (uentry glob, sRef orig) else { ctype ct = ctype_realType (uentry_getType (glob)); - + DPRINTF (("Check global destroyed: %s", uentry_unparseFull (glob))); if (ctype_isVisiblySharable (ct)) @@ -3771,6 +3812,7 @@ checkGlobalReturn (uentry glob, sRef orig) } else { + DPRINTF (("Check transfer: %s", uentry_unparseFull (glob))); transferChecks_globalReturn (glob); } } @@ -4305,6 +4347,8 @@ usymtab_quietExitScope (fileloc loc) { usymtab t = utab->env; + DPRINTF (("Quiet exit scope [%p]", utab)); + if (utab->reftable != NULL) { int i; @@ -4331,9 +4375,14 @@ usymtab_quietExitScope (fileloc loc) t->mustBreak = utab->mustBreak; t->exitCode = utab->exitCode; + DPRINTF (("Free level [%p]", utab)); usymtab_freeLevel (utab); utab = t; + +# ifdef DEBUGSPLINT + usymtab_checkAllValid (); +# endif } /* @@ -4361,7 +4410,7 @@ void usymtab_exitScope (exprNode expr) usymtab lctab = usymtab_undefined; bool mustReturn = exprNode_mustEscape (expr); - DPRINTF (("Exit scope")); + DPRINTF (("Exit scope [%p]", utab)); if (utab->kind == US_CBRANCH) { @@ -4380,32 +4429,34 @@ void usymtab_exitScope (exprNode expr) } if (utab->kind == US_TBRANCH || utab->kind == US_FBRANCH - || utab->kind == US_CBRANCH || utab->kind == US_SWITCH) { - - if (context_inMacro ()) { - /* evs 2000-07-25 */ - /* Unparseable macro may end inside nested scope. Deal with it. */ - - llerror (FLG_SYNTAX, - message ("Problem parsing macro body of %s (unbalanced scopes). " - "Attempting to recover, recommend /*@notfunction@*/ before " - "macro definition.", - context_inFunctionName ())); - - while (utab->kind == US_TBRANCH - || utab->kind == US_FBRANCH - || utab->kind == US_CBRANCH - || utab->kind == US_SWITCH) + || utab->kind == US_CBRANCH || utab->kind == US_SWITCH) + { + if (context_inMacro ()) { - utab = utab->env; - llassert (utab != GLOBAL_ENV); - } - } else { - llcontbug (message ("exitScope: in branch: %q", usymtab_unparseStack ())); - /*@-branchstate@*/ - } /*@=branchstate@*/ - } - + /* evs 2000-07-25 */ + /* Unparseable macro may end inside nested scope. Deal with it. */ + + llerror (FLG_SYNTAX, + message ("Problem parsing macro body of %s (unbalanced scopes). " + "Attempting to recover, recommend /*@notfunction@*/ before " + "macro definition.", + context_inFunctionName ())); + + while (utab->kind == US_TBRANCH + || utab->kind == US_FBRANCH + || utab->kind == US_CBRANCH + || utab->kind == US_SWITCH) + { + utab = utab->env; + llassert (utab != GLOBAL_ENV); + } + } else + { + llcontbug (message ("exitScope: in branch: %q", usymtab_unparseStack ())); + /*@-branchstate@*/ + } /*@=branchstate@*/ + } + /* ** check all variables in scope were used */ @@ -4431,7 +4482,7 @@ void usymtab_exitScope (exprNode expr) ** NOTE: note for exiting paramsScope, since checkReturn should be ** called first. */ - + if (!mustReturn && (usymtab_lexicalLevel () > functionScope)) { /* @@ -4450,7 +4501,6 @@ void usymtab_exitScope (exprNode expr) uentryList params = context_getParams (); globSet globs = context_getUsedGlobs (); - uentryList_elements (params, ue) { uentry_fixupSref (ue); @@ -4458,9 +4508,12 @@ void usymtab_exitScope (exprNode expr) clearFunctionTypes (); - + DPRINTF (("Fixing up globals: %s", globSet_unparse (globs))); + globSet_allElements (globs, el) { + DPRINTF (("Fix: %s", sRef_unparseDebug (el))); + if (sRef_isCvar (el)) { uentry current; @@ -4478,13 +4531,17 @@ void usymtab_exitScope (exprNode expr) if (uentry_isVariable (current)) { + DPRINTF (("Fixup: %s", uentry_unparse (current))); uentry_fixupSref (current); } else { + DPRINTF (("Clear: %s", uentry_getSref (current))); sRef_clearDerived (uentry_getSref (current)); } } + + sRef_clearDerived (el); /* evans 2002-03-14 - this is the likely source of many crashes! */ } end_globSet_allElements; } @@ -4496,6 +4553,11 @@ void usymtab_exitScope (exprNode expr) /*@i@*/ utab = ctab; /*@-branchstate@*/ } /*@=branchstate@*/ /*@-globstate@*/ + + +# ifdef DEBUGSPLINT + usymtab_checkAllValid (); +# endif /*@i523@*/ } /*@=globstate@*/ @@ -4512,13 +4574,7 @@ uentry_directParamNo (uentry ue) if (sRef_lexLevel (sr) == functionScope) { - int index; - - /*@access sRef@*/ - llassert (sr->info != NULL); - llassert (sr->info->cvar != NULL); - index = sr->info->cvar->index; - /*@noaccess sRef@*/ + int index = sRef_getScopeIndex (sr); if (index < uentryList_size (context_getParams ())) { @@ -4850,7 +4906,15 @@ usymtab_addRefEntry (/*@notnull@*/ usymtab s, cstring k) uentry ue; DPRINTF (("Here: copying %s", uentry_unparse (current))); - ue = uentry_copy (current); + if (uentry_isNonLocal (current)) + { + ue = uentry_copy (current); + } + else + { + ue = uentry_copyNoSave (current); + } + DPRINTF (("Here: copying %s", uentry_unparse (ue))); usymtab_addEntryQuiet (ut, ue); DPRINTF (("Okay...")); @@ -4949,6 +5013,7 @@ usymtab_lookupQuietAux (usymtab s, cstring k, bool noalt) } else { + llassert (s != NULL); /*@i523 should not need this? */ s = s->env; } } @@ -5011,6 +5076,7 @@ uentry usymtab_lookupGlob (cstring k) if (uentry_isPriv (ce)) llfatalbug (message ("usymtab_lookup: private: %s", k)); + DPRINTF (("Lookup global: %s", uentry_unparseFull (ce))); return ce; } @@ -5019,7 +5085,7 @@ uentry usymtab_lookupGlob (cstring k) /*@globals globtab@*/ { uentry ce = usymtab_lookupAux (globtab, k); - + DPRINTF (("Lookup global: %s", uentry_unparseFull (ce))); return ce; } @@ -5031,10 +5097,10 @@ uentry usymtab_lookupEither (cstring k) if (uentry_isUndefined (ce)) llfatalerror (message ("usymtab_lookup: not found: %s", k)); + DPRINTF (("Lookup either: %s", uentry_unparseFull (ce))); return ce; } -# ifndef NOLCL ctype usymtab_lookupType (cstring k) /*@globals globtab@*/ @@ -5049,7 +5115,6 @@ usymtab_lookupType (cstring k) return (uentry_getRealType (usymtab_getTypeEntry (uid))); } -# endif ctype usymtab_lookupAbstractType (cstring k) /*@globals globtab@*/ @@ -5184,7 +5249,6 @@ bool return (!(uentry_isUndefined (ce)) && !(uentry_isPriv (ce))); } -# ifndef NOLCL bool usymtab_existsEither (cstring k) /*@globals utab@*/ @@ -5202,7 +5266,6 @@ bool return (uentry_isValid (ce)); } -# endif bool usymtab_existsType (cstring k) @@ -5252,7 +5315,6 @@ usymtab_existsEnumTag (cstring k) /*@globals globtab@*/ return (!(uentry_isUndefined (ce)) && !(uentry_isPriv (ce))); } -# ifndef NOLCL bool usymtab_existsVar (cstring k) /*@globals utab@*/ { @@ -5260,7 +5322,6 @@ bool usymtab_existsVar (cstring k) return (!(uentry_isUndefined (ce)) && !(uentry_isPriv (ce)) && (uentry_isVar (ce))); } -# endif /* ** destructors @@ -5288,6 +5349,7 @@ usymtab_freeLevel (/*@notnull@*/ /*@only@*/ usymtab u) { int i; + DPRINTF (("Free level [%p]", u)); aliasTable_free (u->aliases); refTable_free (u->reftable, u->nentries); @@ -5296,7 +5358,10 @@ usymtab_freeLevel (/*@notnull@*/ /*@only@*/ usymtab u) { for (i = 0; i < u->nentries; i++) { + DPRINTF (("Free complete: %d", i)); + DPRINTF (("Uentry: %s", uentry_unparse (u->entries[i]))); uentry_freeComplete (u->entries[i]); + u->entries[i] = uentry_undefined; } } else @@ -5304,6 +5369,7 @@ usymtab_freeLevel (/*@notnull@*/ /*@only@*/ usymtab u) for (i = 0; i < u->nentries; i++) { uentry_free (u->entries[i]); + u->entries[i] = uentry_undefined; } } @@ -5315,11 +5381,11 @@ usymtab_freeLevel (/*@notnull@*/ /*@only@*/ usymtab u) && u != filetab) { llassert (!cstringTable_isDefined (u->htable)); - sfree (u); } -/*@-mustfree@*/ -} /*@=mustfree@*/ + sfree (u); /* evans 2002-07-12: was inside if */ + /*:!!mustfree@*/ +} /*!@=mustfree@*/ static void usymtab_freeAux (/*@only@*/ usymtab u) @@ -5342,7 +5408,8 @@ void usymtab_free () { dbgfree = TRUE; usymtab_freeAux (utab); -} + utab = usymtab_undefined; +/*@i523@*/ } static int usymtab_lexicalLevel (void) /*@globals utab@*/ { @@ -5364,7 +5431,6 @@ bool usymtab_inFunctionScope () /*@globals utab@*/ return (utab->lexlevel == functionScope); } -# ifndef NOLCL void usymtab_replaceEntry (uentry s) /*@globals utab, globtab@*/ @@ -5372,7 +5438,6 @@ usymtab_replaceEntry (uentry s) { usymtab_replaceEntryAux (utab, s); } -# endif bool usymtab_matchForwardStruct (usymId u1, usymId u2) @@ -5561,7 +5626,7 @@ usymtab_displayAllUses () usymtab_entries (copy, ue) { - if (uentry_isValid (ue)) + if (uentry_isValid (ue) && !uentry_isGlobalMarker (ue)) { filelocList uses = uentry_getUses (ue); int size = filelocList_realSize (uses); @@ -5653,6 +5718,7 @@ void usymtab_addMustAlias (/*@exposed@*/ sRef s, /*@exposed@*/ sRef al) void usymtab_addForceMustAlias (/*@exposed@*/ sRef s, /*@exposed@*/ sRef al) /*@modifies utab@*/ { + /* evans 2002-03-3: was sRef_isMeaningful -- but we need to keep aliases for new storage also! */ if (sRef_isMeaningful (s) && sRef_isMeaningful (al) && !(sRef_isConst (s) || sRef_isConst (al)) @@ -5672,10 +5738,17 @@ void usymtab_addForceMustAlias (/*@exposed@*/ sRef s, /*@exposed@*/ sRef al) } else { - ; + DPRINTF (("Not aliasing! %s / %s", sRef_unparseFull (s), sRef_unparseFull (al))); + DPRINTF (("meaningful: %d %d", sRef_isMeaningful (s), sRef_isMeaningful (al))); } } +void usymtab_addReallyForceMustAlias (/*@exposed@*/ sRef s, /*@exposed@*/ sRef al) + /*@modifies utab@*/ +{ + utab->aliases = aliasTable_addMustAlias (utab->aliases, s, al); +} + void usymtab_clearAlias (sRef s) /*@modifies utab, s@*/ { @@ -5686,7 +5759,7 @@ void usymtab_clearAlias (sRef s) sRefSet usymtab_allAliases (sRef s) /*@globals utab@*/ { - if (sRef_isMeaningful (s)) + if (sRef_isSomewhatMeaningful (s)) { sRefSet ret; @@ -5704,7 +5777,7 @@ sRefSet usymtab_allAliases (sRef s) /*@only@*/ sRefSet usymtab_canAlias (sRef s) /*@globals utab@*/ { - if (sRef_isMeaningful (s)) + if (sRef_isSomewhatMeaningful (s)) { sRefSet res = aliasTable_canAlias (utab->aliases, s); return res; @@ -5741,7 +5814,7 @@ usymtab_printOut (void) int depth = 0; char *ind = mstring_copy (" "); - fprintf (g_msgstream, "<<< [symbol table] >>>\n"); + fprintf (g_warningstream, "<<< [symbol table] >>>\n"); while (s != GLOBAL_ENV && s->env != GLOBAL_ENV) { @@ -5752,7 +5825,7 @@ usymtab_printOut (void) ind[depth * 3 + 1] = '\0'; } - fprintf (g_msgstream, "level: %d (%s)\n", s->lexlevel, + fprintf (g_warningstream, "level: %d (%s)\n", s->lexlevel, cstring_toCharsSafe (tname)); cstring_free (tname); @@ -5760,17 +5833,17 @@ usymtab_printOut (void) for (i = 0; i < s->nentries; i++) { cstring us = uentry_unparseFull (s->entries[i]); - fprintf (g_msgstream, "%s\n", cstring_toCharsSafe (us)); + fprintf (g_warningstream, "%s\n", cstring_toCharsSafe (us)); cstring_free (us); } if (s->reftable != NULL && s->nentries > 0) { - fprintf (g_msgstream, "\t<< Ref table >>\n"); + fprintf (g_warningstream, "\t<< Ref table >>\n"); for (i = 0; i < s->nentries; i++) { - fprintf (g_msgstream, "\t%s %3d: %d, %d\n", ind, i, + fprintf (g_warningstream, "\t%s %3d: %d, %d\n", ind, i, s->reftable[i]->level, s->reftable[i]->index); } @@ -5780,7 +5853,7 @@ usymtab_printOut (void) depth++; s = s->env; } - fprintf (g_msgstream, "<<< end usymtab >>>\n"); + fprintf (g_warningstream, "<<< end usymtab >>>\n"); mstring_free (ind); return; } @@ -5801,7 +5874,7 @@ usymtab_printAll (void) static void usymtab_printAllAux (usymtab s) - /*@modifies g_msgstream@*/ + /*@modifies g_warningstream@*/ { int i; int depth = 0; @@ -5877,7 +5950,7 @@ usymtab_printComplete () for (i = looplow; i < s->nentries; i++) { printf ("%s%3d %s\n", ind, i, - cstring_toCharsSafe (uentry_unparse (s->entries[i]))); + cstring_toCharsSafe (uentry_unparseFull (s->entries[i]))); } } else @@ -5886,7 +5959,7 @@ usymtab_printComplete () for (i = 0; i < s->nentries; i++) { printf ("%s%3d %s\n", ind, i, - cstring_toCharsSafe (uentry_unparse (s->entries[i]))); + cstring_toCharsSafe (uentry_unparseFull (s->entries[i]))); } } @@ -5977,9 +6050,9 @@ usymtab_printLocal (void) static bool checkDistinctExternalName (uentry e) /*@globals globtab@*/ - /*@modifies *g_msgstream@*/ + /*@modifies *g_warningstream@*/ { - int checklen = context_getValue (FLG_EXTERNALNAMELEN); + size_t checklen = size_fromInt (context_getValue (FLG_EXTERNALNAMELEN)); bool ignorecase = context_getFlag (FLG_EXTERNALNAMECASEINSENSITIVE); bool gotone = FALSE; bool extras = FALSE; @@ -6054,7 +6127,7 @@ static bool checkDistinctExternalName (uentry e) "in the first %d characters (%q)", uentry_getName (e), uentry_getName (oe), - checklen, + size_toInt (checklen), cstring_clip (uentry_getName (e), checklen)), /*@=sefparams@*/ uentry_whereLast (e))) @@ -6080,7 +6153,7 @@ static bool checkDistinctExternalName (uentry e) "is ignored", uentry_getName (e), uentry_getName (oe), - checklen), + size_toInt (checklen)), uentry_whereLast (e))) { uentry_showWhereAny (oe); @@ -6106,7 +6179,7 @@ static bool checkDistinctExternalName (uentry e) "in the first %d characters (%q)", uentry_getName (e), uentry_getName (oe), - checklen, + size_toInt (checklen), cstring_clip (uentry_getName (e), checklen)), /*@=sefparams@*/ uentry_whereLast (e))) @@ -6138,11 +6211,11 @@ static bool checkDistinctExternalName (uentry e) static bool checkDistinctInternalName (uentry e) /*@globals utab@*/ - /*@modifies *g_msgstream@*/ + /*@modifies *g_warningstream@*/ { usymtab ttab = utab; cstring name = uentry_rawName (e); - int numchars = context_getValue (FLG_INTERNALNAMELEN); + size_t numchars = size_fromInt (context_getValue (FLG_INTERNALNAMELEN)); bool caseinsensitive = context_getFlag (FLG_INTERNALNAMECASEINSENSITIVE); bool lookalike = context_getFlag (FLG_INTERNALNAMELOOKALIKE); @@ -6182,7 +6255,7 @@ static bool checkDistinctInternalName (uentry e) "in the first %d characters (%q)", uentry_getName (e), uentry_getName (oe), - numchars, + size_toInt (numchars), cstring_clip (uentry_getName (e), numchars)), /*@=sefparams@*/ uentry_whereLast (e))) @@ -6195,8 +6268,7 @@ static bool checkDistinctInternalName (uentry e) /*@switchbreak@*/ break; case CGE_CASE: - if (numchars == 0 - || (cstring_length (name) <= numchars)) + if (numchars == 0 || (cstring_length (name) <= numchars)) { if (optgenerror (FLG_DISTINCTINTERNALNAMES, @@ -6221,7 +6293,7 @@ static bool checkDistinctInternalName (uentry e) "in the first %d characters without case sensitivity", uentry_getName (e), uentry_getName (oe), - numchars), + size_toInt (numchars)), uentry_whereLast (e))) { uentry_showWhereAny (oe); @@ -6258,7 +6330,7 @@ static bool checkDistinctInternalName (uentry e) "in the first %d characters except by lookalike characters", uentry_getName (e), uentry_getName (oe), - numchars), + size_toInt (numchars)), uentry_whereLast (e))) { uentry_showWhereAny (oe); @@ -6313,3 +6385,36 @@ void usymtab_checkDistinctName (uentry e, int scope) return uentry_getSref (ue); } + +# ifdef DEBUGSPLINT +/* +** For debugging only +*/ + +void +usymtab_checkAllValid () /*@globals utab@*/ +{ + usymtab tab = utab; + + while (tab != GLOBAL_ENV) + { + int i; + + for (i = 0; i < utab->nentries; i++) + { + uentry e = utab->entries[i]; + + uentry_checkValid (e); + } + + aliasTable_checkValid (tab->aliases); + tab = tab->env; + } +} +# endif + + + + + +