Module Name: src Committed By: christos Date: Fri Oct 2 21:04:03 UTC 2009
Modified Files: src/usr.bin/xlint/lint1: decl.c externs1.h tree.c Log Message: compute sizes by the new tsize() function. To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.28 -r1.29 src/usr.bin/xlint/lint1/externs1.h cvs rdiff -u -r1.61 -r1.62 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.49 src/usr.bin/xlint/lint1/decl.c:1.50 --- src/usr.bin/xlint/lint1/decl.c:1.49 Fri Oct 2 16:45:06 2009 +++ src/usr.bin/xlint/lint1/decl.c Fri Oct 2 17:04:03 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.49 2009/10/02 20:45:06 christos Exp $ */ +/* $NetBSD: decl.c,v 1.50 2009/10/02 21:04:03 christos Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: decl.c,v 1.49 2009/10/02 20:45:06 christos Exp $"); +__RCSID("$NetBSD: decl.c,v 1.50 2009/10/02 21:04:03 christos Exp $"); #endif #include <sys/param.h> @@ -497,14 +497,16 @@ case STRUCT: sp = tp->t_str; sp->size = 0; - for (mem = sp->memb; mem != NULL; mem = mem->s_nxt) - sp->size += size(mem->s_type->t_tspec); + for (mem = sp->memb; mem != NULL; mem = mem->s_nxt) { + size_t x = (size_t)tsize(mem->s_type); + sp->size += x; + } break; case UNION: sp = tp->t_str; sp->size = 0; for (mem = sp->memb; mem != NULL; mem = mem->s_nxt) { - size_t x = size(mem->s_type->t_tspec); + size_t x = (size_t)tsize(mem->s_type); if (x > sp->size) sp->size = x; } Index: src/usr.bin/xlint/lint1/externs1.h diff -u src/usr.bin/xlint/lint1/externs1.h:1.28 src/usr.bin/xlint/lint1/externs1.h:1.29 --- src/usr.bin/xlint/lint1/externs1.h:1.28 Fri Oct 2 11:03:45 2009 +++ src/usr.bin/xlint/lint1/externs1.h Fri Oct 2 17:04:03 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: externs1.h,v 1.28 2009/10/02 15:03:45 christos Exp $ */ +/* $NetBSD: externs1.h,v 1.29 2009/10/02 21:04:03 christos Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -210,6 +210,7 @@ extern void chkmisc(tnode_t *, int, int, int, int, int, int); extern int conaddr(tnode_t *, sym_t **, ptrdiff_t *); extern strg_t *catstrg(strg_t *, strg_t *); +extern int64_t tsize(type_t *); /* * func.c Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.61 src/usr.bin/xlint/lint1/tree.c:1.62 --- src/usr.bin/xlint/lint1/tree.c:1.61 Fri Oct 2 15:02:16 2009 +++ src/usr.bin/xlint/lint1/tree.c Fri Oct 2 17:04:03 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.61 2009/10/02 19:02:16 christos Exp $ */ +/* $NetBSD: tree.c,v 1.62 2009/10/02 21:04:03 christos Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tree.c,v 1.61 2009/10/02 19:02:16 christos Exp $"); +__RCSID("$NetBSD: tree.c,v 1.62 2009/10/02 21:04:03 christos Exp $"); #endif #include <stdlib.h> @@ -3030,14 +3030,26 @@ return (getcnode(tn->tn_type, v)); } + /* * Create a constant node for sizeof. */ tnode_t * bldszof(type_t *tp) { - int elem, elsz; tspec_t st; +#if SIZEOF_IS_ULONG + st = ULONG; +#else + st = UINT; +#endif + return getinode(st, tsize(tp) / CHAR_BIT); +} + +int64_t +tsize(type_t *tp) +{ + int elem, elsz; elem = 1; while (tp->t_tspec == ARRAY) { @@ -3088,12 +3100,7 @@ break; } -#if SIZEOF_IS_ULONG - st = ULONG; -#else - st = UINT; -#endif - return (getinode(st, (int64_t)(elem * elsz / CHAR_BIT))); + return (int64_t)(elem * elsz); } /*