This is an archive of the discontinued LLVM Phabricator instance.

[MS compat] Handle #pragma fenv_access like #pragma STDC FENV_ACCESS (PR50694)
ClosedPublic

Authored by hans on Oct 8 2021, 9:45 AM.

Details

Summary

This adds support for the MSVC spelling of the pragma in -fms-extensions mode.

Diff Detail

Event Timeline

hans created this revision.Oct 8 2021, 9:45 AM
hans requested review of this revision.Oct 8 2021, 9:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 8 2021, 9:45 AM
thakis accepted this revision.Oct 11 2021, 5:56 AM

Very cool.

clang/lib/Parse/ParsePragma.cpp
276

Move down 10 lines until you need it?

280

Is it important that this is a warning?

Independently if we have access to Parser here (not sure), there's Parser::ExpectAndConsume.

This revision is now accepted and ready to land.Oct 11 2021, 5:56 AM
hans marked an inline comment as done.Oct 11 2021, 7:24 AM
hans added inline comments.
clang/lib/Parse/ParsePragma.cpp
280

Is it important that this is a warning?

You mean as opposed to an error? Or as opposed to accepting slightly alternative spellings? I don't think we want to accept any other syntax than MSVC. And the custom seems to be to warn and ignore when we can't parse a pragma so I'm following that pattern.

Independently if we have access to Parser here (not sure), there's Parser::ExpectAndConsume.

Sadly the PragmaHandler classes don't have access to it. It might be possible to plumb it through, but I'm not sure whether it would be worth it.

While looking at it, I did switch to more specific diags for the parens though.

hans updated this revision to Diff 378660.Oct 11 2021, 7:25 AM

Slightly better diags, try to appease clang-format.

thakis added inline comments.Oct 11 2021, 7:53 AM
clang/lib/Parse/ParsePragma.cpp
280

Yes, as opposed to an error. If cl.exe errs on this, we should probably err too.

hans added inline comments.Oct 11 2021, 8:00 AM
clang/lib/Parse/ParsePragma.cpp
280

They also just warn: https://godbolt.org/z/P3j5Wc78E

This revision was landed with ongoing or failed builds.Oct 11 2021, 8:07 AM
This revision was automatically updated to reflect the committed changes.