[PATCH] Implement __declspec(selectany) under -fms-extensions

Reid Kleckner rnk at google.com
Fri May 17 13:06:44 PDT 2013


On Fri, May 17, 2013 at 3:50 PM, Rafael EspĂ­ndola <
rafael.espindola at gmail.com> wrote:

> On 17 May 2013 15:44, Reid Kleckner <rnk at google.com> wrote:
> > MSVC accepts
> >
> > static int x7;
> > extern __declspec(selectany) int x7;
> >
> > But it also accepts
> >
> > static int x7;
> > extern int x7;
>
> It should, we also do :-)
>
> In the case with __declspec(selectany), is x7 transformed into a
> externally visible symbol or the attribute just ignored?


Oh.  Looks like it's externally visible and comdat.  Looks like it needs
work to accept it after initial definitions or something.

> 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.
>
> It is nice to have a test that there in an error, just to make sure we
> don't extend a microsoft extension.


OK.


> > OK to commit as is?
>
> OK with the test. There is a discussion on weak_odr being the correct
> linkage, but changing to _odr (if appropriate), just enables more
> optimizations and can be a followup patch.
>

The code you sent returns 5 directly with optimizations, so does that mean
I can go with weak_odr?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130517/8de3d1da/attachment.html>


More information about the cfe-commits mailing list