diff mbox series

Fix error recovery in toplev::finalize.

Message ID 5d9fe598-1f3d-a756-2eab-d287cda5f46e@suse.cz
State New
Headers show
Series Fix error recovery in toplev::finalize. | expand

Commit Message

Martin Liška Feb. 28, 2022, 11:49 a.m. UTC
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

Comments

Richard Biener Feb. 28, 2022, 12:55 p.m. UTC | #1
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
>
David Malcolm Feb. 28, 2022, 3:30 p.m. UTC | #2
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" } */
> +};
Richard Biener Feb. 28, 2022, 5:47 p.m. UTC | #3
> 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" } */
>> +};
> 
>
David Malcolm Feb. 28, 2022, 7:21 p.m. UTC | #4
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" } */
> > > +};
> > 
> > 
>
diff mbox series

Patch

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" } */
+};