This is an archive of the discontinued LLVM Phabricator instance.

mingw-w64: enable support for __declspec(selectany)
ClosedPublic

Authored by martell on Apr 14 2017, 7:21 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

martell created this revision.Apr 14 2017, 7:21 AM

@rnk what are your thoughts on adding a new LangOpts maybe called WindowsExt which can be shared across MSVC and Mingw?
I will also add a test case once I know how best to proceed

martell updated this revision to Diff 95305.Apr 14 2017, 8:43 AM

updated to fix test cases.

needs more work,
I see that I can have an array of language opts so I will add a mingw one rather then a combined one

rnk accepted this revision.Apr 14 2017, 9:38 AM

Using TargetSpecificAttr<TargetWindws> sounds good to me.

include/clang/Basic/Attr.td
2245 ↗(On Diff #95305)

This is at least consistent with what we do for dllexport/dllimport, which is the other major attribute/declspec that GCC and MSVC share, so let's do that for now.

test/Sema/attr-selectany.c
2 ↗(On Diff #95305)

Ditto, can we remove -fms-extensions?

test/SemaCXX/attr-selectany.cpp
1 ↗(On Diff #95305)

Does the test still pass if you remove -fms-extensions? If it does, let's remove it to simplify the test.

This revision is now accepted and ready to land.Apr 14 2017, 9:38 AM
martell updated this revision to Diff 95310.Apr 14 2017, 9:55 AM

I got a little carried away and submitted too early before I realised they were comma separated arguments.

martell added inline comments.Apr 14 2017, 9:56 AM
test/Sema/attr-selectany.c
2 ↗(On Diff #95305)

I done it in a way to work without -fms-extensions for mingw but not for masvc to keep the current expectation intact

test/SemaCXX/attr-selectany.cpp
1 ↗(On Diff #95305)

Ditto

martell added a comment.EditedApr 14 2017, 10:03 AM

Also note that now we have to add the target to non msvc default hosts.
The test case was updated to reflect that.

martell updated this revision to Diff 95582.Apr 18 2017, 9:01 AM

reverted back based on comments by @rnk

We can't just simply remove -fms-extensions because
'__declspec' attributes are not enabled; use '-fdeclspec' or '-fms-extensions' to enable support for __declspec attributes
mingw passes -fdeclspec.

Test cases are updated to test both -fdeclspec and -fms-extensions because the cpp testcase does a lot more then just test selectany

This revision was automatically updated to reflect the committed changes.