Comparing tree types
Vini Kanvar
vini@cse.iitb.ac.in
Sun Nov 2 21:42:00 GMT 2014
I am trying to compare the tree declarations of the lhs and the rhs of
the assignment statement in the following program.
struct node {
struct node * next;
};
struct node ** obj1, obj2;
obj1 = &obj2.next; // lhs is obj1, rhs is obj2.next
-----------
Let us call the following tree declaration of the lhs as "obj1_tree".
-------------
<var_decl 0x405cc180 obj1
type <pointer_type 0x405c5ea0
type <pointer_type 0x405c5f00 type <record_type 0x405c5f60 node>
unsigned SI
size <integer_cst 0x40511578 constant 32>
unit size <integer_cst 0x40511594 constant 4>
align 32 symtab 0 alias set -1 canonical type 0x405cc000
pointer_to_this <pointer_type 0x405c5ea0>>
unsigned SI
size <integer_cst 0x40511578 constant 32>
unit size <integer_cst 0x40511594 constant 4>
align 32 symtab 0 alias set -1 canonical type 0x405c5ea0>
used unsigned SI file structstruct2.c line 8 col 17
size <integer_cst 0x40511578 type <integer_type 0x40521060
bitsizetype> constant 32>
unit size <integer_cst 0x40511594 type <integer_type 0x40521000
sizetype> constant 4>
align 32 context <function_decl 0x405c9080 main> chain <var_decl
0x405cc1e0 obj2>>
-------------
Let us call the following tree declaration of the rhs as
"obj2.next_tree"
-------------
<field_decl 0x4051f0b8 next
type <pointer_type 0x405cc000
type <record_type 0x405c5f60 node SI
size <integer_cst 0x40511578 constant 32>
unit size <integer_cst 0x40511594 constant 4>
align 32 symtab 0 alias set -1 canonical type 0x405c5f60
fields <field_decl 0x4051f0b8 next> context <translation_unit_decl
0x40526804 D.2319>
pointer_to_this <pointer_type 0x405c5f00> chain <type_decl
0x40526870 node>>
unsigned SI
size <integer_cst 0x40511578 constant 32>
unit size <integer_cst 0x40511594 constant 4>
align 32 symtab 0 alias set -1 canonical type 0x405cc000
pointer_to_this <pointer_type 0x405cc060>>
used unsigned nonlocal SI file structstruct2.c line 3 col 16
size <integer_cst 0x40511578 type <integer_type 0x40521060
bitsizetype> constant 32>
unit size <integer_cst 0x40511594 type <integer_type 0x40521000
sizetype> constant 4>
align 32 offset_align 128
offset <integer_cst 0x405115b0 type <integer_type 0x40521000
sizetype> constant 0>
bit offset <integer_cst 0x4051163c type <integer_type 0x40521060
bitsizetype> constant 0> context <record_type 0x405c5f60 node> chain
<type_decl 0x405268dc node>>
-------------
Please note from the above tree declarations that
Type1 = TREE_TYPE (TREE_TYPE (obj1_tree)) = 0x405c5f00
Type2 = TREE_TYPE (obj2.next_tree) = 0x405cc000
Type3 = TYPE_POINTER_TO (TREE_TYPE (TREE_TYPE (obj2.next_tree))) =
0x405c5f00
I was expecting Type1 and Type2 to be equal because obj1=&obj2.next.
However, in this case, we see that Type1 and Type3 are equal. Please
explain this.
Also, what is the meaning of "pointer_to_this" in the tree declarations?
Thanks and regards,
Vini Kanvar.
More information about the Gcc
mailing list