diff options
author | Olivier Hainque <hainque@adacore.com> | 2012-05-04 08:03:54 +0000 |
---|---|---|
committer | Olivier Hainque <hainque@gcc.gnu.org> | 2012-05-04 08:03:54 +0000 |
commit | b50ff8bbb379d7be46b3e516e02e4c9ed08d3c14 (patch) | |
tree | 85a3a040f1d5a4524635a077278a095151962816 /gcc/gcc.c | |
parent | b075f09963a9960f9f386a8ec4d6cc41c214f4bd (diff) | |
download | gcc-b50ff8bbb379d7be46b3e516e02e4c9ed08d3c14.tar.gz |
gcc.c (eval_spec_function): Finalize/restore the current string obstack state as part of the context...
* gcc.c (eval_spec_function): Finalize/restore the current string
obstack state as part of the context push/pop operations.
From-SVN: r187146
Diffstat (limited to 'gcc/gcc.c')
-rw-r--r-- | gcc/gcc.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/gcc.c b/gcc/gcc.c index 09f9b1548b8..e152b705393 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -5313,6 +5313,8 @@ eval_spec_function (const char *func, const char *args) int save_this_is_linker_script; const char *save_suffix_subst; + int save_growing_size; + void *save_growing_value; sf = lookup_spec_function (func); if (sf == NULL) @@ -5329,6 +5331,18 @@ eval_spec_function (const char *func, const char *args) save_input_from_pipe = input_from_pipe; save_suffix_subst = suffix_subst; + /* If we have some object growing now, finalize it so the args and function + eval proceed from a cleared context. This is needed to prevent the first + constructed arg from mistakenly including the growing value. We'll push + this value back on the obstack once the function evaluation is done, to + restore a consistent processing context for our caller. This is fine as + the address of growing objects isn't guaranteed to remain stable until + they are finalized, and we expect this situation to be rare enough for + the extra copy not to be an issue. */ + save_growing_size = obstack_object_size (&obstack); + if (save_growing_size > 0) + save_growing_value = obstack_finish (&obstack); + /* Create a new spec processing context, and build the function arguments. */ @@ -5354,6 +5368,9 @@ eval_spec_function (const char *func, const char *args) input_from_pipe = save_input_from_pipe; suffix_subst = save_suffix_subst; + if (save_growing_size > 0) + obstack_grow (&obstack, save_growing_value, save_growing_size); + return funcval; } |