X-Git-Url: http://andersk.mit.edu/gitweb/splint.git/blobdiff_plain/288cbc5cbbbb68f1c95fd491c667d34e162f7863..2e4caa51b7f68083f8e80e59475eb5d045ffd91e:/src/uentry.c diff --git a/src/uentry.c b/src/uentry.c index 05abe0a..0f5fb17 100644 --- a/src/uentry.c +++ b/src/uentry.c @@ -1,6 +1,6 @@ /* ** Splint - annotation-assisted static program checker -** Copyright (C) 1994-2002 University of Virginia, +** Copyright (C) 1994-2003 University of Virginia, ** Massachusetts Institute of Technology ** ** This program is free software; you can redistribute it and/or modify it @@ -66,10 +66,8 @@ static void checkVarConformance (/*@notnull@*/ uentry p_old, bool p_mustConform, bool p_completeConform) /*@modifies p_old, p_unew@*/; -# ifndef NOLCL static void uentry_setHasMods (uentry p_ue) /*@modifies p_ue@*/; static void uentry_setHasGlobs (uentry p_ue) /*@modifies p_ue@*/; -# endif static void uentry_reallyFree (/*@notnull@*/ /*@only@*/ uentry p_e); @@ -687,7 +685,6 @@ static void uentry_setConstantValue (uentry ue, /*@only@*/ multiVal val) return ue; } -# ifndef NOLCL /*@notnull@*/ uentry uentry_makeSpecEnumConstant (cstring n, ctype t, fileloc loc) { uentry ue = uentry_makeConstant (n, t, loc); @@ -695,7 +692,6 @@ static void uentry_setConstantValue (uentry ue, /*@only@*/ multiVal val) ue->ukind = KENUMCONST; return ue; } -# endif /*@notnull@*/ uentry uentry_makeVariableLoc (cstring n, ctype t) { @@ -716,11 +712,12 @@ bool uentry_isUnnamedVariable (uentry ue) { ctype ct = idDecl_getCtype (id); uentry ue = uentry_makeDatatype (idDecl_observeId (id), ct, - MAYBE, MAYBE, setLocation ()); + MAYBE, qual_createUnknown (), + setLocation ()); uentry_reflectQualifiers (ue, idDecl_getQuals (id)); - if (!ynm_isOn (ue->info->datatype->abs)) + if (!qual_isEitherAbstract (ue->info->datatype->abs)) { if (ctype_isUnknown (ct)) { @@ -744,9 +741,12 @@ void uentry_checkParams (uentry ue) if (uentry_isRealFunction (ue)) { uentryList params = uentry_getParams (ue); + int paramno = 0; uentryList_elements (params, current) { + paramno++; + if (uentry_isValid (current)) { ctype ct = current->utype; @@ -760,24 +760,48 @@ void uentry_checkParams (uentry ue) } else { - voptgenerror - (FLG_FIXEDFORMALARRAY, - message ("Function parameter %q declared as " - "manifest array (size constant is meaningless)", - uentry_getName (current)), - uentry_whereDeclared (current)); + if (uentry_hasName (current)) + { + voptgenerror + (FLG_FIXEDFORMALARRAY, + message ("Function parameter %q declared as " + "manifest array (size constant is meaningless)", + uentry_getName (current)), + uentry_whereDeclared (current)); + } + else + { + voptgenerror + (FLG_FIXEDFORMALARRAY, + message ("Unnamed function parameter %d declared as " + "manifest array (size constant is meaningless)", + paramno), + uentry_whereDeclared (current)); + } } } else { if (ctype_isArray (ct)) { - voptgenerror - (FLG_FORMALARRAY, - message ("Function parameter %q declared as " - "array (treated as pointer)", - uentry_getName (current)), - uentry_whereDeclared (current)); + if (uentry_hasName (current)) + { + voptgenerror + (FLG_FORMALARRAY, + message ("Function parameter %q declared as " + "array (treated as pointer)", + uentry_getName (current)), + uentry_whereDeclared (current)); + } + else + { + voptgenerror + (FLG_FORMALARRAY, + message ("Unnamed function parameter %d declared as " + "array (treated as pointer)", + paramno), + uentry_whereDeclared (current)); + } } } @@ -1034,14 +1058,18 @@ static void uentry_reflectClauses (uentry ue, functionClauseList clauses) if (uentry_hasGlobs (ue)) { - voptgenerror + vgenhinterror (FLG_SYNTAX, message ("Multiple globals clauses for %q: %q", uentry_getName (ue), globalsClause_unparse (glc)), + cstring_makeLiteral ("Only one globals clause may be used. The second globals clause is ignored."), globalsClause_getLoc (glc)); - uentry_setGlobals (ue, globalsClause_takeGlobs (glc)); /*@i32@*/ + + /* + uentry_setGlobals (ue, globalsClause_takeGlobs (glc)); + */ } else { @@ -1309,7 +1337,6 @@ uentry_makeVariableParamAux (cstring n, ctype t, /*@dependent@*/ sRef s, return (e); } -# ifndef NOLCL void uentry_setRefCounted (uentry e) { @@ -1319,7 +1346,6 @@ uentry_setRefCounted (uentry e) sRef_storeState (e->sref); } } -# endif void uentry_setStatic (uentry c) @@ -1625,6 +1651,7 @@ uentry_setPreconditions (uentry ue, /*@only@*/ functionConstraint preconditions) if (functionConstraint_isDefined (ue->info->fcn->preconditions)) { + /*drl oops this date is wronge...*/ /* drl 11-29-2002 I changed this so it didn't appear as a Splint bug among other things this gets triggered when there is @@ -2320,6 +2347,7 @@ uentry_reflectOtherQualifier (/*@notnull@*/ uentry ue, qual qel) uentry_setNullState (ue, NS_MNOTNULL); } else if (qual_isAbstract (qel) + || qual_isNumAbstract (qel) || qual_isConcrete (qel)) { if (!uentry_isDatatype (ue)) @@ -2332,7 +2360,9 @@ uentry_reflectOtherQualifier (/*@notnull@*/ uentry ue, qual qel) } else { - ue->info->datatype->abs = ynm_fromBool (qual_isAbstract (qel)); + ue->info->datatype->abs = qel; + DPRINTF (("Setting abstract %s: %s", + uentry_unparse (ue), qual_unparse (qel))); } } else if (qual_isMutable (qel)) @@ -3042,7 +3072,7 @@ uentry_isSpecialFunction (uentry ue) ctype ct = idDecl_getCtype (t); ctype base = ct; fileloc loc = setLocation (); - sRef pref = sRef_makeParam (i, ct, stateInfo_makeLoc (loc)); + sRef pref = sRef_makeParam (i, ct, stateInfo_makeLoc (loc, SA_CREATED)); uentry ue = uentry_makeVariableSrefParam (idDecl_observeId (t), ct, loc, pref); DPRINTF (("Make param: %s", uentry_unparseFull (ue))); @@ -3103,12 +3133,10 @@ uentry_isSpecialFunction (uentry ue) } } -# ifndef NOLCL /*@notnull@*/ uentry uentry_makeVariableParam (cstring n, ctype t, fileloc loc) { return (uentry_makeVariableParamAux (n, t, sRef_makeType (t), fileloc_copy (loc), SS_DEFINED)); } -# endif /* ** constants @@ -3592,36 +3620,24 @@ void uentry_makeConstantFunction (uentry ue) } void -uentry_setGlobals (uentry ue, /*@owned@*/ globSet globs) +uentry_setGlobals (uentry ue, /*@only@*/ globSet globs) { llassert (uentry_isValid (ue)); + globSet_markImmutable (globs); + if (uentry_isIter (ue)) { - llassert (globSet_isUndefined (ue->info->iter->globs)); - ue->info->iter->globs = globs; + ue->info->iter->globs = globSet_unionFree (ue->info->iter->globs, globs); } else { uentry_convertVarFunction (ue); - llassert (uentry_isFunction (ue)); - llassert (!ue->info->fcn->hasGlobs - && globSet_isUndefined (ue->info->fcn->globs)); - - ue->info->fcn->hasGlobs = TRUE; - globSet_markImmutable (globs); - /*@-mustfree@*/ ue->info->fcn->globs = globs; - /*@=mustfree@*/ - } - /*@i23*/ - /* ??? - evans 2001-09-09 not sure what's going on here...? - if (globSet_hasStatic (globs)) - { - context_recordFileGlobals (globs); + ue->info->fcn->hasGlobs = TRUE; + ue->info->fcn->globs = globSet_unionFree (ue->info->fcn->globs, globs); } - */ if (context_getFlag (FLG_GLOBALSIMPMODIFIESNOTHING)) { @@ -3669,7 +3685,6 @@ void uentry_addAccessType (uentry ue, typeId tid) FALSE, FALSE)); } -# ifndef NOLCL /*@notnull@*/ uentry uentry_makePrivFunction2 (cstring n, ctype t, typeIdSet access, @@ -3698,7 +3713,6 @@ void uentry_addAccessType (uentry ue, typeId tid) reflectImplicitFunctionQualifiers (ue, TRUE); return (ue); } -# endif uentry uentry_makeExpandedMacro (cstring s, fileloc f) { @@ -3737,7 +3751,6 @@ bool uentry_isForward (uentry e) return FALSE; } -# ifndef NOLCL /*@notnull@*/ uentry uentry_makeTypeListFunction (cstring n, typeIdSet access, fileloc f) { @@ -3758,7 +3771,6 @@ uentry_makeUnspecFunction (cstring n, ctype t, reflectImplicitFunctionQualifiers (ue, TRUE); return ue; } -# endif /* ** datatypes @@ -3767,7 +3779,7 @@ uentry_makeUnspecFunction (cstring n, ctype t, /* is exported for use by usymtab_interface */ /*@notnull@*/ uentry - uentry_makeDatatypeAux (cstring n, ctype t, ynm mut, ynm abstract, + uentry_makeDatatypeAux (cstring n, ctype t, ynm mut, qual abstract, fileloc f, bool priv) { uentry e = uentry_alloc (); @@ -3808,7 +3820,7 @@ uentry_makeUnspecFunction (cstring n, ctype t, uentry_setDefined (e, f); } - if (ynm_isOn (abstract) && !(uentry_isCodeDefined (e))) + if (qual_isAbstract (abstract) && !(uentry_isCodeDefined (e))) { sRef_setNullState (e->sref, NS_ABSNULL, uentry_whereDeclared (e)); } @@ -3817,12 +3829,12 @@ uentry_makeUnspecFunction (cstring n, ctype t, } /*@notnull@*/ uentry - uentry_makeDatatype (cstring n, ctype t, ynm mut, ynm abstract, fileloc f) + uentry_makeDatatype (cstring n, ctype t, ynm mut, qual abstract, fileloc f) { return (uentry_makeDatatypeAux (n, t, mut, abstract, f, FALSE)); } -/*@notnull@*/ uentry uentry_makeBoolDatatype (ynm abstract) +/*@notnull@*/ uentry uentry_makeBoolDatatype (qual abstract) { uentry ret = uentry_makeDatatypeAux (context_getBoolName (), ctype_bool, NO, abstract, @@ -3943,7 +3955,7 @@ static /*@only@*/ /*@notnull@*/ uentry e->info = (uinfo) dmalloc (sizeof (*e->info)); e->info->datatype = (udinfo) dmalloc (sizeof (*e->info->datatype)); - e->info->datatype->abs = NO; + e->info->datatype->abs = qual_createUnknown (); e->info->datatype->mut = (kind == KENUMTAG) ? NO : MAYBE; e->info->datatype->type = t; e->warn = warnClause_undefined; /*@i452@*/ @@ -3985,7 +3997,6 @@ uentry_makeUnionTag (cstring n, ctype t, fileloc loc) return (ret); } -# ifndef NOLCL uentry uentry_makeEnumTag (cstring n, ctype t, fileloc loc) { @@ -3995,7 +4006,6 @@ uentry_makeEnumTag (cstring n, ctype t, fileloc loc) cstring_free (ename); return ret; } -# endif uentry uentry_makeUnionTagLoc (cstring n, ctype t) @@ -4231,7 +4241,7 @@ uentry_compare (uentry u1, uentry u2) u2->info->datatype->type)); COMPARERETURN (ynm_compare (u1->info->datatype->mut, u2->info->datatype->mut)); - return (ynm_compare (u1->info->datatype->abs, u2->info->datatype->abs)); + return (generic_compare (u1->info->datatype->abs, u2->info->datatype->abs)); } BADEXIT; @@ -4374,7 +4384,7 @@ static /*@only@*/ uentry } static /*@only@*/ uentry -uentry_makeDatatypeBase (/*@only@*/ cstring name, ctype ct, ynm abstract, +uentry_makeDatatypeBase (/*@only@*/ cstring name, ctype ct, qual abstract, ynm mut, ctype rtype, alkind ak, exkind exp, sstate defstate, nstate isnull, /*@only@*/ fileloc loc) @@ -4412,7 +4422,7 @@ uentry_makeDatatypeBase (/*@only@*/ cstring name, ctype ct, ynm abstract, sRef_setDefState (e->sref, defstate, loc); - if (ynm_isOn (abstract) && ctype_isUnknown (ct) && isnull == NS_UNKNOWN) + if (qual_isEitherAbstract (abstract) && ctype_isUnknown (ct) && isnull == NS_UNKNOWN) { isnull = NS_ABSNULL; } @@ -4455,7 +4465,6 @@ uentry_makeDatatypeBase (/*@only@*/ cstring name, ctype ct, ynm abstract, return (e); } -# ifndef NOLCL static void uentry_setHasGlobs (uentry ue) { llassert (uentry_isFunction (ue)); @@ -4469,7 +4478,6 @@ static void uentry_setHasMods (uentry ue) ue->info->fcn->hasMods = TRUE; } -# endif bool uentry_hasGlobs (uentry ue) { @@ -4649,7 +4657,7 @@ static /*@only@*/ uentry e->info = (uinfo) dmalloc (sizeof (*e->info)); e->info->datatype = (udinfo) dmalloc (sizeof (*e->info->datatype)); - e->info->datatype->abs = NO; + e->info->datatype->abs = qual_createUnknown (); e->info->datatype->mut = MAYBE; e->info->datatype->type = rtype; @@ -4846,7 +4854,7 @@ uentry_undump (ekind kind, fileloc loc, char **s) break; case KDATATYPE: { - ynm abstract; + qual abstract; ynm mut; ctype rtype; sstate defstate; @@ -4854,7 +4862,7 @@ uentry_undump (ekind kind, fileloc loc, char **s) alkind aliased; exkind exp; - advanceField (s); abstract = ynm_fromCodeChar (reader_loadChar (s)); + advanceField (s); abstract = qual_abstractFromCodeChar (reader_loadChar (s)); advanceField (s); mut = ynm_fromCodeChar (reader_loadChar (s)); advanceField (s); defstate = sstate_fromInt (reader_getInt (s)); advanceField (s); isnull = nstate_fromInt (reader_getInt (s)); @@ -5123,7 +5131,7 @@ uentry_dumpAux (uentry v, bool isParam) else { sdump = message ("%d@%d@%d@%d@%d", - (int) dss, + (int) dss, (int) nst, (int) alk, (int) exk, @@ -5156,9 +5164,9 @@ uentry_dumpAux (uentry v, bool isParam) ctype_unparse (v->utype), (int) v->utype)); */ - return (message ("%q@%s@%s@%d@%d@%d@%d@%q#%s", + return (message ("%q@%c@%s@%d@%d@%d@%d@%q#%s", ctype_dump (v->utype), - ynm_unparseCode (v->info->datatype->abs), + qual_abstractCode (v->info->datatype->abs), ynm_unparseCode (v->info->datatype->mut), (int) sRef_getDefState (v->sref), (int) sRef_getNullState (v->sref), @@ -5327,8 +5335,8 @@ uentry_unparseFull (uentry v) { cstring res; - res = message ("[%w] %s %s: %s [spec: %q; decl: %q; def: %q]", - (unsigned long) v, ekind_unparse (v->ukind), v->uname, + res = message ("[%p] %s %s: %s [spec: %q; decl: %q; def: %q]", + v, ekind_unparse (v->ukind), v->uname, ctype_unparse (v->utype), fileloc_unparse (uentry_whereSpecified (v)), fileloc_unparse (uentry_whereDeclared (v)), @@ -5344,7 +5352,7 @@ uentry_unparseFull (uentry v) (ctype_isDefined (v->info->datatype->type) ? v->info->datatype->type : ctype_unknown), ynm_unparse (v->info->datatype->mut), - ynm_unparse (v->info->datatype->abs), + qual_unparse (v->info->datatype->abs), sRef_unparseState (v->sref)); } else if (uentry_isFunction (v)) @@ -5484,10 +5492,10 @@ uentry_setAbstract (uentry e) typeId oldid; llassert (uentry_isDatatype (e) - && (ynm_isMaybe (e->info->datatype->abs))); + && (qual_isUnknown (e->info->datatype->abs))); oldid = ctype_typeId (e->info->datatype->type); - e->info->datatype->abs = YES; + e->info->datatype->abs = qual_createAbstract (); e->info->datatype->type = ctype_createAbstract (oldid); } @@ -5495,23 +5503,24 @@ void uentry_setConcrete (uentry e) { llassert (uentry_isDatatype (e) - && (ynm_isMaybe (e->info->datatype->abs))); + && (qual_isUnknown (e->info->datatype->abs) + || qual_isConcrete (e->info->datatype->abs))); - e->info->datatype->abs = NO; + e->info->datatype->abs = qual_createConcrete (); } bool uentry_isAbstractDatatype (uentry e) { return (uentry_isDatatype (e) - && (ynm_isOn (e->info->datatype->abs))); + && (qual_isEitherAbstract (e->info->datatype->abs))); } bool uentry_isMaybeAbstract (uentry e) { return (uentry_isDatatype (e) - && (ynm_isMaybe (e->info->datatype->abs))); + && (!qual_isConcrete (e->info->datatype->abs))); } bool @@ -5727,27 +5736,35 @@ uentry_getGlobs (uentry l) return globSet_undefined; } - if (l->ukind != KFCN) + if (uentry_isFunction (l)) + { + return l->info->fcn->globs; + } + else if (uentry_isIter (l)) + { + return l->info->iter->globs; + } + else if (uentry_isEndIter (l)) + { + return globSet_undefined; + } + else { - if (l->ukind != KITER && l->ukind != KENDITER) + if (l->ukind == KVAR) { - if (l->ukind == KVAR) - { - llbug (message ("Bad call to uentry_getGlobs (var): %q (%s)", + llcontbug (message ("Bad call to uentry_getGlobs (var): %q (%s)", uentry_unparse (l), ekind_unparse (l->ukind))); - } - else - { - llbug (message ("Bad call to uentry_getGlobs: %q (%s)", + } + else + { + llcontbug (message ("Bad call to uentry_getGlobs: %q (%s)", uentry_unparse (l), ekind_unparse (l->ukind))); - } } + return globSet_undefined; } - - return l->info->fcn->globs; } /*@observer@*/ sRefSet @@ -5761,9 +5778,32 @@ uentry_getMods (uentry l) return sRefSet_undefined; } - return l->info->fcn->mods; + if (uentry_isFunction (l)) + { + return l->info->fcn->mods; + } + else if (uentry_isIter (l)) + { + return l->info->iter->mods; + } + else if (uentry_isEndIter (l)) + { + return sRefSet_undefined; + } + else + { + BADBRANCH; + } +# ifdef WIN32 +/* Make Microsoft VC++ happy */ +# pragma warning (disable:4715) +# endif } +# ifdef WIN32 +# pragma warning (enable:4715) +# endif + ekind uentry_getKind (uentry e) { @@ -5803,7 +5843,13 @@ uentry_getParams (uentry l) { ctype ct = l->utype; - llassert (ctype_isFunction (ct)); + /*drl 12/10/2002 changed to fix bug involving multiple redefines of library functions in macros. Bug was reported by Malcolm Parsons + + Old code was simplly llassert (ctype_isFunction (ct) ); + */ + + llassert (ctype_isFunction (ct) || context_inMacro() ); + return (ctype_argsFunction (ct)); } BADDEFAULT; @@ -6548,7 +6594,15 @@ uentry_setDatatype (uentry e, usymId uid) if (uentry_isAbstractType (e)) { - e->info->datatype->type = ctype_createAbstract (uid); + if (qual_isNumAbstract (e->info->datatype->abs)) + { + e->info->datatype->type = ctype_createNumAbstract (uid); + } + else + { + llassert (qual_isAbstract (e->info->datatype->abs)); + e->info->datatype->type = ctype_createAbstract (uid); + } } else { @@ -6782,7 +6836,7 @@ uentry_reallyFree (/*@notnull@*/ /*@only@*/ uentry e) nuentries--; sfree (e); - } +} extern void uentry_markOwned (/*@owned@*/ uentry u) { @@ -6824,7 +6878,7 @@ KindConformanceError (/*@unique@*/ uentry old, uentry unew, bool mustConform) llassert (uentry_isValid (old)); llassert (uentry_isValid (unew)); - if (uentry_isEitherConstant (unew) + if ((uentry_isEitherConstant (unew) || uentry_isDatatype (unew)) && (fileloc_isPreproc (uentry_whereDeclared (old)) || ctype_isUnknown (old->utype)) && !uentry_isSpecified (old)) @@ -7296,9 +7350,10 @@ checkEnumConformance (/*@notnull@*/ uentry old, /*@notnull@*/ uentry unew) if (optgenerror (FLG_MATCHFIELDS, message ("Enum %q declared with members { %q } but " - "specified with members { %q }", + "%s with members { %q }", uentry_getName (old), enumNameList_unparse (enew), + uentry_specOrDefName (old), enumNameList_unparse (eold)), uentry_whereDeclared (unew))) { @@ -8834,10 +8889,10 @@ uentry_checkDatatypeConformance (/*@notnull@*/ uentry old, } } - if (unew->info->datatype->abs != MAYBE) + if (!qual_isUnknown (unew->info->datatype->abs)) { - if (ynm_isOff (old->info->datatype->abs) - && ynm_isOn (unew->info->datatype->abs)) + if (qual_isConcrete (old->info->datatype->abs) + && qual_isEitherAbstract (unew->info->datatype->abs)) { if (!ctype_isDirectBool (old->utype)) { @@ -8853,8 +8908,8 @@ uentry_checkDatatypeConformance (/*@notnull@*/ uentry old, } } } - else if (ynm_isOn (old->info->datatype->abs) - && ynm_isOff (unew->info->datatype->abs)) + else if (qual_isEitherAbstract (old->info->datatype->abs) + && qual_isConcrete (unew->info->datatype->abs)) { if (!ctype_isDirectBool (old->utype)) { @@ -8877,7 +8932,7 @@ uentry_checkDatatypeConformance (/*@notnull@*/ uentry old, } else { - if (ynm_isOn (old->info->datatype->abs)) + if (qual_isEitherAbstract (old->info->datatype->abs)) { old->sref = unew->sref; unew->info->datatype->mut = old->info->datatype->mut; @@ -8926,7 +8981,7 @@ uentry_checkDatatypeConformance (/*@notnull@*/ uentry old, } else { - if (ynm_isOn (old->info->datatype->abs)) + if (qual_isEitherAbstract (old->info->datatype->abs)) { if (ynm_isOn (old->info->datatype->mut) && ynm_isOff (unew->info->datatype->mut)) { @@ -9884,10 +9939,10 @@ static void uentry_updateInto (/*@unique@*/ uentry unew, uentry old) unew->info = uinfo_copy (old->info, old->ukind); } - -uentry -uentry_copy (uentry e) +static uentry +uentry_copyAux (uentry e, bool saveCopy) { + if (uentry_isValid (e)) { uentry enew = uentry_alloc (); @@ -9900,7 +9955,15 @@ uentry_copy (uentry e) enew->whereDefined = fileloc_copy (e->whereDefined); enew->whereDeclared = fileloc_copy (e->whereDeclared); - enew->sref = sRef_saveCopy (e->sref); /* Memory leak! */ + if (saveCopy) + { + enew->sref = sRef_saveCopy (e->sref); /* Memory leak! */ + } + else + { + enew->sref = sRef_copy (e->sref); + } + enew->used = e->used; enew->lset = FALSE; enew->isPrivate = e->isPrivate; @@ -9923,6 +9986,18 @@ uentry_copy (uentry e) } } +uentry +uentry_copy (uentry e) +{ + return uentry_copyAux (e, TRUE); +} + +uentry +uentry_copyNoSave (uentry e) +{ + return uentry_copyAux (e, FALSE); +} + void uentry_setState (uentry res, uentry other) { @@ -9974,8 +10049,8 @@ uentry_mergeUses (uentry res, uentry other) */ static void - branchStateError (/*@notnull@*/ uentry res, /*@notnull@*/ uentry other, - bool flip, clause cl, fileloc loc) +branchStateError (/*@notnull@*/ uentry res, /*@notnull@*/ uentry other, + bool flip, clause cl, fileloc loc) { if (optgenerror (FLG_BRANCHSTATE, @@ -9985,18 +10060,43 @@ static void sRef_stateAltVerb (res->sref), clause_nameFlip (cl, !flip)), loc)) { + DPRINTF (("Here: %s / %s", sRef_unparseFull (res->sref), sRef_unparseFull (other->sref))); + if (sRef_isDead (res->sref)) { - sRef_showStateInfo (res->sref); + if (sRef_hasStateInfoLoc (res->sref)) { + llgenindentmsg (message ("%s:", clause_nameFlip (cl, flip)), loc); + sRef_showStateInfo (res->sref); + } + + if (sRef_hasStateInfoLoc (other->sref)) { + llgenindentmsg (message ("%s:", clause_nameFlip (cl, !flip)), loc); + sRef_showStateInfo (other->sref); + } } else if (sRef_isKept (res->sref)) { - sRef_showAliasInfo (res->sref); + if (sRef_hasAliasInfoLoc (res->sref)) { + llgenindentmsg (message ("%s:", clause_nameFlip (cl, flip)), loc); + sRef_showAliasInfo (res->sref); + } + + if (sRef_hasAliasInfoLoc (other->sref)) { + llgenindentmsg (message ("%s:", clause_nameFlip (cl, !flip)), loc); + sRef_showAliasInfo (other->sref); + } } else /* dependent */ { - sRef_showAliasInfo (res->sref); - sRef_showAliasInfo (other->sref); + if (sRef_hasAliasInfoLoc (res->sref)) { + llgenindentmsg (message ("%s:", clause_nameFlip (cl, flip)), loc); + sRef_showAliasInfo (res->sref); + } + + if (sRef_hasAliasInfoLoc (other->sref)) { + llgenindentmsg (message ("%s:", clause_nameFlip (cl, !flip)), loc); + sRef_showAliasInfo (other->sref); + } } sRef_setAliasKind (res->sref, AK_ERROR, fileloc_undefined); @@ -10037,11 +10137,27 @@ static void { if (sRef_isDead (other->sref)) { - sRef_showStateInfo (other->sref); + if (sRef_hasStateInfoLoc (other->sref)) { + llgenindentmsg (message ("%s:", clause_nameFlip (cl, flip)), loc); + sRef_showStateInfo (other->sref); + } + + if (sRef_hasStateInfoLoc (res->sref)) { + llgenindentmsg (message ("%s:", clause_nameFlip (cl, !flip)), loc); + sRef_showStateInfo (res->sref); + } } else /* kept */ { - sRef_showAliasInfo (other->sref); + if (sRef_hasAliasInfoLoc (other->sref)) { + llgenindentmsg (message ("%s:", clause_nameFlip (cl, flip)), loc); + sRef_showAliasInfo (other->sref); + } + + if (sRef_hasAliasInfoLoc (res->sref)) { + llgenindentmsg (message ("%s:", clause_nameFlip (cl, !flip)), loc); + sRef_showAliasInfo (res->sref); + } } sRef_setAliasKind (res->sref, AK_ERROR, fileloc_undefined); @@ -10133,7 +10249,7 @@ uentry_mergeAliasStates (/*@notnull@*/ uentry res, /*@notnull@*/ uentry other, } else { - branchStateError (res, other, flip, cl, loc); + branchStateError (res, other, !flip, cl, loc); /* evans 2002-12-15: changed flip to !flip */ } } } @@ -10822,7 +10938,7 @@ bool uentry_isReturned (uentry u) } # endif -/*@exposed@*/ sRef uentry_returnedRef (uentry u, exprNodeList args) +/*@exposed@*/ sRef uentry_returnedRef (uentry u, exprNodeList args, fileloc loc) { llassert (uentry_isRealFunction (u)); @@ -10832,7 +10948,7 @@ bool uentry_isReturned (uentry u) sRef res = sRef_makeNew (ctype_getReturnType (u->utype), u->sref, u->uname); DPRINTF (("Returned: %s", sRef_unparseFull (res))); - sRef_setAllocated (res, g_currentloc); + sRef_setAllocated (res, loc); DPRINTF (("ensures clause: %s / %s", uentry_unparse (u), stateClauseList_unparse (clauses))); @@ -10857,7 +10973,7 @@ bool uentry_isReturned (uentry u) if (modf != NULL) { sRef sr = sRef_fixBase (el, res); - modf (sr, g_currentloc); + modf (sr, loc); } } else @@ -10897,19 +11013,25 @@ bool uentry_isReturned (uentry u) usymtab_addForceMustAlias (tcref, tref); /* evans 2001-05-27 */ + if (sRef_isNew (tcref)) + { + /* tcref->kind = SK_OBJECT; */ /*!! Not new anymore */ + } + if (sRef_isDead (tcref)) { - sRef_setDefined (tcref, g_currentloc); - sRef_setOnly (tcref, g_currentloc); + sRef_setDefined (tcref, loc); + sRef_setOnly (tcref, loc); } if (sRef_isRefCounted (tcref)) { /* could be a new ref now (but only if its returned) */ - sRef_setAliasKindComplete (tcref, AK_ERROR, g_currentloc); + sRef_setAliasKindComplete (tcref, AK_ERROR, loc); } sRef_makeSafe (tcref); + DPRINTF (("Returns tcref / %s", sRef_unparseFull (tcref))); prefs = sRefSet_insert (prefs, tcref); } } @@ -10934,7 +11056,7 @@ bool uentry_isReturned (uentry u) if (nstate_isKnown (n)) { - sRef_setNullState (res, n, g_currentloc); + sRef_setNullState (res, n, loc); } } else @@ -10951,7 +11073,7 @@ bool uentry_isReturned (uentry u) if (sRef_isRefCounted (res)) { - sRef_setAliasKind (res, AK_NEWREF, g_currentloc); + sRef_setAliasKind (res, AK_NEWREF, loc); } } @@ -10962,7 +11084,7 @@ bool uentry_isReturned (uentry u) if (ctype_isAbstract (ct)) { - sRef_setNotNull (res, g_currentloc); + sRef_setNotNull (res, loc); } else { @@ -10972,18 +11094,18 @@ bool uentry_isReturned (uentry u) } else { - sRef_setNotNull (res, g_currentloc); + sRef_setNotNull (res, loc); } } } if (sRef_isRefCounted (res)) { - sRef_setAliasKind (res, AK_NEWREF, g_currentloc); + sRef_setAliasKind (res, AK_NEWREF, loc); } else if (sRef_isKillRef (res)) { - sRef_setAliasKind (res, AK_REFCOUNTED, g_currentloc); + sRef_setAliasKind (res, AK_REFCOUNTED, loc); } else { @@ -10996,11 +11118,18 @@ bool uentry_isReturned (uentry u) { sRef_setAliasKind (res, alkind_fixImplicit (ak), - g_currentloc); + loc); } sRefSet_free (prefs); - + + /* + if (sRef_isOnly (res)) + { + sRef_setFresh (res, loc); + } + */ + DPRINTF (("Returns ref: %s", sRef_unparseFull (res))); return res; } @@ -11272,7 +11401,7 @@ void uentry_checkName (uentry ue) fileloc_free (tloc); uentry_setHasNameError (ue); - if (context_getFlag (FLG_REPEATUNRECOG) || (context_inOldSytleScope() ) ) + if (context_getFlag (FLG_REPEATUNRECOG) || (context_inOldStyleScope())) { uentry_markOwned (ue); }