aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2014-01-07 16:28:33 -0500
committerJason Merrill <jason@gcc.gnu.org>2014-01-07 16:28:33 -0500
commit1b7ac92269bc3ed399572600e1722790c6903f7c (patch)
tree8e38ef496844471831393a649d64b9ef666c40a4
parent5a5e7deb5f93f04e027fd5baa1876370d6d6697f (diff)
downloadgcc-1b7ac92269bc3ed399572600e1722790c6903f7c.zip
gcc-1b7ac92269bc3ed399572600e1722790c6903f7c.tar.gz
gcc-1b7ac92269bc3ed399572600e1722790c6903f7c.tar.bz2
re PR c++/58856 (spurious 'wrong number of template arguments' error for template alias)
PR c++/58856 * pt.c (num_innermost_template_parms): New. (get_underlying_template): Use it. From-SVN: r206406
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/pt.c11
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/alias-decl-39.C11
3 files changed, 26 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index cdb376d..bf2a593 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2014-01-07 Jason Merrill <jason@redhat.com>
+ PR c++/58856
+ * pt.c (num_innermost_template_parms): New.
+ (get_underlying_template): Use it.
+
PR c++/58965
* mangle.c (write_guarded_var_name): Handle null DECL_NAME.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 98d7365..2e7cf60 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -5149,6 +5149,15 @@ alias_template_specialization_p (const_tree t)
&& DECL_ALIAS_TEMPLATE_P (TYPE_TI_TEMPLATE (t)));
}
+/* Return the number of innermost template parameters in TMPL. */
+
+static int
+num_innermost_template_parms (tree tmpl)
+{
+ tree parms = INNERMOST_TEMPLATE_PARMS (DECL_TEMPLATE_PARMS (tmpl));
+ return TREE_VEC_LENGTH (parms);
+}
+
/* Return either TMPL or another template that it is equivalent to under DR
1286: An alias that just changes the name of a template is equivalent to
the other template. */
@@ -5164,6 +5173,8 @@ get_underlying_template (tree tmpl)
{
tree sub = TYPE_TI_TEMPLATE (result);
if (PRIMARY_TEMPLATE_P (sub)
+ && (num_innermost_template_parms (tmpl)
+ == num_innermost_template_parms (sub))
&& same_type_p (result, TREE_TYPE (sub)))
{
/* The alias type is equivalent to the pattern of the
diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-39.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-39.C
new file mode 100644
index 0000000..9fe5538
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-39.C
@@ -0,0 +1,11 @@
+// PR c++/58856
+// { dg-require-effective-target c++11 }
+
+template <typename T>
+struct U1 {};
+
+template <typename T1, typename... Ts>
+using U2 = U1<T1>;
+
+template <typename T1, typename... Ts>
+using U3 = U2<T1, Ts...>;