* "gcc -E" does not honor #pragma
@ 2020-09-13 18:18 Chelsea Meyers
2020-09-14 12:46 ` Nathan Sidwell
0 siblings, 1 reply; 2+ messages in thread
From: Chelsea Meyers @ 2020-09-13 18:18 UTC (permalink / raw)
To: gcc
Hi,
I'm new to contributing to GCC, so I looked for issues in Bugzilla with the
keyword "easyhack" that looked comprehensible to me, and found bug 53920: "'gcc
-E' does not honor #pragma GCC diagnostic ignored '-Wunused-macro'". I
verified using a fresh build of gcc from the master branch that when "gcc
-E -Wunused-macros" is used to invoke the preprocessor on the following two
lines, a warning is given for the unused FOO macro despite the #pragma
directive:
#pragma GCC diagnostic ignored "-Wunused-macros"
#define FOO
My impression is that the preprocessor is ignoring the content of pragma
diagnostics when invoked with -E, and that the proposed change is to add
support for handling pragma diagnostics for this use case. The Bugzilla
entry for this issue hasn't been commented on since 2013, so I want to make
sure this is actually a good thing to work on. Might there be a reason why
support for handling pragma diagnostics is missing from c-ppoutput.c?
Thanks,
Chelsea Meyers
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: "gcc -E" does not honor #pragma
2020-09-13 18:18 "gcc -E" does not honor #pragma Chelsea Meyers
@ 2020-09-14 12:46 ` Nathan Sidwell
0 siblings, 0 replies; 2+ messages in thread
From: Nathan Sidwell @ 2020-09-14 12:46 UTC (permalink / raw)
To: Chelsea Meyers, gcc
On 9/13/20 2:18 PM, Chelsea Meyers via Gcc wrote:
> Hi,
>
> I'm new to contributing to GCC, so I looked for issues in Bugzilla with the
> keyword "easyhack" that looked comprehensible to me, and found bug 53920: "'gcc
> -E' does not honor #pragma GCC diagnostic ignored '-Wunused-macro'". I
> verified using a fresh build of gcc from the master branch that when "gcc
> -E -Wunused-macros" is used to invoke the preprocessor on the following two
> lines, a warning is given for the unused FOO macro despite the #pragma
> directive:
>
> #pragma GCC diagnostic ignored "-Wunused-macros"
> #define FOO
>
> My impression is that the preprocessor is ignoring the content of pragma
> diagnostics when invoked with -E, and that the proposed change is to add
> support for handling pragma diagnostics for this use case. The Bugzilla
> entry for this issue hasn't been commented on since 2013, so I want to make
> sure this is actually a good thing to work on. Might there be a reason why
> support for handling pragma diagnostics is missing from c-ppoutput.c?
I'm not aware of a reason. IIUC in -E pragmas go through to the cpp
output, as they're needed by the compiler proper. However, this is a
case of a preprocessor warning, which I guess got forgotten about. I
suppose diagnostic options should both be propagated into the output
/and/ acted upon?
Don't forget that '-E -fdirectives-only' will want to defer macro
checking until proper compilation, and in general would be difficult to
get right, considering
#define bob 1
#if bob
....
#else
....
#endif
where 'bob' is only used during the preprocessing.
nathan
--
Nathan Sidwell
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-09-14 12:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-13 18:18 "gcc -E" does not honor #pragma Chelsea Meyers
2020-09-14 12:46 ` Nathan Sidwell
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).