This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Strange offsets in FIELD_DECL's...
- From: Chris Lattner <sabre at nondot dot org>
- To: gcc at gcc dot gnu dot org
- Date: Mon, 14 Apr 2003 00:01:08 -0500 (CDT)
- Subject: Strange offsets in FIELD_DECL's...
I'm trying to figure out how to calculate the offset of a field in a
RECORD_DECL. Things seem to be working, except in some simple cases:
struct Virt {
Virt();
virtual ~Virt();
int X, Y;
};
Here the structure logically has three elements in it: a VTable at offset
0, 'X' at offset 4, and 'Y' at offset 8. The problem that I'm seeing is
that both DECL_FIELD_BIT_OFFSET and DECL_FIELD_OFFSET return an
(INTEGER_CST) offset of zero for the FIELD_DECL corresponding to the X
element. The FIELD_DECL corresponding to the Y element claims that it is
at an offset of 8 bytes from the start of the structure. Thus, for the
three logical members, I'm currently getting offsets of [0, 0, 4], and
would like to get [0, 4, 8] in this case.
Are these the right macros to be getting this information with? (The
tree->rtl expansion function get_inner_reference seems to be using these
macros...). BTW, the documentation on FIELD_DECL seems to be out of date,
referring to a non-existant DECL_FIELD_BITPOS macro.
Thanks for any help!
-Chris
--
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/