public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug preprocessor/100125] New: -Wunused-macros generated while should be ignored; if undef is seen?
@ 2021-04-16 20:30 gcc at behdad dot org
  2022-06-29 16:08 ` [Bug preprocessor/100125] " lhyatt at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: gcc at behdad dot org @ 2021-04-16 20:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100125

            Bug ID: 100125
           Summary: -Wunused-macros generated while should be ignored; if
                    undef is seen?
           Product: gcc
           Version: 10.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: preprocessor
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc at behdad dot org
  Target Milestone: ---

We're facing this in HarfBuzz. I narrowed down the bug to this:

Works:

```c++
#pragma GCC diagnostic ignored "-Wunused-macros"

#define A B
```

$ g++ a.cc -c -Wunused-macros

(fine; no warning)

But if I add an `undef` to that file:

```c++
#pragma GCC diagnostic ignored "-Wunused-macros"

#define A B

#undef A
```

$ g++ a.cc -c -Wunused-macros
a.cc:3: warning: macros "A" is not used [-Wunused-macros]
    3 | #define A B

Am I missing something?

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

* [Bug preprocessor/100125] -Wunused-macros generated while should be ignored; if undef is seen?
  2021-04-16 20:30 [Bug preprocessor/100125] New: -Wunused-macros generated while should be ignored; if undef is seen? gcc at behdad dot org
@ 2022-06-29 16:08 ` lhyatt at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: lhyatt at gcc dot gnu.org @ 2022-06-29 16:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100125

Lewis Hyatt <lhyatt at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lhyatt at gcc dot gnu.org
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #1 from Lewis Hyatt <lhyatt at gcc dot gnu.org> ---
The reason it works without #undef is that cpp_finish() is called late by the
C++ frontend, after it has processed everything including pragmas. With #undef,
the warning is generated immediately by libcpp and so is subject to PR53431.
There is a patch waiting for review that will resolve it.

*** This bug has been marked as a duplicate of bug 53431 ***

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

end of thread, other threads:[~2022-06-29 16:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-16 20:30 [Bug preprocessor/100125] New: -Wunused-macros generated while should be ignored; if undef is seen? gcc at behdad dot org
2022-06-29 16:08 ` [Bug preprocessor/100125] " 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).