[1/4,lambda] Preserve type qualifiers for implicit template parameters.

Submitted by Adam Butcher on Aug. 1, 2013, 12:25 p.m.

Details

Message ID 1375359930-12871-2-git-send-email-adam@jessamine.co.uk
State New
Headers show

Commit Message

Adam Butcher Aug. 1, 2013, 12:25 p.m.
---
 gcc/cp/pt.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

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);