make_node vs. copy_node
Mark Mitchell
mark@codesourcery.com
Thu Aug 12 12:41:00 GMT 1999
These two functions do not operate in the same way with respect to
obstacks. In particular, make_node does things like this:
/* All decls in an inline function need to be saved. */
if (obstack != &permanent_obstack)
obstack = saveable_obstack;
whereas copy_node just blithely allocated on the current_obstack.
This has bad consequences if one does a copy_node on a decl in an
inline function. (Why would one do this? When instantiating a
template, for example; we copy the template decl and then modify it.)
I think that the semantics of copy_node should be roughly:
new_node = make_node (code);
memcpy (new_node, old_node, size);
Does anyone disagree? (I don't propose literally doing this; the
example is only for clarity.)
Does anyone care to pre-approve a patch that replicates the obstack
handling of make_node, assuming the regression tests don't blow up?
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
More information about the Gcc
mailing list