* [pushed] c++: alias template equivalence and cv-quals [PR100032]
@ 2021-04-13 19:20 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2021-04-13 19:20 UTC (permalink / raw)
To: gcc-patches
We also need to check that the cv-qualifiers are the same.
Tested x86_64-pc-linux-gnu, applying to trunk.
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 | 4 ++++
gcc/testsuite/g++.dg/cpp0x/alias-decl-equiv1.C | 13 +++++++++++++
2 files changed, 17 insertions(+)
create mode 100644 gcc/testsuite/g++.dg/cpp0x/alias-decl-equiv1.C
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 106dfe556f7..59df79484bf 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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
index 00000000000..ae27c43bc0a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-equiv1.C
@@ -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" }
base-commit: 4df918798b445e86305b63f86f5312a18e4017c5
--
2.27.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-04-13 19:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-13 19:20 [pushed] c++: alias template equivalence and cv-quals [PR100032] Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).