diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-10-18 16:35:54 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-07 21:03:36 -0700 |
commit | d16c7a0d4290dcc5a033710e6a5139031c88a323 (patch) | |
tree | 53288cba1e5b76525644d33402ddd7b39bff31b6 /show-parse.c | |
parent | Mark more identifiers reserved. (diff) | |
download | sparse-d16c7a0d4290dcc5a033710e6a5139031c88a323.tar.gz sparse-d16c7a0d4290dcc5a033710e6a5139031c88a323.tar.bz2 sparse-d16c7a0d4290dcc5a033710e6a5139031c88a323.zip |
Add __sizeof_ptr__ that looks at a pointer expression and
returns the size of the underlying object.
This is different from "sizeof(*expr)" for arrays, where
the array would degenerate to a pointer to one member, and
thus "sizeof(*expr)" gives the size of one entry in the
array.
Why do this? It's useful for things like
#define memset(a,b,c) ({ \
(void) __builtin_warning(__sizeof_ptr__(a) > 1, __sizeof_ptr__(a) != (c), "check memset size"); \
memset(a, b, c); })
where we really want to check the size of the object we're
doing the "memset()" on, but the regular sizeof() just doesn't
cut it.
Diffstat (limited to 'show-parse.c')
-rw-r--r-- | show-parse.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/show-parse.c b/show-parse.c index 9192827..564c3e8 100644 --- a/show-parse.c +++ b/show-parse.c @@ -1024,6 +1024,7 @@ int show_expression(struct expression *expr) return show_symbol_expr(expr->symbol); case EXPR_DEREF: case EXPR_SIZEOF: + case EXPR_PTRSIZEOF: case EXPR_ALIGNOF: warning(expr->pos, "invalid expression after evaluation"); return 0; |