From 02e52ae514072eb565ae9d7451ee00756c4f5121 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 12 Feb 2008 01:34:59 -0500 Subject: [PATCH] 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 --- 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 1e26a16..c11dcd5 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 2a8296e..a1e6521 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 0000000..c614ed4 --- /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.7.4