re PR c++/35097 (ICE with attribute and template specialization)

PR c++/35097
        * pt.c (tsubst): Don't look up a template typedef in an explicit
        specialization.

From-SVN: r132253
This commit is contained in:
Jason Merrill 2008-02-12 01:34:59 -05:00 committed by Jason Merrill
parent d6f77715ea
commit 02e52ae514
3 changed files with 25 additions and 2 deletions

View File

@ -1,3 +1,9 @@
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.
2008-02-11 Douglas Gregor <doug.gregor@gmail.com>
PR c++/35113

View File

@ -8826,14 +8826,16 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
tree decl = TYPE_NAME (t);
if (DECL_CLASS_SCOPE_P (decl)
&& CLASSTYPE_TEMPLATE_INFO (DECL_CONTEXT (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)))
&& 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. */

View File

@ -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);
}