Hello,

Spec function evaluations currently fail to work properly when involved as
part of an outer ongoing construction, as in

  *cpp:
  -I%:getenv(MYROOT /include)

for example. Here, the getenv function eval is queried while the "-I..."
string is being constructed.

The bug is that the currently growing string value is mistakenly seen as
part of the function first argument. With the example above, this yields to
misbehavior like

  "environment variable '-IMYROOT' not defined"
                         ^^

The attached patch fixes this by finalizing the current string obstack
prior to using it for the function arguments evaluation, saving/restoring the
obstack state as part of the context push/pop sequences already there.

We have been using this successfully for a while now, using env variables in
specs to make a few cross ports easier to use.

Bootstrapped and regtested for mainline on x86-linux.

OK to commit ?

Thanks in advance,

Olivier

2012-05-03  Olivier Hainque  <hain...@adacore.com>

        * gcc.c (eval_spec_function): Finalize/restore the current string
        obstack state as part of the context push/pop operations.

Attachment: specfn.dif
Description: video/dv

Reply via email to