X-Git-Url: http://andersk.mit.edu/gitweb/splint.git/blobdiff_plain/24633cea72ce411b2bb74177c293876d8c6ce5b3..aa9c16018c05551094b01617f312d52735a8ddd9:/src/ctbase.i diff --git a/src/ctbase.i b/src/ctbase.i index 9c2fddf..5e3d374 100644 --- a/src/ctbase.i +++ b/src/ctbase.i @@ -69,7 +69,8 @@ static void cttable_grow (void); static ctype cttable_addDerived (ctkind p_ctk, /*@keep@*/ ctbase p_cnew, ctype p_base); static ctype cttable_addFull (/*@keep@*/ ctentry p_cnew); static bool ctentry_isInteresting (ctentry p_c) /*@*/; -static /*@notnull@*/ /*@only@*/ ctbase ctbase_makeFixedArray (ctype p_b, long p_size) /*@*/ ; +static /*@notnull@*/ /*@only@*/ ctbase ctbase_makeFixedArray (ctype p_b, size_t p_size) /*@*/ ; +static bool ctbase_isAnytype (/*@notnull@*/ ctbase p_b) /*@*/ ; /* ** These are file-static macros (used in ctype.c). No way to @@ -168,7 +169,7 @@ typedef struct typedef struct { ctype base; - long size; + size_t size; } *tfixed; typedef union @@ -538,7 +539,11 @@ ctbase_unparse (ctbase c) enumNameList_unparseBrief (c->contents.cenum->members))); } case CT_CONJ: - if (c->contents.conj->isExplicit || context_getFlag (FLG_SHOWALLCONJS)) + if (ctbase_isAnytype (c)) + { + return (cstring_makeLiteral ("")); + } + else if (c->contents.conj->isExplicit || context_getFlag (FLG_SHOWALLCONJS)) { if (!ctype_isSimple (c->contents.conj->a) || !ctype_isSimple (c->contents.conj->b)) @@ -609,7 +614,14 @@ static /*@only@*/ cstring case CT_UNION: return (message ("union %s { ... }", c->contents.su->name)); case CT_CONJ: - return (message ("%t", c->contents.conj->a)); + if (ctbase_isAnytype (c)) + { + return (cstring_makeLiteral ("")); + } + else + { + return (message ("%t", c->contents.conj->a)); + } BADDEFAULT; } BADEXIT; @@ -657,9 +669,16 @@ ctbase_unparseNotypes (ctbase c) case CT_ENUMLIST: return (message ("[enumlist]")); case CT_CONJ: - return (message ("%q/%q", - ctbase_unparseNotypes (ctype_getCtbase (c->contents.conj->a)), - ctbase_unparseNotypes (ctype_getCtbase (c->contents.conj->b)))); + if (ctbase_isAnytype (c)) + { + return (cstring_makeLiteral ("")); + } + else + { + return (message ("%q/%q", + ctbase_unparseNotypes (ctype_getCtbase (c->contents.conj->a)), + ctbase_unparseNotypes (ctype_getCtbase (c->contents.conj->b)))); + } BADDEFAULT; } BADEXIT; @@ -754,8 +773,12 @@ ctbase_unparseDeclaration (ctbase c, /*@only@*/ cstring name) /*@*/ enumNameList_unparseBrief (c->contents.cenum->members), name)); } - case CT_CONJ: - if (c->contents.conj->isExplicit || context_getFlag (FLG_SHOWALLCONJS)) + case CT_CONJ: + if (ctbase_isAnytype (c)) + { + return (message (" %q", name)); + } + else if (c->contents.conj->isExplicit || context_getFlag (FLG_SHOWALLCONJS)) { if (!ctype_isSimple (c->contents.conj->a) || !ctype_isSimple (c->contents.conj->b)) @@ -828,10 +851,10 @@ static ctbase ctbase_undump (d_char *c) /*@requires maxRead(*c) >= 2 @*/ case 'F': { ctype ct = ctype_undump (c); - int size; + size_t size; reader_checkChar (c, '/'); - size = reader_getInt (c); + size = size_fromInt (reader_getInt (c)); reader_checkChar (c, '|'); return (ctbase_makeFixedArray (ct, size)); } @@ -1167,13 +1190,13 @@ ctbase_expectFunction (ctype c) } static bool -ctbase_isExpectFunction (ctbase ct) /*@*/ +ctbase_isExpectFunction (/*@notnull@*/ ctbase ct) /*@*/ { return (ct->type == CT_EXPFCN); } static ctype -ctbase_getExpectFunction (ctbase ct) +ctbase_getExpectFunction (/*@notnull@*/ ctbase ct) { llassert (ctbase_isExpectFunction (ct)); return ct->contents.base; @@ -1668,7 +1691,7 @@ ctbase_makeArray (ctype b) } static /*@notnull@*/ /*@only@*/ ctbase -ctbase_makeFixedArray (ctype b, long size) +ctbase_makeFixedArray (ctype b, size_t size) { ctbase c = ctbase_new (); @@ -1839,6 +1862,23 @@ static /*@only@*/ ctbase return (c); } +static bool ctbase_isAnytype (/*@notnull@*/ ctbase b) +{ + /* + ** A unknown|dne conj is a special representation for an anytype. + */ + + if (b->type == CT_CONJ) + { + /*@access ctype@*/ + return (b->contents.conj->a == ctype_unknown + && b->contents.conj->b == ctype_dne); + /*@noaccess ctype@*/ + } + + return FALSE; +} + static ctype ctbase_getConjA (/*@notnull@*/ ctbase c) { @@ -2513,18 +2553,14 @@ ctbase_almostEqual (ctbase c1, ctbase c2) called by ctype_getArraySize */ -long int ctbase_getArraySize (ctbase ctb) +size_t ctbase_getArraySize (ctbase ctb) { - /*drl 1/25/2002 fixed discover by Jim Francis */ + /*drl 1/25/2002 fixed discovered by Jim Francis */ ctbase r; - llassert (ctbase_isDefined (ctb) ); r = ctbase_realType (ctb); llassert (ctbase_isFixedArray(r) ); - - return (r->contents.farray->size); - }