This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

tree representation of C data types


I am looking at the tree representation of data types in GCC-3.0.2.
I find the following confusing and am wondering whether it might be 
a mistake. For the following declarations:

typedef int foo;
typedef const int bar;

foo f;
bar b;

If "F" is the VAR_DECL for variable "f" then TREE_TYPE(F) is
an INTEGER_TYPE whose TYPE_NAME is a TYPE_DECL with name "foo".
This is exactly what I'd expected.
Here is the relevant snippet from a dump-translation-unit file.

@10     var_decl         name: @17      type: @18      srcp: m8.c:4      
                         chan: @19      size: @11      algn: 32      
                         used: 1       
@17     identifier_node  strg: f        lngt: 1       
@18     integer_type     name: @25      unql: @6       size: @11     
                         algn: 32       prec: 32       min : @14     
                         max : @15     
@25     type_decl        name: @30      type: @18      srcp: m8.c:1      
                         chan: @31     
@30     identifier_node  strg: foo      lngt: 3       

However, for the declaration of "b" I see something confusing.
If "B" is the VAR_DECL for variable "b" then TREE_TYPE(B) is
an INTEGER_TYPE whose TYPE_NAME is a TYPE_DECL with name "int".
I would have expected for the TYPE_DECL to have name "bar".
Here is the snippet.

@4      var_decl         name: @8       type: @9       srcp: m8.c:5      
                         chan: @10      size: @11      algn: 32      
                         used: 1       
@8      identifier_node  strg: b        lngt: 1       
@9      integer_type     qual: c        name: @13      unql: @6      
                         size: @11      algn: 32       prec: 32      
                         min : @14      max : @15     
@13     type_decl        name: @23      type: @6       srcp: <built-in>:0     
 
@23     identifier_node  strg: int      lngt: 3       

@6      integer_type     name: @13      size: @11      algn: 32      
                         prec: 32       min : @14      max : @15     

I understand that the tree representation is not wrong in the sense that 
"b" has type "const int" which is correct. It might be more consistent.
though, for "b" to have an integer type with type_decl "bar".
Am I missing something here?

Thanks for any enlightenment

	Florian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]