public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Record that -gtoggle is already used in gcc_options.
@ 2021-11-02 14:10 Martin Liška
  2021-11-02 14:33 ` Richard Biener
  2021-11-02 22:49 ` Andrew Pinski
  0 siblings, 2 replies; 10+ messages in thread
From: Martin Liška @ 2021-11-02 14:10 UTC (permalink / raw)
  To: gcc-patches

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-11-05 12:01 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-02 14:10 [PATCH] Record that -gtoggle is already used in gcc_options Martin Liška
2021-11-02 14:33 ` Richard Biener
2021-11-02 15:11   ` Martin Liška
2021-11-02 16:45     ` Richard Biener
2021-11-04 12:51       ` Martin Liška
2021-11-04 13:09         ` Richard Biener
2021-11-04 15:11           ` Martin Liška
2021-11-05 10:23             ` Richard Biener
2021-11-05 12:01               ` Martin Liška
2021-11-02 22:49 ` Andrew Pinski

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).