Mangling enclosing template arguments used in the base of an unresolved-name
John McCall
rjmccall at apple.com
Tue Jun 28 06:32:27 UTC 2011
How should we mangle the reference to 'T' in the following example?
template <class T> struct A {
template <class U> auto foo(U &u) -> decltype(T::bar(u));
};
The ABI says:
Class template parameter references are mangled using the standard
mangling for the actual parameter type, typically a substitution. Note that
a template parameter reference is a substitution candidate, distinct from
the type (or other substitutible entity) that is the actual parameter.
We can't mangle T as a <template-param> because it would look exactly
like U. We can't mangle it as a <source-name> because we're required
to be alpha-invariant over template parameter names. As far as I can tell,
the mangling grammar doesn't allow us to mangle it as the substituted
type. So we have a problem, and there's a parallel problem if the base
of the <unresolved-name> is a template-id where the template name is a
template template parameter from an enclosing template.
In both cases the underlying template argument should be available
as a substitution. I suggest adding a new production:
<existing-substitution> ::= <substitution>
and then extending unresolved-type:
<unresolved-type> ::= <existing-substitution> [ <template-args> ]
with the proviso that this production should only be used for enclosing
template template parameters.
John.
More information about the cxx-abi-dev
mailing list