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

            Bug ID: 125162
           Summary: -Q --help=warnings misreports -Wkeyword-macro when
                    enabled through C++26 and -Wpedantic
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ivan.lazaric.gcc at gmail dot com
  Target Milestone: ---

Some context for start:

Consider this short snippet of code:
```cpp
#define inline
```

When compiled with `-std=c++26 -Wpedantic` it gives a warning:
```
<source>:1:9: warning: keyword 'inline' defined as macro [-Wkeyword-macro]
    1 | #define inline
      |         ^~~~~~
```
Godbolt: https://godbolt.org/z/befMv597h

>From GCC manual (emphasis ***):
```
-Wkeyword-macro
Warn if a keyword is defined as a macro or undefined. For C++ identifiers with
special meaning or standard attribute identifiers are diagnosed as well. This
warning is ***enabled by default for C++26 if -Wpedantic*** and emits a pedwarn
in
that case.
```

Manual says "C++26 && -Wpedantic imply -Wkeyword-macro",
and starting example shows it to be true, everything for now makes sense.


Issue:

Going through `-Q --help=warnings` to check for Wkeyword-macro:
```
$ g++ foo.cpp -std=c++26 -Wpedantic -Q --help=warnings | grep Wkeyword-macro
  -Wkeyword-macro                       [disabled]
```

I was expecting `-Q --help=warnings` to report Wkeyword-macro as enabled.
  • [Bug c++/125162] New: -Q --... ivan.lazaric.gcc at gmail dot com via Gcc-bugs

Reply via email to