[PATCH] Record that -gtoggle is already used in gcc_options.
Richard Biener
richard.guenther@gmail.com
Tue Nov 2 14:33:22 GMT 2021
On Tue, Nov 2, 2021 at 3:11 PM Martin Liška <mliska@suse.cz> wrote:
>
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>
> Ready to be installed?
I think -gtoggle matches a Defered option and thus should be processed
in handle_common_deferred_options. I'd argue that --help printing shouldn't
be part of decode_options but done only in toplev.c (not from the
parse_optimize_options caller).
Richard.
> Thanks,
> Martin
>
> When doing flip based on -gtoggle, record it. Otherwise, we will
> apply it for the second time in finish_options.
>
> PR debug/102955
>
> gcc/ChangeLog:
>
> * common.opt: Add new gtoggle_used variable.
> * opts.c (finish_options): Do not interpret flag_gtoggle twice.
>
> gcc/testsuite/ChangeLog:
>
> * gcc.dg/pr102955.c: New test.
> ---
> gcc/common.opt | 4 ++++
> gcc/opts.c | 3 ++-
> gcc/testsuite/gcc.dg/pr102955.c | 14 ++++++++++++++
> 3 files changed, 20 insertions(+), 1 deletion(-)
> create mode 100644 gcc/testsuite/gcc.dg/pr102955.c
>
> diff --git a/gcc/common.opt b/gcc/common.opt
> index 1a5b9bfcca9..2568ecb98b8 100644
> --- a/gcc/common.opt
> +++ b/gcc/common.opt
> @@ -3316,6 +3316,10 @@ gdescribe-dies
> Common Driver Var(flag_describe_dies) Init(0)
> Add description attributes to some DWARF DIEs that have no name attribute.
>
> +; True if -gtoggle option was already handled.
> +Variable
> +bool gtoggle_used
> +
> gtoggle
> Common Driver Var(flag_gtoggle)
> Toggle debug information generation.
> diff --git a/gcc/opts.c b/gcc/opts.c
> index 3f80fce82bc..ef38b8dbab0 100644
> --- a/gcc/opts.c
> +++ b/gcc/opts.c
> @@ -1375,8 +1375,9 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
> profile_flag = 0;
> }
>
> - if (flag_gtoggle)
> + if (flag_gtoggle && !gtoggle_used)
> {
> + gtoggle_used = true;
> if (debug_info_level == DINFO_LEVEL_NONE)
> {
> debug_info_level = DINFO_LEVEL_NORMAL;
> diff --git a/gcc/testsuite/gcc.dg/pr102955.c b/gcc/testsuite/gcc.dg/pr102955.c
> new file mode 100644
> index 00000000000..de9689edec4
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/pr102955.c
> @@ -0,0 +1,14 @@
> +/* PR debug/102955 */
> +/* { dg-do compile } */
> +/* { dg-options "-g -gtoggle" } */
> +
> +#pragma GCC optimize "0"
> +struct j
> +{
> + explicit j ();
> + ~j ();
> +};
> +void g (void)
> +{
> + new j();
> +}
> --
> 2.33.1
>
More information about the Gcc-patches
mailing list