@@ -2870,7 +2870,7 @@ primary_template_instantiation_p (const_tree t)
return DECL_LANG_SPECIFIC (t)
&& DECL_TEMPLATE_INSTANTIATION (t)
&& PRIMARY_TEMPLATE_P (DECL_TI_TEMPLATE (t));
- else if (CLASS_TYPE_P (t))
+ else if (CLASS_TYPE_P (t) && !TYPE_DECL_ALIAS_P (TYPE_NAME (t)))
return CLASSTYPE_TEMPLATE_INSTANTIATION (t)
&& PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (t));
else if (TYPE_P (t)
new file mode 100644
@@ -0,0 +1,24 @@
+// Origin PR c++/51191
+// { dg-options "-std=c++0x" }
+
+template< class T >
+class ClassTemplate {};
+
+template< class T >
+struct Metafunction {
+ typedef T type;
+};
+
+template< class T >
+using TemplateAlias = ClassTemplate< typename Metafunction<T>::type >;
+
+using Alias = TemplateAlias<int>;
+
+template< class T >
+void f( TemplateAlias<T> );
+
+int main()
+{
+ Alias x;
+ f( x ); // { dg-error "no matching function for call to|f" }
+}
I think I was a bit too hasty on this subject. I am bootstrapping and testing the (IMHO better) patch below on x86_64-unknown-linux-gnu against trunk. Sorry for the noise. From: Dodji Seketeli <dodji@redhat.com> Date: Thu, 17 Nov 2011 19:07:58 +0100 Subject: [PATCH] PR c++/51191 - ICE on alias of alias template instantiation gcc/cp/ PR c++/51191 - ICE while printing alias of alias instantiation * pt.c (primary_template_instantiation_p): Don't forget to consider alias declarations. gcc/testsuite/ PR c++/51191 - ICE while printing alias of alias instantiation * g++.dg/cpp0x/alias-decl-13.C: New test. --- gcc/cp/pt.c | 2 +- gcc/testsuite/g++.dg/cpp0x/alias-decl-13.C | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/alias-decl-13.C