x64 windows (MinGW) and "__declspec(dllimport)" emits a "unknown attribute warning"

Hi,

This small piece of code:

int main() {}
__declspec(dllexport) void foo (int); void bar (void) { foo (0); }

emits following warning when Clang is built for x86_64-w64-mingw32,
but not when built for i686-w64-mingw32:

foo.c:3:12: warning: unknown attribute 'dllexport' ignored [-Wattributes]
__declspec(dllexport) void foo (int); void bar (void) { foo (0); }
^
<built-in>:128:38: note: expanded from:
#define __declspec(a) __attribute__((a))
^
1 warning generated.

Note that this code has an undefined reference, that's not the point.

I tried looking through Clang's code where this warning is emitted,
but can't find anything relevant. The code differentiating x86 and x64
(or most likely just "forgetting" x64 mingw) is probably deeper in the
code.

Any help is appreciated.

Ruben

Ruben,

It must be a bug even if __attribute__((dllexport)) is not accepted on
x86_64-mingw32.

This small piece of code:

int main() {}
__declspec(dllexport) void foo (int); void bar (void) { foo (0); }

emits following warning when Clang is built for x86_64-w64-mingw32,
but not when built for i686-w64-mingw32:

Interesting.

Note, __declspec(dllexport) can be accepted (w/o macro substitution)
with -fms-extensions.
(FYI, IIRC, cygming-gcc does not accept __declspec. cygming header
should have the macro def)

...Takumi

Try lib/Sema/TargetAttributesSema.cpp.

-Eli

Eli,

Try lib/Sema/TargetAttributesSema.cpp.

The last modification to the stuff was I. :smiley:

Ruben,

What is defined to LLVM_HOSTTRIPLE in your
(builddir)/include/llvm/Config/*config.h?
I am afraid Triple cannot parse "x86_64-w64-mingw32" correctly...

...Takumi

Both in config.h and llvm-config.h it is defined as
"x86_64-w64-mingw32". I also had a brief look at
LLVM/lib/Support/Triple.cpp and can't find anything that stands out
(except for the fact that the *-w64-* vs *-pc-* isn't handled, but as
far as I know, that's only used by GCC itself to differentiate certain
low-level aspects like library/crt/header locations when it builds
itself, nothing Clang needs to worry about yet).

Ruben