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

Nico Rieck nico.rieck at gmail.com
Thu Mar 20 16:41:47 PDT 2014

On 05.03.2014 19:43, Richard Smith wrote:
> 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;
> }

This test fails with the original patch, but this problem can be solved
by setting the storage class a bit earlier even without setting the
correct DeclContext. I have yet to come up with a test case that exposes
the wrong DeclContext.

I've restructured the patch to look at the parsed attributes to get the
correct DeclContext. Another option I explored was using setDeclContext
on the VarDecl. This passes all tests but I'm more reluctant to do this.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: dll-sema-global-dllimport-extern-v2.patch
Type: text/x-patch
Size: 5428 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140321/71692db1/attachment.bin>

More information about the cfe-commits mailing list