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

Reply via email to