/* Perform default promotions for C data used in expressions.
Arrays and functions are converted to pointers;
enumeral types or short or char, to int.
In addition, manifest constants symbols are replaced by their values. */
tree
default_conversion (exp)
tree exp;
{
register tree dt = TREE_TYPE (exp);
register enum tree_code form = TREE_CODE (dt);
......
if (form == ARRAY_TYPE)
{
register tree adr;
tree restype = TREE_TYPE (dt);
tree ptrtype;
if (TREE_CODE (exp) == INDIRECT_REF)
return convert (TYPE_POINTER_TO (restype),
TREE_OPERAND (exp, 0));
if (TREE_CODE (exp) == COMPOUND_EXPR)
{
tree op1 = default_conversion (TREE_OPERAND (exp, 1));
return build (COMPOUND_EXPR, TREE_TYPE (op1),
TREE_OPERAND (exp, 0), op1);
}
if (!lvalue_p (exp)
&& ! (TREE_CODE (exp) == CONSTRUCTOR && TREE_STATIC (exp)))
{
error ("invalid use of non-lvalue array");
return error_mark_node;
}
if (TREE_READONLY (exp) || TREE_THIS_VOLATILE (exp))
restype = c_build_type_variant (restype, TREE_READONLY (exp),
TREE_THIS_VOLATILE (exp));
ptrtype = build_pointer_type (restype);
......
/* This way is better for a COMPONENT_REF since it can
simplify the offset for a component. */
adr = build_unary_op (ADDR_EXPR, exp, 1);
return convert (ptrtype, adr);
}
return exp;
}
in default_conversion
<string_cst 84014
type <
array_type 94ef4
type <integer_type 825bc char permanent QI
size <integer_cst 82638 literal permanent 1
align 8 size_unit 8 sep_unit 8 symtab 0
sep <integer_cst 82608 literal permanent -128 precision 8 min <integer_cst 82608 -128>
max <integer_cst 82620 literal permanent 127
pointer_to_this <pointer_type 88a44> chain <integer_type 826a8* long int>
BLK
size <integer_cst 94f40 literal 15
align 8 size_unit 8 sep_unit 8 symtab 0 sep <integer_cst 82638 1>
domain <integer_type 94ea8 SI
size <integer_cst 8254c literal permanent 4
align 32 size_unit 8 sep_unit 32 symtab 0
sep <integer_cst 84048 literal 0 precision 32 min <integer_cst 84048 0>
max <integer_cst 84078 literal 14
static literal "Hello, world!
"
in build_pointer_type
<integer_type 825bc char permanent QI
size <integer_cst 82638 type <integer_type 82848* unsigned int> literal permanent 1
align 8 size_unit 8 sep_unit 8 symtab 0
sep <integer_cst 82608 type <integer_type 825bc* char> literal permanent -128 precision 8 min <integer_cst 82608 -128>
max <integer_cst 82620 type <integer_type 825bc* char> literal permanent 127
pointer_to_this <pointer_type 88a44> chain <integer_type 826a8* long int>
restype is
<integer_type 825bc char permanent QI
size <integer_cst 82638 type <integer_type 82848* unsigned int> literal permanent 1
align 8 size_unit 8 sep_unit 8 symtab 0
sep <integer_cst 82608 type <integer_type 825bc* char> literal permanent -128 precision 8 min <integer_cst 82608 -128>
max <integer_cst 82620 type <integer_type 825bc* char> literal permanent 127
pointer_to_this <pointer_type 88a44> chain <integer_type 826a8* long int>
ptrtype is
<
pointer_type 88a44
type <integer_type 825bc char permanent QI
size <integer_cst 82638 literal permanent 1
align 8 size_unit 8 sep_unit 8 symtab 0
sep <integer_cst 82608 literal permanent -128 precision 8 min <integer_cst 82608 -128>
max <integer_cst 82620 literal permanent 127
pointer_to_this <pointer_type 88a44> chain <integer_type 826a8* long int>
permanent unsigned SI
size <integer_cst 8254c type <integer_type 82848* unsigned int> literal permanent 4
align 32 size_unit 8 sep_unit 32 symtab 0
chain <array_type 88a90>
before build_unary_op exp is
<string_cst 84014
type <array_type 94ef4
type <integer_type 825bc char permanent QI
size <integer_cst 82638 literal permanent 1
align 8 size_unit 8 sep_unit 8 symtab 0
sep <integer_cst 82608 literal permanent -128 precision 8 min <integer_cst 82608 -128>
max <integer_cst 82620 literal permanent 127
pointer_to_this <pointer_type 88a44> chain <integer_type 826a8* long int>
BLK
size <integer_cst 94f40 literal 15
align 8 size_unit 8 sep_unit 8 symtab 0 sep <integer_cst 82638 1>
domain <integer_type 94ea8 SI
size <integer_cst 8254c literal permanent 4
align 32 size_unit 8 sep_unit 32 symtab 0
sep <integer_cst 84048 literal 0 precision 32 min <integer_cst 84048 0>
max <integer_cst 84078 literal 14
static literal "Hello, world!
"
in build_pointer_type
<array_type 94ef4
type <integer_type 825bc char permanent QI
size <integer_cst 82638 literal permanent 1
align 8 size_unit 8 sep_unit 8 symtab 0
sep <integer_cst 82608 literal permanent -128 precision 8 min <integer_cst 82608 -128>
max <integer_cst 82620 literal permanent 127
pointer_to_this <pointer_type 88a44> chain <integer_type 826a8* long int>
BLK
size <integer_cst 94f40 type <integer_type 82848* unsigned int> literal 15
align 8 size_unit 8 sep_unit 8 symtab 0 sep <integer_cst 82638 1>
domain <integer_type 94ea8 SI
size <integer_cst 8254c literal permanent 4
align 32 size_unit 8 sep_unit 32 symtab 0
sep <integer_cst 84048 literal 0 precision 32 min <integer_cst 84048 0>
max <integer_cst 84078 literal 14
after return t
<pointer_type 94f58 VOID
align 1 size_unit 1 sep_unit 0 symtab 0
<
addr_expr 840a8
type <pointer_type 94f58
type <array_type 94ef4 type <integer_type 825bc* char>
BLK
size <integer_cst 94f40 literal 15
align 8 size_unit 8 sep_unit 8 symtab 0
sep <integer_cst 82638 literal permanent 1 domain <integer_type 94ea8>
pointer_to_this <pointer_type 94f58> chain <pointer_type 94f58>
unsigned SI
size <integer_cst 8254c literal permanent 4
align 32 size_unit 8 sep_unit 32 symtab 0
literal
arg 0 <string_cst 84014 type <array_type 94ef4>
static literal "Hello, world!
"
tree
convert (type, expr)
tree type, expr;
{
register tree e = expr;
register enum tree_code code = TREE_CODE (type);
...
if (code == POINTER_TYPE)
return fold (convert_to_pointer (type, e));
... /*这里会调用convert_to_pointer ()函数*/
static tree
convert_to_pointer (type, expr)
tree type, expr;
{
register tree intype = TREE_TYPE (expr);
register enum tree_code form = TREE_CODE (intype);
...
if (form == POINTER_TYPE)
return build (NOP_EXPR, type, expr);
/*这里会建立一个NOP_EXPR类型的tree*/
<nop_expr 840c0
type <
pointer_type 88a44
type <integer_type 825bc char permanent QI
size <integer_cst 82638 literal permanent 1
align 8 size_unit 8 sep_unit 8 symtab 0
sep <integer_cst 82608 literal permanent -128 precision 8 min <integer_cst 82608 -128>
max <integer_cst 82620 literal permanent 127
pointer_to_this <pointer_type 88a44> chain <integer_type 826a8* long int>
permanent unsigned SI
size <integer_cst 8254c literal permanent 4
align 32 size_unit 8 sep_unit 32 symtab 0
chain <array_type 88a90>
literal
arg 0 <
addr_expr 840a8
type <pointer_type 94f58 type <array_type 94ef4>
unsigned SI size <integer_cst 8254c 4>
align 32 size_unit 8 sep_unit 32 symtab 0
literal
arg 0 <string_cst 84014 type <array_type 94ef4>
static literal "Hello, world!
"