This is the mail archive of the gcc-patches@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]

Re: [PATCH] PR c++/26693


Jason Merrill a Ãcrit :
Dodji Seketeli wrote:
-      && uses_template_parms (DECL_CONTEXT (decl)))
+      && uses_template_parms (DECL_CONTEXT (decl))
+      && uses_template_parms (decl))

This seems wrong. Why wouldn't we want to re-use typedefs with non-dependent types?

Ah, I did this as a stop gap measure because otherwise for a non-dependent typedef variant, the compiler was crashing in tree gen_args = tsubst (DECL_TI_ARGS (decl), args, complain, in_decl);


I should have investigated. Earlier. Now it seems it is crashing eventualy in tsusbt () because of the assert gcc_assert (TREE_VEC_LENGTH (args) > 0); around line 9060. This is because we are trying to tsubst a TEMPLATE_PARM_INDEX with a NULL args parameter. I am not sure why the assert would be required there. Just handling the arg == NULL case seems to fix it.


+ if (!enforce_access (TYPE_BINFO (DECL_CONTEXT (decl)), decl, decl))
+ return error_mark_node;

It occurs to me that just using TYPE_BINFO (DECL_CONTEXT (decl)) may not be enough for code that accesses a typedef through a derived class, i.e.


class A
{
 protected:
  typedef int mytype;
};

template <class T> class B;

class C: public A
{
  template <class T> friend class B;
};

template <class T> class B
{
  C::mytype mem;
};

B<int> b;

This is valid, but I believe your patch will cause us to reject it, which would be a regression.

Good catch.


Now I guess in this particular case, the right TYPE_BINFO to pass to enforce_access() would be the one of the C type, in C::mytype. If that is correct then how can I have access to that C type from withing tsubst() when I am tsubsting mytype, which TYPE_DECL points to the declaration "typedef int mytype;" from class A ? If I can't get that

+ name = TYPE_IDENTIFIER (TREE_TYPE (TYPE_MAIN_DECL (type)));

Is this different from TYPE_IDENTIFIER (TYPE_MAIN_VARIANT (type))?

It seems like both are equal actually.


Dodji.


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