public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r9-10162] c++: alias template equivalence and cv-quals [PR100032]
Date: Fri, 13 May 2022 17:40:51 +0000 (GMT)	[thread overview]
Message-ID: <20220513174051.710FE395B468@sourceware.org> (raw)

https://gcc.gnu.org/g:945c2afcb390dd040510ee7a2dc996ad204031c5

commit r9-10162-g945c2afcb390dd040510ee7a2dc996ad204031c5
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Apr 13 14:49:29 2021 -0400

    c++: alias template equivalence and cv-quals [PR100032]
    
    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.

Diff:
---
 gcc/cp/pt.c                                    |  4 ++++
 gcc/testsuite/g++.dg/cpp0x/alias-decl-equiv1.C | 13 +++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 08909e2c863..568d5155ea3 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -6255,6 +6255,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
 	(template_parms_to_args (DECL_TEMPLATE_PARMS (tmpl)));
       if (!comp_template_args (TI_ARGS (tinfo), alias_args))
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" }


                 reply	other threads:[~2022-05-13 17:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220513174051.710FE395B468@sourceware.org \
    --to=jason@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).