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

            Bug ID: 124464
           Summary: RFE: Add ability to quote command line
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: diagnostics
          Assignee: dmalcolm at redhat dot com
          Reporter: pierre-emmanuel.patry at embecosm dot com
  Target Milestone: ---

The language hooks already provide a way to get the location within an
argument.

FOO_langhook_handle_option (
  size_t scode, const char *arg, HOST_WIDE_INT value, int kind,
  location_t loc, const struct cl_option_handlers *handlers);

But this location is relative to the beginning of the option handled, it gets
hard for the user to know which one was invalid when a lot of options are
specified.

Example from the rust front-end:

./gcc/crab1 test.rs -frust-crate-attr="(option1" -frust-crate-attr="option2("
-frust-crate-attr="option3(

gives the following output using the standard diagnostic mechanisms:

cli:1:1: error: XXX
cli:1:8: error: YYY
cli:1:8: error: ZZZ

A quoting mechanism for the command line would improve readability:

cli:1:1: error: XXXX
    1 | ./gcc/crab1 test.rs -frust-crate-attr="(option1"
      |                                        ^~~~~

Reply via email to