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

Gao, Yunzhong yunzhong_gao at playstation.sony.com
Wed Feb 26 16:20:22 PST 2014


I was a bit concerned that clang would reject a program that MSVC can compile on a MSVC
attribute, but I agree with you that dllexport is most likely not intended here either.

LGTM.


________________________________________
From: Nico Rieck [nico.rieck at gmail.com]
Sent: Wednesday, February 26, 2014 4:07 PM
To: Gao, Yunzhong; cfe-commits
Subject: Re: [PATCH] Sema: Treat dllimport globals without explicit storage class as extern

On 27.02.2014 00:45, Gao, Yunzhong wrote:
> Thanks for clarifying. So with your patch, what is the expected compiler behaviour on the
> following snippet?
> __declspec(dllimport) int v;
> int v;
>
> From your test case it seems that I will get a compile-time error "definition of dllimport data",
> but when I test this out on Visual Studio 2012, I got only a warning:
> warning C4273: inconsistent dll linkage

MSVC has surprising behavior here and actually makes v dllexport. I
don't plan to implement this. But this should at least warn about the
ignored dllimport attribute. The following patch deals with
redeclarations and properly diagnoses this (including dllexport).

> I take this to mean, more tests are coming? If so, it is fine with me.

Yes.

-Nico






More information about the cfe-commits mailing list