public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug preprocessor/53920] New: "gcc -E" does not honor #pragma GCC diagnostic ignored "-Wunused-macro"
@ 2012-07-10 17:50 naesten at gmail dot com
2012-07-10 19:07 ` [Bug preprocessor/53920] " naesten at gmail dot com
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: naesten at gmail dot com @ 2012-07-10 17:50 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53920
Bug #: 53920
Summary: "gcc -E" does not honor #pragma GCC diagnostic ignored
"-Wunused-macro"
Classification: Unclassified
Product: gcc
Version: 4.7.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: preprocessor
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: naesten@gmail.com
iMac:gcc-bugs user$ cat cpp-pragma-GCC-diagnostic.c
#pragma GCC diagnostic ignored "-Wunused-macros"
#define FOO
iMac:gcc-bugs user$ gcc-fsf-4.7 -Wunused-macros cpp-pragma-GCC-diagnostic.c -E
# 1 "cpp-pragma-GCC-diagnostic.c"
# 1 "<command-line>"
# 1 "cpp-pragma-GCC-diagnostic.c"
#pragma GCC diagnostic ignored "-Wunused-macros"
cpp-pragma-GCC-diagnostic.c:3:0: warning: macro "FOO" is not used
[-Wunused-macros]
iMac:gcc-bugs user$ gcc-fsf-4.7 --version
gcc-fsf-4.7 (GCC) 4.7.1
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug preprocessor/53920] "gcc -E" does not honor #pragma GCC diagnostic ignored "-Wunused-macro"
2012-07-10 17:50 [Bug preprocessor/53920] New: "gcc -E" does not honor #pragma GCC diagnostic ignored "-Wunused-macro" naesten at gmail dot com
@ 2012-07-10 19:07 ` naesten at gmail dot com
2013-11-16 20:41 ` manu at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: naesten at gmail dot com @ 2012-07-10 19:07 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53920
--- Comment #1 from Samuel Bronson <naesten at gmail dot com> 2012-07-10 19:07:26 UTC ---
Oh, I suppose I should mention that I ran into this because I was using ccache
to compile Emacs with --enable-gcc-warnings, and by default ccache runs the
preprocessor and the compiler in separate passes (so that it can skip the
compilation proper if it has cached output for a given preprocessor output),
and then pastes together the diagnostic output from the two passes.
(Thankfully, setting the environment variable CCACHE_CPP2 causes ccache to
throw out the preprocessor output after hashing, which is a quite effective
workaround for this sort of thing, though preprocessing the source twice does
make things a bit slower on cache misses.)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug preprocessor/53920] "gcc -E" does not honor #pragma GCC diagnostic ignored "-Wunused-macro"
2012-07-10 17:50 [Bug preprocessor/53920] New: "gcc -E" does not honor #pragma GCC diagnostic ignored "-Wunused-macro" naesten at gmail dot com
2012-07-10 19:07 ` [Bug preprocessor/53920] " naesten at gmail dot com
@ 2013-11-16 20:41 ` manu at gcc dot gnu.org
2021-05-27 13:15 ` markus at oberhumer dot com
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: manu at gcc dot gnu.org @ 2013-11-16 20:41 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53920
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-11-16
CC| |manu at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #2 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
The C FE normally preprocesses and parses concurrently. But -E (only
preprocessing) is handled by a different function in
c-ppoutput.c(scan_translation_unit), which does not handle pragma diagnostics.
So someone would need to add that handling there. Probably not difficult. I
think one just needs to call c_invoke_pragma handler when a pragma diagnostic
is detected, but someone has to try and flush out the details. If you need help
just ask.
>From gcc-bugs-return-434773-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Nov 16 20:44:47 2013
Return-Path: <gcc-bugs-return-434773-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 2857 invoked by alias); 16 Nov 2013 20:44:47 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 2815 invoked by uid 48); 16 Nov 2013 20:44:44 -0000
From: "manu at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/48914] #pragma GCC diagnostic ignored "-Wc++0x-compat" doesn't work
Date: Sat, 16 Nov 2013 20:44:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.6.1
X-Bugzilla-Keywords: diagnostic
X-Bugzilla-Severity: normal
X-Bugzilla-Who: manu at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-48914-4-rVDXbUKR5K@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-48914-4@http.gcc.gnu.org/bugzilla/>
References: <bug-48914-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-11/txt/msg01550.txt.bz2
Content-length: 235
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48914
--- Comment #9 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
If this warning is given by the preprocessor during lexing, then this is a dup
of bug 53431.
>From gcc-bugs-return-434774-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Nov 16 21:45:06 2013
Return-Path: <gcc-bugs-return-434774-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 24756 invoked by alias); 16 Nov 2013 21:45:05 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 24642 invoked by uid 55); 16 Nov 2013 21:45:00 -0000
From: "pault at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/58771] [4.7/4.8/4.9 Regression] ICE in transfer_expr, at fortran/trans-io.c:2164
Date: Sat, 16 Nov 2013 21:45:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: fortran
X-Bugzilla-Version: 4.8.2
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: pault at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: pault at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-58771-4-9RXIflqeLm@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-58771-4@http.gcc.gnu.org/bugzilla/>
References: <bug-58771-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-11/txt/msg01551.txt.bz2
Content-length: 827
http://gcc.gnu.org/bugzilla/show_bug.cgi?idX771
--- Comment #5 from Paul Thomas <pault at gcc dot gnu.org> ---
Author: pault
Date: Sat Nov 16 21:44:56 2013
New Revision: 204907
URL: http://gcc.gnu.org/viewcvs?rev 4907&root=gcc&view=rev
Log:
2013-11-16 Paul Thomas <pault@gcc.gnu.org>
PR fortran/58771
* trans-io.c (transfer_expr): If the backend_decl for a derived
type is missing, build it with gfc_typenode_for_spec.
2013-11-16 Paul Thomas <pault@gcc.gnu.org>
PR fortran/58771
* gfortran.dg/derived_external_function_1.f90 : New test
Added:
branches/gcc-4_8-branch/gcc/testsuite/gfortran.dg/derived_external_function_1.f90
Modified:
branches/gcc-4_8-branch/gcc/fortran/ChangeLog
branches/gcc-4_8-branch/gcc/fortran/trans-io.c
branches/gcc-4_8-branch/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug preprocessor/53920] "gcc -E" does not honor #pragma GCC diagnostic ignored "-Wunused-macro"
2012-07-10 17:50 [Bug preprocessor/53920] New: "gcc -E" does not honor #pragma GCC diagnostic ignored "-Wunused-macro" naesten at gmail dot com
2012-07-10 19:07 ` [Bug preprocessor/53920] " naesten at gmail dot com
2013-11-16 20:41 ` manu at gcc dot gnu.org
@ 2021-05-27 13:15 ` markus at oberhumer dot com
2022-06-17 18:57 ` lhyatt at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: markus at oberhumer dot com @ 2021-05-27 13:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53920
Markus F.X.J. Oberhumer <markus at oberhumer dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |markus at oberhumer dot com
--- Comment #3 from Markus F.X.J. Oberhumer <markus at oberhumer dot com> ---
Still a problem in 2021 with gcc-11.1.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug preprocessor/53920] "gcc -E" does not honor #pragma GCC diagnostic ignored "-Wunused-macro"
2012-07-10 17:50 [Bug preprocessor/53920] New: "gcc -E" does not honor #pragma GCC diagnostic ignored "-Wunused-macro" naesten at gmail dot com
` (2 preceding siblings ...)
2021-05-27 13:15 ` markus at oberhumer dot com
@ 2022-06-17 18:57 ` lhyatt at gcc dot gnu.org
2022-06-17 18:59 ` lhyatt at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: lhyatt at gcc dot gnu.org @ 2022-06-17 18:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53920
--- Comment #4 from Lewis Hyatt <lhyatt at gcc dot gnu.org> ---
*** Bug 64698 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug preprocessor/53920] "gcc -E" does not honor #pragma GCC diagnostic ignored "-Wunused-macro"
2012-07-10 17:50 [Bug preprocessor/53920] New: "gcc -E" does not honor #pragma GCC diagnostic ignored "-Wunused-macro" naesten at gmail dot com
` (3 preceding siblings ...)
2022-06-17 18:57 ` lhyatt at gcc dot gnu.org
@ 2022-06-17 18:59 ` lhyatt at gcc dot gnu.org
2022-07-06 19:40 ` cvs-commit at gcc dot gnu.org
2022-07-06 19:44 ` lhyatt at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: lhyatt at gcc dot gnu.org @ 2022-06-17 18:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53920
Lewis Hyatt <lhyatt at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |lhyatt at gcc dot gnu.org
--- Comment #5 from Lewis Hyatt <lhyatt at gcc dot gnu.org> ---
I have a patch awaiting review to fix PR53431 which would fix this one too.
https://gcc.gnu.org/pipermail/gcc-patches/2022-May/595556.html
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug preprocessor/53920] "gcc -E" does not honor #pragma GCC diagnostic ignored "-Wunused-macro"
2012-07-10 17:50 [Bug preprocessor/53920] New: "gcc -E" does not honor #pragma GCC diagnostic ignored "-Wunused-macro" naesten at gmail dot com
` (4 preceding siblings ...)
2022-06-17 18:59 ` lhyatt at gcc dot gnu.org
@ 2022-07-06 19:40 ` cvs-commit at gcc dot gnu.org
2022-07-06 19:44 ` lhyatt at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-07-06 19:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53920
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Lewis Hyatt <lhyatt@gcc.gnu.org>:
https://gcc.gnu.org/g:e46f4d7430c5210465791603735ab219ef263c51
commit r13-1544-ge46f4d7430c5210465791603735ab219ef263c51
Author: Lewis Hyatt <lhyatt@gmail.com>
Date: Tue Jul 5 17:15:28 2022 -0400
diagnostics: Honor #pragma GCC diagnostic in the preprocessor [PR53431]
As discussed on PR c++/53431, currently, "#pragma GCC diagnostic" does
not always take effect for diagnostics generated by libcpp. The reason
is that libcpp itself does not interpret this pragma and only sends it on
to the frontend, hence the pragma is only honored if the frontend
arranges for it. The C frontend does process the pragma immediately
(more or less) after seeing the token, so things work fine there. The PR
points out that it doesn't work for C++, because the C++ frontend
doesn't handle anything until it has read all the tokens from
libcpp. The underlying problem is not C++-specific, though, and for
instance, gcc -E has the same issue.
This commit fixes the PR by adding the concept of an early pragma handler
that
can be registered by frontends, which gives them a chance to process
diagnostic pragmas from libcpp before it is too late for them to take
effect. The C++ and preprocess-only frontends are modified to use early
pragmas and correct the behavior.
gcc/c-family/ChangeLog:
PR preprocessor/53920
PR c++/53431
* c-common.cc (c_option_is_from_cpp_diagnostics): New function.
* c-common.h (c_option_is_from_cpp_diagnostics): Declare.
(c_pp_stream_token): Declare.
* c-ppoutput.cc (init_pp_output): Refactor logic about skipping
pragmas to...
(should_output_pragmas): ...here. New function.
(token_streamer::stream): Support handling early pragmas.
(do_line_change): Likewise.
(c_pp_stream_token): New function.
* c-pragma.cc (struct pragma_diagnostic_data): New helper class.
(pragma_diagnostic_lex_normal): New function. Moved logic for
interpreting GCC diagnostic pragmas here.
(pragma_diagnostic_lex_pp): New function for parsing diagnostic
pragmas
directly from libcpp.
(handle_pragma_diagnostic): Refactor into helper function...
(handle_pragma_diagnostic_impl): ...here. New function.
(handle_pragma_diagnostic_early): New function.
(handle_pragma_diagnostic_early_pp): New function.
(struct pragma_ns_name): Renamed to...
(struct pragma_pp_data): ...this. Add new "early_handler" member.
(c_register_pragma_1): Support early pragmas in the preprocessor.
(c_register_pragma_with_early_handler): New function.
(c_register_pragma): Support the new early handlers in struct
internal_pragma_handler.
(c_register_pragma_with_data): Likewise.
(c_register_pragma_with_expansion): Likewise.
(c_register_pragma_with_expansion_and_data): Likewise.
(c_invoke_early_pragma_handler): New function.
(c_pp_invoke_early_pragma_handler): New function.
(init_pragma): Add early pragma support for diagnostic pragmas.
* c-pragma.h (struct internal_pragma_handler): Add new early
handler
members.
(c_register_pragma_with_early_handler): Declare.
(c_invoke_early_pragma_handler): Declare.
(c_pp_invoke_early_pragma_handler): Declare.
gcc/cp/ChangeLog:
PR c++/53431
* parser.cc (cp_parser_pragma_kind): Move earlier in the file.
(cp_lexer_handle_early_pragma): New function.
(cp_lexer_new_main): Support parsing and handling early pragmas.
(c_parse_file): Adapt to changes in cp_lexer_new_main.
gcc/testsuite/ChangeLog:
PR preprocessor/53920
PR c++/53431
* c-c++-common/pragma-diag-11.c: New test.
* c-c++-common/pragma-diag-12.c: New test.
* c-c++-common/pragma-diag-13.c: New test.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug preprocessor/53920] "gcc -E" does not honor #pragma GCC diagnostic ignored "-Wunused-macro"
2012-07-10 17:50 [Bug preprocessor/53920] New: "gcc -E" does not honor #pragma GCC diagnostic ignored "-Wunused-macro" naesten at gmail dot com
` (5 preceding siblings ...)
2022-07-06 19:40 ` cvs-commit at gcc dot gnu.org
@ 2022-07-06 19:44 ` lhyatt at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: lhyatt at gcc dot gnu.org @ 2022-07-06 19:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53920
Lewis Hyatt <lhyatt at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #7 from Lewis Hyatt <lhyatt at gcc dot gnu.org> ---
Fixed for GCC 13.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-07-06 19:44 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-10 17:50 [Bug preprocessor/53920] New: "gcc -E" does not honor #pragma GCC diagnostic ignored "-Wunused-macro" naesten at gmail dot com
2012-07-10 19:07 ` [Bug preprocessor/53920] " naesten at gmail dot com
2013-11-16 20:41 ` manu at gcc dot gnu.org
2021-05-27 13:15 ` markus at oberhumer dot com
2022-06-17 18:57 ` lhyatt at gcc dot gnu.org
2022-06-17 18:59 ` lhyatt at gcc dot gnu.org
2022-07-06 19:40 ` cvs-commit at gcc dot gnu.org
2022-07-06 19:44 ` lhyatt at gcc dot gnu.org
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).