Support copying local_specializations.
authorJason Merrill <jason@redhat.com>
Tue, 29 Aug 2017 19:40:21 +0000 (15:40 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 29 Aug 2017 19:40:21 +0000 (15:40 -0400)
* cp-tree.h (enum lss_policy): New.
(local_specialization_stack): Add policy parameter to default ctor.
* pt.c (local_specialization_stack): Copy local_specializations if
lss_copy.

From-SVN: r251424

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/pt.c

index f91f6bebcb6f40b4e1c092858e492500167ff011..b4e21f6f0643169419f897fd5ae64f678d854b10 100644 (file)
@@ -1,5 +1,11 @@
 2017-08-29  Jason Merrill  <jason@redhat.com>
 
+       Support copying local_specializations.
+       * cp-tree.h (enum lss_policy): New.
+       (local_specialization_stack): Add policy parameter to default ctor.
+       * pt.c (local_specialization_stack): Copy local_specializations if
+       lss_copy.
+
        * constexpr.c (potential_constant_expression_1): Add "now" parm.
        (is_constant_expression, require_constant_expression): New.
        (is_static_init_expression, is_nondependent_constant_expression)
index f0eafb3c27705c6ac1a4b700826b5070f3c4b764..a58e7bd0cc00f9922fc7119c417c20aa6ec1fab8 100644 (file)
@@ -5117,9 +5117,10 @@ enum unification_kind_t {
 // An RAII class used to create a new pointer map for local
 // specializations. When the stack goes out of scope, the
 // previous pointer map is restored.
+enum lss_policy { lss_blank, lss_copy };
 struct local_specialization_stack
 {
-  local_specialization_stack ();
+  local_specialization_stack (lss_policy = lss_blank);
   ~local_specialization_stack ();
 
   hash_map<tree, tree> *saved;
index e34fe21cb1592b8fcc8ef469b26b04713f9ac9dd..1b726ff53985e8b76d22f0e9e0e718d6642ec73d 100644 (file)
@@ -77,10 +77,13 @@ static tree cur_stmt_expr;
 //
 // Implementation of the RAII helper for creating new local
 // specializations.
-local_specialization_stack::local_specialization_stack ()
+local_specialization_stack::local_specialization_stack (lss_policy policy)
   : saved (local_specializations)
 {
-  local_specializations = new hash_map<tree, tree>;
+  if (policy == lss_blank || !saved)
+    local_specializations = new hash_map<tree, tree>;
+  else
+    local_specializations = new hash_map<tree, tree>(*saved);
 }
 
 local_specialization_stack::~local_specialization_stack ()