public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug preprocessor/109994] New: Issue a diagnostic when a C++ file defines a macro that hides a keyword
@ 2023-05-26 16:31 redi at gcc dot gnu.org
  2023-05-26 16:34 ` [Bug preprocessor/109994] " mpolacek at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2023-05-26 16:31 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109994
           Summary: Issue a diagnostic when a C++ file defines a macro
                    that hides a keyword
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: enhancement
          Priority: P3
         Component: preprocessor
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

The C++ standard says this is undefined:

#define new foo

It might be nice if the preprocessor had a warning about it.


[macro.names]
A translation unit shall not #define or #undef names lexically identical to
keywords, to the identifiers listed in Table 4, or to the attribute-tokens
described in 9.12, except that the names likely and unlikely may be defined as
function-like macros (15.6).

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

* [Bug preprocessor/109994] Issue a diagnostic when a C++ file defines a macro that hides a keyword
  2023-05-26 16:31 [Bug preprocessor/109994] New: Issue a diagnostic when a C++ file defines a macro that hides a keyword redi at gcc dot gnu.org
@ 2023-05-26 16:34 ` mpolacek at gcc dot gnu.org
  2023-05-26 16:40 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-05-26 16:34 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
                 CC|                            |mpolacek at gcc dot gnu.org
   Last reconfirmed|                            |2023-05-26

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

* [Bug preprocessor/109994] Issue a diagnostic when a C++ file defines a macro that hides a keyword
  2023-05-26 16:31 [Bug preprocessor/109994] New: Issue a diagnostic when a C++ file defines a macro that hides a keyword redi at gcc dot gnu.org
  2023-05-26 16:34 ` [Bug preprocessor/109994] " mpolacek at gcc dot gnu.org
@ 2023-05-26 16:40 ` pinskia at gcc dot gnu.org
  2023-05-26 16:41 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-26 16:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
There are definitly testcases in GCC's testsuite which does this all the time.
#define int ...

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

* [Bug preprocessor/109994] Issue a diagnostic when a C++ file defines a macro that hides a keyword
  2023-05-26 16:31 [Bug preprocessor/109994] New: Issue a diagnostic when a C++ file defines a macro that hides a keyword redi at gcc dot gnu.org
  2023-05-26 16:34 ` [Bug preprocessor/109994] " mpolacek at gcc dot gnu.org
  2023-05-26 16:40 ` pinskia at gcc dot gnu.org
@ 2023-05-26 16:41 ` redi at gcc dot gnu.org
  2023-05-26 16:42 ` jakub at gcc dot gnu.org
  2024-01-21 22:22 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2023-05-26 16:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> There are definitly testcases in GCC's testsuite which does this all the
> time.
> #define int ...

Yeah, it shouldn't be in -Wall, and it's not a required diagnostic for
conformance. But it might be nice. Not a priority though.

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

* [Bug preprocessor/109994] Issue a diagnostic when a C++ file defines a macro that hides a keyword
  2023-05-26 16:31 [Bug preprocessor/109994] New: Issue a diagnostic when a C++ file defines a macro that hides a keyword redi at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-05-26 16:41 ` redi at gcc dot gnu.org
@ 2023-05-26 16:42 ` jakub at gcc dot gnu.org
  2024-01-21 22:22 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-05-26 16:42 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Not just testcases, libgcc.h does that too (though, sure, that is C).

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

* [Bug preprocessor/109994] Issue a diagnostic when a C++ file defines a macro that hides a keyword
  2023-05-26 16:31 [Bug preprocessor/109994] New: Issue a diagnostic when a C++ file defines a macro that hides a keyword redi at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2023-05-26 16:42 ` jakub at gcc dot gnu.org
@ 2024-01-21 22:22 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2024-01-21 22:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
*** Bug 113532 has been marked as a duplicate of this bug. ***

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

end of thread, other threads:[~2024-01-21 22:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-26 16:31 [Bug preprocessor/109994] New: Issue a diagnostic when a C++ file defines a macro that hides a keyword redi at gcc dot gnu.org
2023-05-26 16:34 ` [Bug preprocessor/109994] " mpolacek at gcc dot gnu.org
2023-05-26 16:40 ` pinskia at gcc dot gnu.org
2023-05-26 16:41 ` redi at gcc dot gnu.org
2023-05-26 16:42 ` jakub at gcc dot gnu.org
2024-01-21 22:22 ` redi 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).