> Am 14.12.2024 um 09:08 schrieb Jakub Jelinek <ja...@redhat.com>:
> 
> Hi!
> 
> The magic values for default (usually -1 or sometimes 2) for some options
> are from times we haven't global_options_set, I think we should eventually
> get rid of all of those.
> 
> The PR is about gcc -Q --help=optimizers reporting -fshort-enums as
> [enabled] when it is disabled.
> For this the following patch is just partial fix; with explicit
> gcc -Q --help=optimizers -fshort-enums
> or
> gcc -Q --help=optimizers -fno-short-enums
> it already worked correctly before, with this patch it will report
> even with just
> gcc -Q --help=optimizers
> correct value on most targets, except 32-bit arm with some options or
> defaults, so I think it is a step in the right direction.
> 
> But, as I wrote in the PR, process_options isn't done before --help=
> and even shouldn't be in its current form where it warns on some option
> combinations or errors or emits sorry on others, so I think ideally
> process_options should have some bool argument whether it is done for
> --help= purposes or not, if yes, not emit warnings and just adjust the
> options, otherwise do what it currently does.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Ok

Thanks,

Richard 

> 2024-12-14  Jakub Jelinek  <ja...@redhat.com>
> 
>    PR c/118011
> gcc/
>    * opts.cc (init_options_struct): Don't set opts->x_flag_short_enums to
>    2.
>    * toplev.cc (process_options): Test !OPTION_SET_P (flag_short_enums)
>    rather than flag_short_enums == 2.
> gcc/ada/
>    * gcc-interface/misc.cc (gnat_post_options): Test
>    !OPTION_SET_P (flag_short_enums) rather than flag_short_enums == 2.
> 
> --- gcc/opts.cc.jj    2024-12-02 11:08:52.080134376 +0100
> +++ gcc/opts.cc    2024-12-13 10:33:55.433900989 +0100
> @@ -444,9 +444,6 @@ init_options_struct (struct gcc_options
> 
>   /* Initialize whether `char' is signed.  */
>   opts->x_flag_signed_char = DEFAULT_SIGNED_CHAR;
> -  /* Set this to a special "uninitialized" value.  The actual default
> -     is set after target options have been processed.  */
> -  opts->x_flag_short_enums = 2;
> 
>   /* Initialize target_flags before default_options_optimization
>      so the latter can modify it.  */
> --- gcc/toplev.cc.jj    2024-12-09 11:37:50.452216272 +0100
> +++ gcc/toplev.cc    2024-12-13 10:35:29.396546654 +0100
> @@ -1300,7 +1300,7 @@ process_options ()
>       flag_section_anchors = 0;
>     }
> 
> -  if (flag_short_enums == 2)
> +  if (!OPTION_SET_P (flag_short_enums))
>     flag_short_enums = targetm.default_short_enums ();
> 
>   /* Set aux_base_name if not already set.  */
> --- gcc/ada/gcc-interface/misc.cc.jj    2024-11-23 13:00:27.748036611 +0100
> +++ gcc/ada/gcc-interface/misc.cc    2024-12-13 10:36:49.658389809 +0100
> @@ -283,7 +283,7 @@ gnat_post_options (const char **pfilenam
>   /* Unfortunately the post_options hook is called before the value of
>      flag_short_enums is autodetected, if need be.  Mimic the process
>      for our private flag_short_enums.  */
> -  if (flag_short_enums == 2)
> +  if (!OPTION_SET_P (flag_short_enums))
>     flag_short_enums = targetm.default_short_enums ();
> 
>   return false;
> 
>    Jakub
> 

Reply via email to