On 2/5/19 4:39 AM, Paolo Carlini wrote:
Hi,
On 04/02/19 17:48, Jason Merrill wrote:
On Mon, Feb 4, 2019 at 11:00 AM Paolo Carlini
<paolo.carl...@oracle.com> wrote:
On 04/02/19 15:47, Jason Merrill wrote:
On 2/1/19 3:52 PM, Paolo Carlini wrote:
Hi,
I think that this ICE on invalid (and valid, for c++17+) can be in
fact avoided by accepting in make_typename_type a TYPE_PACK_EXPANSION
as context, thus by not triggering the "‘T ...’ is not a class"
error. Not sure if a better fix would be something more general.
Note, anyway, that we are asserting TYPE_P (context) thus
TYPE_PACK_EXPANSIONs definitely get through beyond MAYBE_CLASS_TYPE_P.
The testcase should test that the using actually works, i.e. imports a
type from a base class.
Uhm, if I change the testcase to something like:
struct B { typedef int type; };
template<typename ...T> struct C : T... {
using typename T::type ...;
void f() { type value; }
};
template class C<B>;
we get a "sorry, unimplemented: use of ‘type_pack_expansion’ in
template" for value
I suspected that would happen.
which, arguably, is better than the current ICE,
but I'm not sure if we are close to completing the implementation of
this / we even want to attempt that at this Stage?!?
Well, I'd look at how we implement the equivalent for e.g. a variable:
struct A { static int i; };
template <class ...T> struct B: T... {
using T::i ...;
};
auto x = B<A>::i; // works
and try to use that code path for the typename case as well.
Yes. Note that, AFAICS, the code you added to implement P0195R2 works
fine for typename too. The problem happens when we actually encounter
inside the class something like:
void f() { type value; }
which, so to speak, appears to expand to a set of types: 'type' is a
TYPENAME_TYPE which has a TYPE_PACK_EXPANSION as TYPE_CONTEXT.
I wonder about replacing uses of 'type' with a TYPENAME_TYPE with the
current class as TYPE_CONTEXT? But your approach is OK, too.
Jason