> > Gabriel Dos Reis wrote: > > C++ defines a notion of "class name for linkage purpose" -- that is a > > notion used to define the One Definition Rule. > > In general the TYPE_NAME of TYPE_MAIN_VARIANT is the class name for > > linkage purpose. > > The behaviour you reported on implements the rule 7.1.3/5: > > > > If the typedef declaration defines an unnamed class (or enum), the > > first typedef-name declared by the declaration > > to be that class type (or enum type) is used to denote the class type > > (or enum type) for linkage purposes only (3.5). > > > > As a result of C types not having a "class name for linkage purposes", I > am finding it difficult to define a "normalised" string for > FUNCTION_TYPE nodes that represents the type in the same way across > C/C++ for compatible function types. > > Basically I need to save to a file a string that represents a > FUNCTION_TYPE node that can be compared against other strings that also > represent FUNCTION_TYPE nodes and if the two functions are compatible as > would be returned by: function_types_compatible_p() then the strings > should be equal.
Again C has different rules from C++. In C, the following two TUs combined together are still valid code while in C++, they are invalid. tu1.c: struct a { int t; }; void f(struct a); ---------------- cut --------------------- tu2.c: typedef struct { int t; }b; void f(b a); ---------------- cut --------------------- Thanks, Andrew Pinski