aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/expression.h
diff options
context:
space:
mode:
authorAlexander Viro <viro@www.linux.org.uk>2004-08-12 19:22:24 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:02:45 -0700
commitd77cf76c6941b34eb45dd08ea0aa5febbe07c700 (patch)
tree10b822e7110b1d9967eaec5d0de83c7b7d0f988d /expression.h
parent404a8fc038037d1775861b9f7c921ada7c91c7d6 (diff)
downloadsparse-dev-d77cf76c6941b34eb45dd08ea0aa5febbe07c700.tar.gz
[PATCH] handling of non-lvalue compound objects
Handling of non-lvalue compound objects: We introduce a new primitive - EXPR_SLICE. Meaning is "that many bits from that offset in that non-lvalue struct or union". It is used when we try to get a member out of a non-lvalue struct or union (subsequent .<field> just narrow the slice). And as far as scalar, struct and union fields count, that's it. The only subtle point is handling of array fields. And there I'm doing what C99 requires - they *do* decay to real, honest pointers, causing a copy of object to memory if needed. We get an anonymous object that lives until the next sequence point; optimizer is certainly free to get rid of it completely if it can make do with the value we'd copied there. Note that you _are_ allowed to say foo().a[1] = 0; It doesn't make sense, since the value you've assigned will be immediately lost (and any optimizer will turn that into f()), but it is legitimate and it avoids a *lot* of PITA in describing semantics. It covers only array decay - any other member of non-lvalue struct or union is *not* an lvalue and in struct foo {int x; int y[2];}; struct foo a(void); ... a().x = 0; /* not allowed, non-lvalue */ a().y[0] = 1; /* allowed, but pointless */ you will get an error from the first assignment, but not from the second one. Signed-off-by: Al Viro <viro@parcelfarce.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'expression.h')
-rw-r--r--expression.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/expression.h b/expression.h
index d03cdc35..4c10db8e 100644
--- a/expression.h
+++ b/expression.h
@@ -40,6 +40,7 @@ enum expression_type {
EXPR_INDEX, // index in initializer
EXPR_POS, // position in initializer
EXPR_FVALUE,
+ EXPR_SLICE,
};
struct expression {
@@ -78,6 +79,11 @@ struct expression {
struct expression *deref;
struct ident *member;
};
+ // EXPR_SLICE
+ struct /* slice */ {
+ struct expression *base;
+ unsigned r_bitpos, r_nrbits;
+ };
// EXPR_CAST and EXPR_SIZEOF
struct /* cast_arg */ {
struct symbol *cast_type;