public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Modify the gcc exit code for warning
@ 2022-05-26  0:35 disquisitiones
  2022-05-27 11:46 ` Stefan Ring
  2022-05-29 18:00 ` disquisitiones
  0 siblings, 2 replies; 4+ messages in thread
From: disquisitiones @ 2022-05-26  0:35 UTC (permalink / raw)
  To: gcc-help

Hi,

I would like to modify the exit code returned by gcc in case of warning
from 0 to some other value, but I'm not familiar with the gcc large source
code base.

Could you provide an hint to which is the file in the gcc source code that
I should modify for modifying the exit value?

Many thanks,

Luca

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

* Re: Modify the gcc exit code for warning
  2022-05-26  0:35 Modify the gcc exit code for warning disquisitiones
@ 2022-05-27 11:46 ` Stefan Ring
  2022-05-29 18:00 ` disquisitiones
  1 sibling, 0 replies; 4+ messages in thread
From: Stefan Ring @ 2022-05-27 11:46 UTC (permalink / raw)
  To: gcc-help

On Thu, May 26, 2022 at 2:35 AM disquisitiones via Gcc-help
<gcc-help@gcc.gnu.org> wrote:
>
> I would like to modify the exit code returned by gcc in case of warning
> from 0 to some other value, but I'm not familiar with the gcc large source
> code base.
>
> Could you provide an hint to which is the file in the gcc source code that
> I should modify for modifying the exit value?

Try to find out where -Werror gets handled. This will lead you to the
correct places.

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

* Re: Modify the gcc exit code for warning
  2022-05-26  0:35 Modify the gcc exit code for warning disquisitiones
  2022-05-27 11:46 ` Stefan Ring
@ 2022-05-29 18:00 ` disquisitiones
  2022-05-30 12:32   ` Jonathan Wakely
  1 sibling, 1 reply; 4+ messages in thread
From: disquisitiones @ 2022-05-29 18:00 UTC (permalink / raw)
  To: gcc-help

Hi and thanks for the hint.

I've determined that the following function defined in gcc/gcc.cc (in
my understanding the source code related to g++)


*/* Determine what the exit code of the driver should be.  */*


*intdriver::get_exit_code () const { ... }*

is responsible for the return value of g++.

The "warningcount" macro evaluates from the diagnostic context the
number of warnings generated in the compilation.

The problem is that the warningcount macro evaluates correctly in
cc1plus but always evaluates to 0 in g++, so it's not
possible to solve the problem modifying only this function.

So I think that the information about the warning count is lost from
the diagnostic context of cc1plus
and the diagnostic context available to g++.

Given that g++ and cc1plus are different applications, I assume that
cc1plus passes the diagnostic context back to g++ via some temporary
file.
And maybe the point could be to make cc1plus update also the warning
count information in this file, so that it will be available to g++.

Am I on the right track? If so, any hint on where cc1plus stores the
diagnostic context in this temporary file for g++?


Thanks,

Luca



On Thu, May 26, 2022 at 2:35 AM disquisitiones via Gcc-help
<gcc-help@gcc.gnu.org> wrote:
>>* I would like to modify the exit code returned by gcc in case of warning
*>* from 0 to some other value, but I'm not familiar with the gcc large source
*>* code base.
*>>* Could you provide an hint to which is the file in the gcc source code that
*>* I should modify for modifying the exit value?
*
Try to find out where -Werror gets handled. This will lead you to the
correct places.


Il giorno gio 26 mag 2022 alle ore 02:35 disquisitiones <
disquisitiones@gmail.com> ha scritto:

> Hi,
>
> I would like to modify the exit code returned by gcc in case of warning
> from 0 to some other value, but I'm not familiar with the gcc large source
> code base.
>
> Could you provide an hint to which is the file in the gcc source code that
> I should modify for modifying the exit value?
>
> Many thanks,
>
> Luca
>

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

* Re: Modify the gcc exit code for warning
  2022-05-29 18:00 ` disquisitiones
@ 2022-05-30 12:32   ` Jonathan Wakely
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Wakely @ 2022-05-30 12:32 UTC (permalink / raw)
  To: disquisitiones; +Cc: gcc-help

On Sun, 29 May 2022, 18:01 disquisitiones via Gcc-help, <
gcc-help@gcc.gnu.org> wrote:

> Hi and thanks for the hint.
>
> I've determined that the following function defined in gcc/gcc.cc (in
> my understanding the source code related to g++)
>
>
> */* Determine what the exit code of the driver should be.  */*
>
>
> *intdriver::get_exit_code () const { ... }*
>
> is responsible for the return value of g++.
>
> The "warningcount" macro evaluates from the diagnostic context the
> number of warnings generated in the compilation.
>
> The problem is that the warningcount macro evaluates correctly in
> cc1plus but always evaluates to 0 in g++, so it's not
> possible to solve the problem modifying only this function.
>
> So I think that the information about the warning count is lost from
> the diagnostic context of cc1plus
> and the diagnostic context available to g++.
>
> Given that g++ and cc1plus are different applications, I assume that
> cc1plus passes the diagnostic context back to g++ via some temporary
> file.
>

No, the g++ driver spawns a child process to run the cc1plus program, then
the parent waits for the child to exit and gets the exit status from the OS.


And maybe the point could be to make cc1plus update also the warning
> count information in this file, so that it will be available to g++.
>

There is no file.


> Am I on the right track? If so, any hint on where cc1plus stores the
> diagnostic context in this temporary file for g++?
>


Learn about how the fork, exec, and wait functions work. The exit status of
a child process is available to the parent process.



>
>

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

end of thread, other threads:[~2022-05-30 12:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-26  0:35 Modify the gcc exit code for warning disquisitiones
2022-05-27 11:46 ` Stefan Ring
2022-05-29 18:00 ` disquisitiones
2022-05-30 12:32   ` Jonathan Wakely

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