]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: alias template equivalence and cv-quals [PR100032]
authorJason Merrill <jason@redhat.com>
Tue, 13 Apr 2021 18:49:29 +0000 (14:49 -0400)
committerJason Merrill <jason@redhat.com>
Tue, 13 Apr 2021 19:20:09 +0000 (15:20 -0400)
We also need to check that the cv-qualifiers are the same.

gcc/cp/ChangeLog:

PR c++/100032
* pt.c (get_underlying_template): Compare TYPE_QUALS.

gcc/testsuite/ChangeLog:

PR c++/100032
* g++.dg/cpp0x/alias-decl-equiv1.C: New test.

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

index 106dfe556f7fd7c9ff2af2cbfbf7f9254316b3cf..59df79484bfd826e3d70fb098c558e940aa39558 100644 (file)
@@ -6584,6 +6584,10 @@ get_underlying_template (tree tmpl)
              != num_innermost_template_parms (underlying)))
        break;
 
+      /* Does the alias add cv-quals?  */
+      if (TYPE_QUALS (TREE_TYPE (underlying)) != TYPE_QUALS (TREE_TYPE (tmpl)))
+       break;
+
       tree alias_args = INNERMOST_TEMPLATE_ARGS (generic_targs_for (tmpl));
       if (!comp_template_args (TI_ARGS (tinfo), alias_args))
        break;
diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-equiv1.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-equiv1.C
new file mode 100644 (file)
index 0000000..ae27c43
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/100032
+// { dg-do compile { target c++11 } }
+
+template <template<class> class> struct X { };
+template <class> struct Y { };
+template <class T> using Z = const Y<T>;
+
+template <class T> using W = Z<T>;
+using U = X<Z>;
+using U = X<W>;
+
+using T = X<Y>;
+using T = X<Z>;                        // { dg-error "conflicting declaration" }