From 36b21740b4756881c0e35e3cb87d77fac3d1d731 Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Mon, 7 Jan 2013 08:03:33 +0000 Subject: [PATCH] PR c++/52343 - error with alias template as template template argument In the example accompanying this patch, check_instantiated_arg tries to ensure that a non-type template argument should be a constant if it has integral or enumeration type. The problem is that an alias template which type-id is, e.g, an integer, looks like an argument that has integral/enumeration type: its TREE_TYPE is an integer type. So check_instantiated_arg mistenkaly barks that this integral non-type argument is not a constant. Bootstrapped and tested on x86_64-unknown-linux-gnu against trunk. gcc/cp/ PR c++/52343 * pt.c (check_instantiated_arg): Allow type template arguments. gcc/testsuite/ PR c++/52343 * g++.dg/cpp0x/alias-decl-29.C: New test. From-SVN: r194960 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/pt.c | 3 +++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/alias-decl-29.C | 10 ++++++++++ 4 files changed, 23 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/alias-decl-29.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1aecad0bbd8..1a872ff0658 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2013-01-04 Dodji Seketeli + + PR c++/52343 + * pt.c (check_instantiated_arg): Allow type template arguments. + 2013-01-04 Jason Merrill PR c++/55877 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 09a0aa53919..30bafa07db1 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -14419,6 +14419,9 @@ check_instantiated_arg (tree tmpl, tree t, tsubst_flags_t complain) return true; } } + /* Class template and alias template arguments should be OK. */ + else if (DECL_TYPE_TEMPLATE_P (t)) + ; /* A non-type argument of integral or enumerated type must be a constant. */ else if (TREE_TYPE (t) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0f15221d3c5..217e40fc7da 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-01-04 Dodji Seketeli + + PR c++/52343 + * g++.dg/cpp0x/alias-decl-29.C: New test. + 2013-01-06 Paul Thomas PR fortran/PR53876 diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-29.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-29.C new file mode 100644 index 00000000000..f6cc6950ba7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-29.C @@ -0,0 +1,10 @@ +// Origin: PR c++/52343 +// { dg-do compile { target c++11 } } + +template +using A = int; + +template class> +struct B {}; + +B b; -- 2.30.2