This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for c++/35097
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 12 Feb 2008 01:34:29 -0500
- Subject: C++ PATCH for c++/35097
Yet another refinement of my change to re-use typedefs. This time the
problem was that we were treating explicit specializations as templates,
which doesn't work too well.
Tested x86_64-pc-linux-gnu, applied to trunk.
2008-02-11 Jason Merrill <jason@redhat.com>
PR c++/35097
* pt.c (tsubst): Don't look up a template typedef in an explicit
specialization.
Index: cp/pt.c
===================================================================
*** cp/pt.c (revision 132243)
--- cp/pt.c (working copy)
*************** tsubst (tree t, tree args, tsubst_flags_
*** 8826,8839 ****
tree decl = TYPE_NAME (t);
if (DECL_CLASS_SCOPE_P (decl)
! && CLASSTYPE_TEMPLATE_INFO (DECL_CONTEXT (decl)))
{
tree tmpl = most_general_template (DECL_TI_TEMPLATE (decl));
tree gen_args = tsubst (DECL_TI_ARGS (decl), args, complain, in_decl);
r = retrieve_specialization (tmpl, gen_args, false);
}
else if (DECL_FUNCTION_SCOPE_P (decl)
! && DECL_TEMPLATE_INFO (DECL_CONTEXT (decl)))
r = retrieve_local_specialization (decl);
else
/* The typedef is from a non-template context. */
--- 8826,8841 ----
tree decl = TYPE_NAME (t);
if (DECL_CLASS_SCOPE_P (decl)
! && CLASSTYPE_TEMPLATE_INFO (DECL_CONTEXT (decl))
! && uses_template_parms (DECL_CONTEXT (decl)))
{
tree tmpl = most_general_template (DECL_TI_TEMPLATE (decl));
tree gen_args = tsubst (DECL_TI_ARGS (decl), args, complain, in_decl);
r = retrieve_specialization (tmpl, gen_args, false);
}
else if (DECL_FUNCTION_SCOPE_P (decl)
! && DECL_TEMPLATE_INFO (DECL_CONTEXT (decl))
! && uses_template_parms (DECL_TI_ARGS (DECL_CONTEXT (decl))))
r = retrieve_local_specialization (decl);
else
/* The typedef is from a non-template context. */
Index: testsuite/g++.dg/ext/attrib31.C
===================================================================
*** testsuite/g++.dg/ext/attrib31.C (revision 0)
--- testsuite/g++.dg/ext/attrib31.C (revision 0)
***************
*** 0 ****
--- 1,15 ----
+ // PR c++/35097
+
+ template<int> struct A;
+
+ template<> struct A<0>
+ {
+ typedef int X __attribute((aligned(4)));
+ };
+
+ template<typename T> void foo(const A<0>::X&, T);
+
+ void bar()
+ {
+ foo(A<0>::X(), 0);
+ }