This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 1/4] [lambda] Preserve type qualifiers for implicit template parameters.
- From: Adam Butcher <adam at jessamine dot co dot uk>
- To: Jason Merrill <jason at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Gabriel Dos Reis <gdr at integrable-solutions dot net>, Andrew Sutton <andrew dot n dot sutton at gmail dot com>, Adam Butcher <adam at jessamine dot co dot uk>
- Date: Thu, 1 Aug 2013 13:25:27 +0100
- Subject: [PATCH 1/4] [lambda] Preserve type qualifiers for implicit template parameters.
- References: <51E96FB9 dot 6090108 at redhat dot com> <1375359930-12871-1-git-send-email-adam at jessamine dot co dot uk>
---
gcc/cp/pt.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index dea1ec0..6e209f8 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -21317,8 +21317,15 @@ add_implicit_template_parms (size_t count, tree parameters)
// Rewrite the type of P to be the template_parm added above (getdecls is
// used to retrieve it since it is the most recent declaration in this
- // scope).
- TREE_TYPE (generic_type_ptr) = TREE_TYPE (getdecls ());
+ // scope). Qualifiers need to be preserved also.
+
+ tree& cur_type = TREE_TYPE (generic_type_ptr);
+ tree new_type = TREE_TYPE (getdecls ());
+
+ if (TYPE_QUALS (cur_type))
+ cur_type = cp_build_qualified_type (new_type, TYPE_QUALS (cur_type));
+ else
+ cur_type = new_type;
}
gcc_assert (synth_idx == count);
--
1.8.3