aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2004-10-18 16:35:54 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:03:36 -0700
commitd16c7a0d4290dcc5a033710e6a5139031c88a323 (patch)
tree53288cba1e5b76525644d33402ddd7b39bff31b6 /show-parse.c
parentMark more identifiers reserved. (diff)
downloadsparse-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.c1
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;