[GCC-XML] typenames of template classes with typedef'd template parameters

Brad King brad.king at kitware.com
Thu May 18 09:42:05 EDT 2006


Stefan Roiser wrote:
> parsing the following example with gccxml
> 
> template <typename T> class Foo { T t; };
> 
> typedef int MyInt;
> Foo<MyInt> f;
> 
> will return for the class name "Foo<int>" and the type of the data  
> member "t" the typedef "MyInt". Would it be possible to also retain  the 
> information about the typedef'd template argument in the class  name 
> (maybe as some extra attribute)?

Unfortunately this is not possible, or at least not very easy.  GCC-XML 
is just a patch to a GCC 3.3 C++ parser to dump XML.  The GCC parser 
throws out this information long before the xml.c dump code sees it. 
Function parameter types that are typedefs are sometimes lost too, 
depending on whether the typedef is in a namespace or class context.

I've brought this up on the GCC bug tracker and the response was that 
this is a frequent debate about how error messages should be reported. 
Some people think messages are clearer with the typedef names, and 
others with the true types.  It became obvious I was not going to 
convince them to change anything.

This leaves only the option of further patching the GCC parser to avoid 
throwing out this information.  I've tried a few times but just haven't 
had the time to really figure out where it is stored originally and how 
to keep it.  A few hack changes work in simple cases but cause internal 
compiler errors in other cases.

-Brad



More information about the gccxml mailing list