OSDN Git Service

Fix PR c++/42697
[pf3gnuchains/gcc-fork.git] / gcc / cp / pt.c
index 3e2927c..13bb5aa 100644 (file)
@@ -3720,15 +3720,17 @@ maybe_update_decl_type (tree orig_type, tree scope)
         TYPENAME_TYPEs and SCOPE_REFs that were previously dependent.  */
       tree args = current_template_args ();
       tree auto_node = type_uses_auto (type);
+      tree pushed;
       if (auto_node)
        {
          tree auto_vec = make_tree_vec (1);
          TREE_VEC_ELT (auto_vec, 0) = auto_node;
          args = add_to_template_args (args, auto_vec);
        }
-      push_scope (scope);
+      pushed = push_scope (scope);
       type = tsubst (type, args, tf_warning_or_error, NULL_TREE);
-      pop_scope (scope);
+      if (pushed)
+       pop_scope (scope);
     }
 
   if (type == error_mark_node)
@@ -9018,7 +9020,8 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
               specialize R.  */
            gen_tmpl = most_general_template (DECL_TI_TEMPLATE (t));
            argvec = tsubst_template_args (DECL_TI_ARGS
-                                          (DECL_TEMPLATE_RESULT (gen_tmpl)),
+                                          (DECL_TEMPLATE_RESULT
+                                                 (DECL_TI_TEMPLATE (t))),
                                           args, complain, in_decl);
 
            /* Check to see if we already have this specialization.  */