From 82b0ce2eb32bea3d6e35609d1806ba332576826d Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 29 Aug 2017 15:40:21 -0400 Subject: [PATCH] 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. From-SVN: r251424 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/cp-tree.h | 3 ++- gcc/cp/pt.c | 7 +++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f91f6bebcb6..b4e21f6f064 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,11 @@ 2017-08-29 Jason Merrill + 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) diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index f0eafb3c277..a58e7bd0cc0 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -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 *saved; diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index e34fe21cb15..1b726ff5398 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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; + if (policy == lss_blank || !saved) + local_specializations = new hash_map; + else + local_specializations = new hash_map(*saved); } local_specialization_stack::~local_specialization_stack () -- 2.30.2