]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
driver: fix crash with --diagnostics-plain-output [PR117942]
authorMarek Polacek <polacek@redhat.com>
Mon, 9 Dec 2024 13:19:35 +0000 (08:19 -0500)
committerMarek Polacek <polacek@redhat.com>
Mon, 9 Dec 2024 21:57:34 +0000 (16:57 -0500)
We are crashing here because decode_cmdline_options_to_array has:

  if (!strcmp (opt, "-fdiagnostics-plain-output"))
    ...

but that doesn't handle the '--FLAG' variant.

PR driver/117942

gcc/ChangeLog:

* opts-common.cc (decode_cmdline_options_to_array): Also detect
--diagnostics-plain-output.

Reviewed-by: Joseph Myers <josmyers@redhat.com>
gcc/opts-common.cc

index 2594e5a564326b6cc718e2cfbe8b1b1f4a6bad94..e85920bcb652baae6a32fb0fc31992371203990f 100644 (file)
@@ -1077,7 +1077,9 @@ decode_cmdline_options_to_array (unsigned int argc, const char **argv,
       /* Expand -fdiagnostics-plain-output to its constituents.  This needs
         to happen here so that prune_options can handle -fdiagnostics-color
         specially.  */
-      if (!strcmp (opt, "-fdiagnostics-plain-output"))
+      if (opt[0] == '-'
+         && (opt[1] == '-' || opt[1] == 'f')
+         && !strcmp (opt + 2, "diagnostics-plain-output"))
        {
          /* If you have changed the default diagnostics output, and this new
             output is not appropriately "plain" (e.g., the change needs to be