[PATCH] Sema: Treat dllimport globals without explicit storage class as extern

Richard Smith richard at metafoo.co.uk
Wed Mar 5 10:43:41 PST 2014


On Wed, Mar 5, 2014 at 7:01 AM, Nico Rieck <nico.rieck at gmail.com> wrote:

> On 04.03.2014 03:36, Richard Smith wrote:
> > I'm concerned that you may be updating the storage class too late; at the
> > point where you update the storage class, it's already been used for
> > several things. Can you move this earlier? (I expect this won't be
> trivial
> > since you can't just look for an attribute because you won't have a Decl
> > yet...)
>
> Looking at the code, the main issue seems to be that such a variable
> would get the wrong DeclContext because
> adjustContextForLocalExternDecl() is never called. This seems really ugly.
>
> I could for this special cause check the parsed attributes for dllimport
> (the only checking done when creating a DLLImportAttr is for valid
> subjects, so this is fulfilled).
>
> Do you have an idea what could go wrong when the DeclContext is not
> adjusted? Since the current tests don't expose this. Maybe it's possible
> to provoke wrong behavior but I've been unsuccessful so far.


If we don't adjust the DeclContext, I don't think we'll reject ill-formed
code such as this:

float x;
void f() {
   __declspec(dllimport) int x;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140305/9e29137f/attachment.html>


More information about the cfe-commits mailing list