[GCC-XML]typedef and array in gccxml
Brad King
brad.king at kitware.com
Wed Oct 30 17:41:48 EST 2002
Alia,
> typedef unsigned char logical;
> void check_datatypes(logical alogic){};
[snip]
> <Argument name="aLogical" type="_6" />
> <FundamentalType name="unsigned char" id="_6" />
[snip]
> not exactly what I expected since I loss synonym information in my
> function.
This is an unfortunate consequence of the way GCC stores the argument
information internally. I have found no way to recover the original
typedef in all cases. There is a "DECL_ARGUMENT_AS_WRITTEN" macro in
GCC's source that is supposed to extract the original type of the argument
from a PARM_DECL (a function argument). However, this method does not
seem to work well all the time. I'm guessing that I've mis-read the
documentation, but I don't know if there is anything I can do about it.
> /for double origin[3]/
>
> gccxml falsly interprets as
>
> /<Argument name="origin" type="_129" />
> <PointerType id="_129" type="_121" />
> <FundamentalType name="double" id="_121" /> /
>
> no array information here.
Again, this is the result of GCC's internal storage of the types.
However, in this case it is correct. The C++ standard specifies in 13.1/3
that in a function argument, the outer-most array bounds are ignored and
treated instead as a pointer type. You will find that array information
is correctly reported for the inner-bounds of a multi-dimensional array
argument.
The following are equivalent. Each specifies that the argument is a
pointer to an array of 3 integers. Whether that array of 3 integers is
the first of several in an array of arrays is up to the function body.
void f(int[3][3]);
void f(int [][3]);
void f(int(*)[3]);
You can also try running GCC-XML on this code to see that array types are
correctly reported:
typedef int A[3];
-Brad
More information about the gccxml
mailing list