https://gcc.gnu.org/bugzilla/show_bug.cgi?id=129149
Bug ID: 129149
Summary: Pragma diagnostic in parameters
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: salonsorocpp26 at gmail dot com
Target Milestone: ---
There's a current limitation in the C++ parser with regards to how pragmas are
processed for parameters (there seems to be no pragma_param enumerator in the
pragma_context enum).
I don't think that's good because suppose I have the following:
stacktrace_t stacktrace_identifier; // empty global stacktrace
void foo(
_Pragma("GCC diagnostic push")
_Pragma("GCC diagnostic ignored \"-Wshadow\")
stacktrace_t stacktrace_identifier // I want this to be shadowed because I'm
providing some context that the global one can't provide (e.g an stacktrace
coming from the caller, assuming C++23 can't be used)
_Pragma("GCC diagnostic pop")
, int other_identifier // assuming the current TU is being compiled with
-Wshadow, if other_identifier is shadowing a global name, this will issue a
normal shadowing warning again
)
With the current parsing behavior, this isn't possible in any way. MSVC and
Clang both support this sort of granularity already, so I think this should be
added to GCC for consistency and expressivity purposes.