This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] PR c++/51191 - ICE on alias of alias template instantiation
- From: Dodji Seketeli <dodji at redhat dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 17 Nov 2011 22:07:43 +0100
- Subject: [PATCH] PR c++/51191 - ICE on alias of alias template instantiation
Hello,
In the example of the patch below, we crash when trying to print the
alias of alias template instantiation 'Alias'. This is because
alias_template_specialization_p carelessly looks at
CLASSTYPE_TEMPLATE_INFO first, while TYPE_TEMPLATE_INFO is NULL in
this case.
Fixed thus, bootstrapped and tested on x86_64-unknown-linux-gnu
against trunk.
gcc/cp/
PR c++/51191 - ICE while printing alias of alias instantiation
* pt.c (alias_template_specialization_p): Don't crash on an alias
of template alias instantiation.
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 | 3 ++-
gcc/testsuite/g++.dg/cpp0x/alias-decl-13.C | 24 ++++++++++++++++++++++++
2 files changed, 26 insertions(+), 1 deletions(-)
create mode 100644 gcc/testsuite/g++.dg/cpp0x/alias-decl-13.C
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 9738026..ac5d394 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -5310,7 +5310,8 @@ alias_template_specialization_p (tree t)
{
if (t == NULL_TREE)
return false;
- return (primary_template_instantiation_p (t)
+ return (TYPE_TEMPLATE_INFO (t)
+ && primary_template_instantiation_p (t)
&& DECL_ALIAS_TEMPLATE_P (TYPE_TI_TEMPLATE (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" }
+}
--
1.7.6.4
--
Dodji