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]

[C++] comptypes and TYPENAME_TYPE


Hello,

currently, comptypes handle TYPENAME_TYPES this way:

+   /* TYPENAME_TYPEs should be resolved if the qualifying scope is the
+      current instantiation.  */
+   if (TREE_CODE (t1) == TYPENAME_TYPE)
+     t1 = resolve_typename_type_in_current_instantiation (t1);
+   if (TREE_CODE (t2) == TYPENAME_TYPE)
+     t2 = resolve_typename_type_in_current_instantiation (t2);

(patch by Mark, here:
http://gcc.gnu.org/ml/gcc-patches/2003-01/msg02453.html)

I was tracking c++/11105, this is the testcase:

----------------------------------------------
template <typename T> struct S {
    struct I{};
    operator I* ();
};

template <typename T> struct S2 : S<T> {
    operator typename S<T>::I* ();
};

template struct S2<int>;
----------------------------------------------

I noticed that, in mangle_conv_op_name_for_type we end up comparing
"typename S<T>::I*" with "S<T>::I*". The comparison fails because S<T> (the
scope of S<T>::I) is not the current open class (which happens to be S2<T>).

Why is comptypes using resolve_typename_type_in_current_instantiation?
Changing it to resolve_typename_type(t1, false) makes the testcase work, but
it breaks mangle10.C and mangle12.C. Suggestions? Maybe I should add a new
flag to comptypes like COMPARE_THROUGH_ALL_TYPENAMES and use it within
mangle_conv_op_name_for_type?

Giovanni Bajo


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