Unable to access fields of a record type in some cases
Richard Biener
richard.guenther@gmail.com
Mon Sep 19 08:09:00 GMT 2016
On Mon, Sep 19, 2016 at 3:52 AM, Swati Rathi <swatirathi@cse.iitb.ac.in> wrote:
> Hello,
>
> We want to fetch fields of a record type from the formal arguments of a
> function.
> For a RECORD_TYPE, we fetch the fields using TYPE_FIELDS.
>
> In the program 471.omnetpp (from the SPEC CPU2006 benchmark suite), we
> encountered a case where we were not able to access the fields. Below is the
> dump of the same record type showing different output in different
> functions. We are not able to access fields of the record type for the first
> case.
>
> Can you tell us the reason for different type nodes?
The first is a pointer to an incomplete struct like what you'd get from
struct Foo *p;
without a definition of struct Foo.
> Also can you suggest an approach to solve our problem.
Sorry, no.
Richard.
> -------------------------------------------------------------------------------------------
> Pointer declared as "struct cMessage *" is a parameter in one function.
> Below is the dump of node "struct cMessage *".
>
> <pointer_type 0x2b8fad7baa80
> type <record_type 0x2b8fad7bab28 cMessage VOID
> align 8 symtab 0 alias set -1 canonical type 0x2b8faa800690 context
> <translation_unit_decl 0x2b8fad76e958 D.82130>
> pointer_to_this <pointer_type 0x2b8fad7baa80> chain <type_decl
> 0x2b8fad7b3730 cMessage>>
> unsigned DI
> size <integer_cst 0x2b8faa6c1ec0 type <integer_type 0x2b8faa6d20a8
> bitsizetype> constant 64>
> unit size <integer_cst 0x2b8faa6c1ee0 type <integer_type 0x2b8faa6d2000
> sizetype> constant 8>
> align 64 symtab 0 alias set -1 canonical type 0x2b8faa800e70
> pointer_to_this <pointer_type 0x2b8fad7d9000>>
>
>
> Another pointer also declared as "struct cMessage *" is a parameter in
> second function. Below is the dump of node "struct cMessage *".
>
> <pointer_type 0x2b8faa834150
> type <record_type 0x2b8faa82e1f8 cMessage addressable needs-constructing
> BLK
> size <integer_cst 0x2b8faa8186c0 constant 1408>
> unit size <integer_cst 0x2b8faa818720 constant 176>
> align 64 symtab 0 alias set -1 canonical type 0x2b8faa834c78
> fields <field_decl 0x2b8faa826850 D.2814 type <record_type
> 0x2b8faa819150 cObject>
> ignored BLK file omnet_include/cmessage.h line 84 col 15
> size <integer_cst 0x2b8faa6d4620 constant 448>
> unit size <integer_cst 0x2b8faa7f0620 constant 56>
> align 64 offset_align 128
> offset <integer_cst 0x2b8faa6c1f00 constant 0>
> bit offset <integer_cst 0x2b8faa6c1f60 constant 0> context
> <record_type 0x2b8faa82e1f8 cMessage> chain <field_decl 0x2b8faa8268e8
> swati_test>> context <translation_unit_decl 0x2b8faa6dcf18 D.2350>
> pointer_to_this <pointer_type 0x2b8faa82e2a0> reference_to_this
> <reference_type 0x2b8fab219c78> chain <type_decl 0x2b8faa82b678 cMessage>>
> public unsigned DI
> size <integer_cst 0x2b8faa6c1ec0 type <integer_type 0x2b8faa6d20a8
> bitsizetype> constant 64>
> unit size <integer_cst 0x2b8faa6c1ee0 type <integer_type 0x2b8faa6d2000
> sizetype> constant 8>
> align 64 symtab 0 alias set -1 canonical type 0x2b8faa800e70
> pointer_to_this <pointer_type 0x2b8faa8a3d20>>
>
> -------------------------------------------------------------------------------------------
>
> Thank you.
>
> Regards,
> Swati
More information about the Gcc
mailing list