DR 1286 PR c++/60328
authorJason Merrill <jason@redhat.com>
Tue, 25 Feb 2014 18:53:45 +0000 (13:53 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 25 Feb 2014 18:53:45 +0000 (13:53 -0500)
DR 1286
PR c++/60328
* pt.c (get_underlying_template): Fix equivalence calculation.

From-SVN: r208152

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp0x/alias-decl-dr1286b.C [new file with mode: 0644]

index 5afc6d8..7f63b8e 100644 (file)
@@ -1,3 +1,9 @@
+2014-02-25  Jason Merrill  <jason@redhat.com>
+
+       DR 1286
+       PR c++/60328
+       * pt.c (get_underlying_template): Fix equivalence calculation.
+
 2014-02-25  Adam Butcher  <adam@jessamine.co.uk>
 
        PR c++/60311
index bd59142..4a9fa71 100644 (file)
@@ -5185,9 +5185,12 @@ 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)))
+                 == num_innermost_template_parms (sub)))
            {
+             tree alias_args = INNERMOST_TEMPLATE_ARGS
+               (template_parms_to_args (DECL_TEMPLATE_PARMS (tmpl)));
+             if (!comp_template_args (TYPE_TI_ARGS (result), alias_args))
+               break;
              /* The alias type is equivalent to the pattern of the
                 underlying template, so strip the alias.  */
              tmpl = sub;
diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-dr1286b.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-dr1286b.C
new file mode 100644 (file)
index 0000000..fef9818
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/60328
+// { dg-require-effective-target c++11 }
+
+template <class _T, class... _Rest>
+struct Foo
+{
+  template <class _TT, class... _RR>
+  using Bar = Foo<_TT, _RR...>;
+
+  using Normal = Foo<_Rest...>;
+  using Fail = Bar<_Rest...>;
+};