public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix error recovery in toplev::finalize.
@ 2022-02-28 11:49 Martin Liška
  2022-02-28 12:55 ` Richard Biener
  2022-02-28 15:30 ` David Malcolm
  0 siblings, 2 replies; 5+ messages in thread
From: Martin Liška @ 2022-02-28 11:49 UTC (permalink / raw)
  To: gcc-patches

Use flag_checking instead of CHECKING_P
and run toplev::finalize only if there is not error seen.

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

Ready to be installed?
Thanks,
Martin

	PR ipa/104648

gcc/ChangeLog:

	* main.cc (main): Use flag_checking instead of CHECKING_P
	and run toplev::finalize only if there is not error seen.

gcc/testsuite/ChangeLog:

	* g++.dg/pr104648.C: New test.
---
  gcc/main.cc                     | 6 +++---
  gcc/testsuite/g++.dg/pr104648.C | 9 +++++++++
  2 files changed, 12 insertions(+), 3 deletions(-)
  create mode 100644 gcc/testsuite/g++.dg/pr104648.C

diff --git a/gcc/main.cc b/gcc/main.cc
index f9dd6b2af58..4ba28b7de53 100644
--- a/gcc/main.cc
+++ b/gcc/main.cc
@@ -37,9 +37,9 @@ main (int argc, char **argv)
  		 true /* init_signals */);
  
    int r = toplev.main (argc, argv);
-#if CHECKING_P
-  toplev.finalize ();
-#endif
+
+  if (flag_checking && !seen_error ())
+    toplev.finalize ();
  
    return r;
  }
diff --git a/gcc/testsuite/g++.dg/pr104648.C b/gcc/testsuite/g++.dg/pr104648.C
new file mode 100644
index 00000000000..b8b7c2864cf
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr104648.C
@@ -0,0 +1,9 @@
+// { dg-do compile }
+// { dg-options "-fvtable-verify=preinit" }
+
+struct A {};
+struct B : virtual A
+{
+  B () {};
+  B () {}; /* { dg-error "cannot be overloaded with" } */
+};
-- 
2.35.1


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

* Re: [PATCH] Fix error recovery in toplev::finalize.
  2022-02-28 11:49 [PATCH] Fix error recovery in toplev::finalize Martin Liška
@ 2022-02-28 12:55 ` Richard Biener
  2022-02-28 15:30 ` David Malcolm
  1 sibling, 0 replies; 5+ messages in thread
From: Richard Biener @ 2022-02-28 12:55 UTC (permalink / raw)
  To: Martin Liška; +Cc: GCC Patches

On Mon, Feb 28, 2022 at 12:49 PM Martin Liška <mliska@suse.cz> wrote:
>
> Use flag_checking instead of CHECKING_P
> and run toplev::finalize only if there is not error seen.
>
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>
> Ready to be installed?

OK.

Richard.

> Thanks,
> Martin
>
>         PR ipa/104648
>
> gcc/ChangeLog:
>
>         * main.cc (main): Use flag_checking instead of CHECKING_P
>         and run toplev::finalize only if there is not error seen.
>
> gcc/testsuite/ChangeLog:
>
>         * g++.dg/pr104648.C: New test.
> ---
>   gcc/main.cc                     | 6 +++---
>   gcc/testsuite/g++.dg/pr104648.C | 9 +++++++++
>   2 files changed, 12 insertions(+), 3 deletions(-)
>   create mode 100644 gcc/testsuite/g++.dg/pr104648.C
>
> diff --git a/gcc/main.cc b/gcc/main.cc
> index f9dd6b2af58..4ba28b7de53 100644
> --- a/gcc/main.cc
> +++ b/gcc/main.cc
> @@ -37,9 +37,9 @@ main (int argc, char **argv)
>                  true /* init_signals */);
>
>     int r = toplev.main (argc, argv);
> -#if CHECKING_P
> -  toplev.finalize ();
> -#endif
> +
> +  if (flag_checking && !seen_error ())
> +    toplev.finalize ();
>
>     return r;
>   }
> diff --git a/gcc/testsuite/g++.dg/pr104648.C b/gcc/testsuite/g++.dg/pr104648.C
> new file mode 100644
> index 00000000000..b8b7c2864cf
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/pr104648.C
> @@ -0,0 +1,9 @@
> +// { dg-do compile }
> +// { dg-options "-fvtable-verify=preinit" }
> +
> +struct A {};
> +struct B : virtual A
> +{
> +  B () {};
> +  B () {}; /* { dg-error "cannot be overloaded with" } */
> +};
> --
> 2.35.1
>

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

* Re: [PATCH] Fix error recovery in toplev::finalize.
  2022-02-28 11:49 [PATCH] Fix error recovery in toplev::finalize Martin Liška
  2022-02-28 12:55 ` Richard Biener
@ 2022-02-28 15:30 ` David Malcolm
  2022-02-28 17:47   ` Richard Biener
  1 sibling, 1 reply; 5+ messages in thread
From: David Malcolm @ 2022-02-28 15:30 UTC (permalink / raw)
  To: Martin Liška, gcc-patches

On Mon, 2022-02-28 at 12:49 +0100, Martin Liška wrote:
> Use flag_checking instead of CHECKING_P
> and run toplev::finalize only if there is not error seen.
> 
> Patch can bootstrap on x86_64-linux-gnu and survives regression
> tests.

Did the testing include the libgccjit test suite?  ("jit" is not in --
enable-languages=all)

> 
> Ready to be installed?

I'm not keen on this change; IIRC it's valid to attempt to compile a
gcc_jit_context that fails with an error, and then to attempt a
different gcc_jit_context that succeeds, within the same process.  If
I'm reading the patch right, the patch as written removes this cleanup,
which would thwart that.

I can try to cook up a testcase for the above use case.

Is there another way to fix PR 104648?

Thanks
Dave



> Thanks,
> Martin
> 
>         PR ipa/104648
> 
> gcc/ChangeLog:
> 
>         * main.cc (main): Use flag_checking instead of CHECKING_P
>         and run toplev::finalize only if there is not error seen.
> 
> gcc/testsuite/ChangeLog:
> 
>         * g++.dg/pr104648.C: New test.
> ---
>   gcc/main.cc                     | 6 +++---
>   gcc/testsuite/g++.dg/pr104648.C | 9 +++++++++
>   2 files changed, 12 insertions(+), 3 deletions(-)
>   create mode 100644 gcc/testsuite/g++.dg/pr104648.C
> 
> diff --git a/gcc/main.cc b/gcc/main.cc
> index f9dd6b2af58..4ba28b7de53 100644
> --- a/gcc/main.cc
> +++ b/gcc/main.cc
> @@ -37,9 +37,9 @@ main (int argc, char **argv)
>                  true /* init_signals */);
>   
>     int r = toplev.main (argc, argv);
> -#if CHECKING_P
> -  toplev.finalize ();
> -#endif
> +
> +  if (flag_checking && !seen_error ())
> +    toplev.finalize ();
>   
>     return r;
>   }
> diff --git a/gcc/testsuite/g++.dg/pr104648.C
> b/gcc/testsuite/g++.dg/pr104648.C
> new file mode 100644
> index 00000000000..b8b7c2864cf
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/pr104648.C
> @@ -0,0 +1,9 @@
> +// { dg-do compile }
> +// { dg-options "-fvtable-verify=preinit" }
> +
> +struct A {};
> +struct B : virtual A
> +{
> +  B () {};
> +  B () {}; /* { dg-error "cannot be overloaded with" } */
> +};



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

* Re: [PATCH] Fix error recovery in toplev::finalize.
  2022-02-28 15:30 ` David Malcolm
@ 2022-02-28 17:47   ` Richard Biener
  2022-02-28 19:21     ` David Malcolm
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Biener @ 2022-02-28 17:47 UTC (permalink / raw)
  To: David Malcolm; +Cc: Martin Liška, gcc-patches



> Am 28.02.2022 um 16:31 schrieb David Malcolm via Gcc-patches <gcc-patches@gcc.gnu.org>:
> 
> On Mon, 2022-02-28 at 12:49 +0100, Martin Liška wrote:
>> Use flag_checking instead of CHECKING_P
>> and run toplev::finalize only if there is not error seen.
>> 
>> Patch can bootstrap on x86_64-linux-gnu and survives regression
>> tests.
> 
> Did the testing include the libgccjit test suite?  ("jit" is not in --
> enable-languages=all)
> 
>> 
>> Ready to be installed?
> 
> I'm not keen on this change; IIRC it's valid to attempt to compile a
> gcc_jit_context that fails with an error, and then to attempt a
> different gcc_jit_context that succeeds, within the same process.  If
> I'm reading the patch right, the patch as written removes this cleanup,
> which would thwart that.
> 
> I can try to cook up a testcase for the above use case.
> 
> Is there another way to fix PR 104648?

The function was never called on a release checking build btw.  Is there something like flag_jit one could test?

> Thanks
> Dave
> 
> 
> 
>> Thanks,
>> Martin
>> 
>>         PR ipa/104648
>> 
>> gcc/ChangeLog:
>> 
>>         * main.cc (main): Use flag_checking instead of CHECKING_P
>>         and run toplev::finalize only if there is not error seen.
>> 
>> gcc/testsuite/ChangeLog:
>> 
>>         * g++.dg/pr104648.C: New test.
>> ---
>>   gcc/main.cc                     | 6 +++---
>>   gcc/testsuite/g++.dg/pr104648.C | 9 +++++++++
>>   2 files changed, 12 insertions(+), 3 deletions(-)
>>   create mode 100644 gcc/testsuite/g++.dg/pr104648.C
>> 
>> diff --git a/gcc/main.cc b/gcc/main.cc
>> index f9dd6b2af58..4ba28b7de53 100644
>> --- a/gcc/main.cc
>> +++ b/gcc/main.cc
>> @@ -37,9 +37,9 @@ main (int argc, char **argv)
>>                  true /* init_signals */);
>>   
>>     int r = toplev.main (argc, argv);
>> -#if CHECKING_P
>> -  toplev.finalize ();
>> -#endif
>> +
>> +  if (flag_checking && !seen_error ())
>> +    toplev.finalize ();
>>   
>>     return r;
>>   }
>> diff --git a/gcc/testsuite/g++.dg/pr104648.C
>> b/gcc/testsuite/g++.dg/pr104648.C
>> new file mode 100644
>> index 00000000000..b8b7c2864cf
>> --- /dev/null
>> +++ b/gcc/testsuite/g++.dg/pr104648.C
>> @@ -0,0 +1,9 @@
>> +// { dg-do compile }
>> +// { dg-options "-fvtable-verify=preinit" }
>> +
>> +struct A {};
>> +struct B : virtual A
>> +{
>> +  B () {};
>> +  B () {}; /* { dg-error "cannot be overloaded with" } */
>> +};
> 
> 

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

* Re: [PATCH] Fix error recovery in toplev::finalize.
  2022-02-28 17:47   ` Richard Biener
@ 2022-02-28 19:21     ` David Malcolm
  0 siblings, 0 replies; 5+ messages in thread
From: David Malcolm @ 2022-02-28 19:21 UTC (permalink / raw)
  To: Richard Biener; +Cc: Martin Liška, gcc-patches

On Mon, 2022-02-28 at 18:47 +0100, Richard Biener wrote:
> 
> 
> > Am 28.02.2022 um 16:31 schrieb David Malcolm via Gcc-patches <
> > gcc-patches@gcc.gnu.org>:
> > 
> > On Mon, 2022-02-28 at 12:49 +0100, Martin Liška wrote:
> > > Use flag_checking instead of CHECKING_P
> > > and run toplev::finalize only if there is not error seen.
> > > 
> > > Patch can bootstrap on x86_64-linux-gnu and survives regression
> > > tests.
> > 
> > Did the testing include the libgccjit test suite?  ("jit" is not in -
> > -
> > enable-languages=all)
> > 
> > > 
> > > Ready to be installed?
> > 
> > I'm not keen on this change; IIRC it's valid to attempt to compile a
> > gcc_jit_context that fails with an error, and then to attempt a
> > different gcc_jit_context that succeeds, within the same process.  If
> > I'm reading the patch right, the patch as written removes this
> > cleanup,
> > which would thwart that.
> > 
> > I can try to cook up a testcase for the above use case.
> > 
> > Is there another way to fix PR 104648?
> 
> The function was never called on a release checking build btw.  Is
> there something like flag_jit one could test?

Sorry, I was misremembering - with libgccjit, toplev.finalize () is
called from playback::context::compile in jit/jit-playback.cc, not here
from main.cc

So this cleanup would still be called for libgccjit, and the patch
doesn't affect that.

Looking at PR ipa/104648, it seems to only be triggerable from the C++
frontend, so can't affect libgccjit.

So I think the patch is OK; sorry for the noise.
Dave


> 
> > Thanks
> > Dave
> > 
> > 
> > 
> > > Thanks,
> > > Martin
> > > 
> > >         PR ipa/104648
> > > 
> > > gcc/ChangeLog:
> > > 
> > >         * main.cc (main): Use flag_checking instead of CHECKING_P
> > >         and run toplev::finalize only if there is not error seen.
> > > 
> > > gcc/testsuite/ChangeLog:
> > > 
> > >         * g++.dg/pr104648.C: New test.
> > > ---
> > >   gcc/main.cc                     | 6 +++---
> > >   gcc/testsuite/g++.dg/pr104648.C | 9 +++++++++
> > >   2 files changed, 12 insertions(+), 3 deletions(-)
> > >   create mode 100644 gcc/testsuite/g++.dg/pr104648.C
> > > 
> > > diff --git a/gcc/main.cc b/gcc/main.cc
> > > index f9dd6b2af58..4ba28b7de53 100644
> > > --- a/gcc/main.cc
> > > +++ b/gcc/main.cc
> > > @@ -37,9 +37,9 @@ main (int argc, char **argv)
> > >                  true /* init_signals */);
> > >   
> > >     int r = toplev.main (argc, argv);
> > > -#if CHECKING_P
> > > -  toplev.finalize ();
> > > -#endif
> > > +
> > > +  if (flag_checking && !seen_error ())
> > > +    toplev.finalize ();
> > >   
> > >     return r;
> > >   }
> > > diff --git a/gcc/testsuite/g++.dg/pr104648.C
> > > b/gcc/testsuite/g++.dg/pr104648.C
> > > new file mode 100644
> > > index 00000000000..b8b7c2864cf
> > > --- /dev/null
> > > +++ b/gcc/testsuite/g++.dg/pr104648.C
> > > @@ -0,0 +1,9 @@
> > > +// { dg-do compile }
> > > +// { dg-options "-fvtable-verify=preinit" }
> > > +
> > > +struct A {};
> > > +struct B : virtual A
> > > +{
> > > +  B () {};
> > > +  B () {}; /* { dg-error "cannot be overloaded with" } */
> > > +};
> > 
> > 
> 



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

end of thread, other threads:[~2022-02-28 19:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-28 11:49 [PATCH] Fix error recovery in toplev::finalize Martin Liška
2022-02-28 12:55 ` Richard Biener
2022-02-28 15:30 ` David Malcolm
2022-02-28 17:47   ` Richard Biener
2022-02-28 19:21     ` David Malcolm

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