public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug driver/111014] New: do_spec_1 terminates arguments too eagerly when processing spec function
@ 2023-08-14 13:04 pexu@gcc-bugzilla.mail.kapsi.fi
  0 siblings, 0 replies; only message in thread
From: pexu@gcc-bugzilla.mail.kapsi.fi @ 2023-08-14 13:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111014

            Bug ID: 111014
           Summary: do_spec_1 terminates arguments too eagerly when
                    processing spec function
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: driver
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pexu@gcc-bugzilla.mail.kapsi.fi
  Target Milestone: ---

Hi.

do_spec_1 always terminates the current argument (via end_going_arg) if
processing a spec function.

6881      if (processing_spec_function)
6882        end_going_arg ();

If a spec function returns a non-null string it is expanded using do_spec_1.  

7043      funcval = eval_spec_function (func, args, soft_matched_part);
7044      if (funcval != NULL && do_spec_1 (funcval, 0, NULL) < 0)

However, because processing_spec_function is in this case non-zero, there is
always a termination after each nested %-sequence has been processed.

Thus, e.g. "%:version-compare(>= 1.0 -version-compare= %%(do_spec))" and
"%(do_spec)" behave differently if the expanded %-sequences have any trailing
parts:

# cat version_compare_string.spec
*self_spec:
+ --version-compare=1.0 %<-version-compare=*

*do_spec:
-W%{!Werror:no-}error

*cc1_options:
+ %:version-compare(>= 1.0 -version-compare= %%(do_spec)) %(do_spec)

# gcc -c -xc -specs=version_compare_string.spec - < /dev/null
cc1: error: unrecognized command-line option ‘-Wno-’
[...]

In the first case, do_spec is not expanded as "-Wno-error" but as "-Wno-" and
"error".  I wonder if this termination is really necessary; the same effect can
be archieved by simply having a whitespace character to follow the spec
function, if concatenation is not to be desired.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-08-14 13:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-14 13:04 [Bug driver/111014] New: do_spec_1 terminates arguments too eagerly when processing spec function pexu@gcc-bugzilla.mail.kapsi.fi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).