Patchwork PR c++/51191 - ICE on alias of alias template instantiation

login
register
mail settings
Submitter Dodji Seketeli
Date Nov. 17, 2011, 11:32 p.m.
Message ID <m3aa7us4uf.fsf@redhat.com>
Download mbox | patch
Permalink /patch/126330/
State New
Headers show

Comments

Dodji Seketeli - Nov. 17, 2011, 11:32 p.m.
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
Jason Merrill - Nov. 18, 2011, 1:05 p.m.
On 11/17/2011 06:32 PM, Dodji Seketeli wrote:
> I am bootstrapping and testing the (IMHO better) patch below on
> x86_64-unknown-linux-gnu against trunk.

OK.

Jason

Patch

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 9738026..78e263f 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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)
diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-13.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-13.C
new file mode 100644
index 0000000..8555154
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-13.C
@@ -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" }
+}