From 08037cca35dcd6302fb167af9039a629e1e6fda1 Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 12 Feb 2008 06:34:59 +0000 Subject: [PATCH] PR c++/35097 * pt.c (tsubst): Don't look up a template typedef in an explicit specialization. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@132253 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 6 ++++-- gcc/testsuite/g++.dg/ext/attrib31.C | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ext/attrib31.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1e26a168137..c11dcd55919 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2008-02-11 Jason Merrill + + PR c++/35097 + * pt.c (tsubst): Don't look up a template typedef in an explicit + specialization. + 2008-02-11 Douglas Gregor PR c++/35113 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 2a8296efef0..a1e6521c852 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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. */ diff --git a/gcc/testsuite/g++.dg/ext/attrib31.C b/gcc/testsuite/g++.dg/ext/attrib31.C new file mode 100644 index 00000000000..c614ed4f408 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/attrib31.C @@ -0,0 +1,15 @@ +// PR c++/35097 + +template struct A; + +template<> struct A<0> +{ + typedef int X __attribute((aligned(4))); +}; + +template void foo(const A<0>::X&, T); + +void bar() +{ + foo(A<0>::X(), 0); +} -- 2.11.4.GIT