C++ PATCH: put ttp nodes in permanent obstack

Kriang Lerdsuwanakij lerdsuwa@scf-fs.usc.edu
Tue Jan 12 02:07:00 GMT 1999


Hi

The included patch fixes memory problem reported in

http://www.cygnus.com/ml/egcs-bugs/1999-Jan/0211.html

Nodes involving template template parameters were not placed
in permanent obstack, causing random errors when they are
later used by tsubst.

-Kriang


        * pt.c (lookup_template_class): Call coerce_template_parms early.
        Put newly created TEMPLATE_TEMPLATE_PARM in permanent obstack.


*** gcc/cp/pt.c 1999/01/11 06:27:51     4.0
--- gcc/cp/pt.c 1999/01/12 07:09:26
*************** lookup_template_class (d1, arglist, in_d
*** 3444,3463 ****
        /* Create a new TEMPLATE_DECL and TEMPLATE_TEMPLATE_PARM node to store
           template arguments */
  
!       tree parm = copy_template_template_parm (TREE_TYPE (template));
!       tree template2 = TYPE_STUB_DECL (parm);
        tree arglist2;
  
        parmlist = DECL_INNERMOST_TEMPLATE_PARMS (template);
- 
        arglist2 = coerce_template_parms (parmlist, arglist, template, 1, 1);
        if (arglist2 == error_mark_node)
        return error_mark_node;
  
        arglist2 = copy_to_permanent (arglist2);
        TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO (parm)
        = perm_tree_cons (template2, arglist2, NULL_TREE);
        TYPE_SIZE (parm) = 0;
        return parm;
      }
    else 
--- 3444,3471 ----
        /* Create a new TEMPLATE_DECL and TEMPLATE_TEMPLATE_PARM node to store
           template arguments */
  
!       tree parm;
!       tree template2;
        tree arglist2;
  
        parmlist = DECL_INNERMOST_TEMPLATE_PARMS (template);
        arglist2 = coerce_template_parms (parmlist, arglist, template, 1, 1);
        if (arglist2 == error_mark_node)
        return error_mark_node;
  
+       /* Put the new TEMPLATE_TEMPLATE_PARM and nodes
+          associated to it in permanent obstack.  */
+       push_obstacks (&permanent_obstack, &permanent_obstack);
+ 
+       parm = copy_template_template_parm (TREE_TYPE (template));
+       template2 = TYPE_STUB_DECL (parm);
+ 
        arglist2 = copy_to_permanent (arglist2);
        TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO (parm)
        = perm_tree_cons (template2, arglist2, NULL_TREE);
        TYPE_SIZE (parm) = 0;
+ 
+       pop_obstacks ();
        return parm;
      }
    else



More information about the Gcc-patches mailing list