This is an archive of the discontinued LLVM Phabricator instance.

Implement __declspec(selectany) under -fms-extensions
ClosedPublic

Authored by rnk on May 17 2013, 10:22 AM.

Details

Summary

selectany only applies to externally visible global variables. It has
the effect of making the data linkonce. MSDN doesn't seem to require
that all definitions be the same, which means clang shouldn't use
linkonceodr.

Diff Detail

Event Timeline

Can they be discarded? If so, please add a comment saying that they
can. If not, you need no use weak_odr.

rnk updated this revision to Unknown Object (????).May 17 2013, 11:57 AM
  • Use weak instead of linkonce.
rafael accepted this revision.May 17 2013, 12:36 PM

Should

static int x;
extern __declspec(selectany) int x;

work or be rejected? If rejected, LGTM with it added as a test.

rnk added a comment.May 17 2013, 12:45 PM

MSVC accepts

static int x7;
extern __declspec(selectany) int x7;

But it also accepts

static int x7;
extern int x7;

That seems like a separate issue. It doesn't seem that important to me to
accept this.

Clang errors out with 'attribute declaration must precede definition',
which doesn't seem useful to have in that test.

OK to commit as is?

rnk closed this revision.May 20 2013, 7:05 AM

Closed by commit rL182266 (authored by @rnk).