RFR: 8301244: Replace legacy pragma implementations in HotSpot's compilerWarnings.hpp [v7]

Kim Barrett kbarrett at openjdk.org
Sun Jan 29 21:15:15 UTC 2023


On Sun, 29 Jan 2023 06:38:19 GMT, Julian Waters <jwaters at openjdk.org> wrote:

>> HotSpot has a few legacy implementations of pragmas in some of its macros in compilerWarnings.hpp, they should be cleaned up and use a more modern approach. Rename PRAGMA macro in compilerWarnings_gcc.hpp as well since it can be used for more than just compiler warnings
>
> Julian Waters has updated the pull request incrementally with one additional commit since the last revision:
> 
>   compilerWarnings_gcc.hpp

Describing MSVC `__pragma` as "legacy" is questionable. MSVC documentation
describes it as an extension, and it seems unlikely to ever go away. So all
this change really does is make the MS compiler work a little harder
(stringize the token sequence, then retokenize it) in order to avoid an
MS-specific extension in MS-specific code. Plus the cost of a new helper
macro.

I had wondered if there might be some benefit related to control of macro
expansion, but there's not (see the definition of _Pragma).  While exploring
that question I discovered a difference in behavior between MSVC and gcc.
MSVC macro expands the pragma tokens, while gcc does not.

So I don't think this change should be made.

-------------

PR: https://git.openjdk.org/jdk/pull/12255


More information about the hotspot-dev mailing list