[PATCH] Support __declspec(selectany) on Mingw
Aaron Ballman
aaron at aaronballman.com
Wed Mar 26 05:48:55 PDT 2014
On Tue, Mar 25, 2014 at 7:26 PM, Ivan Garramona
<heavenandhell171 at gmail.com> wrote:
> Trying to build wxWidgets with Clang i've found out that it only support
> selectany under ms-extensions. This patch enable selectany on Mingw as well.
Good catch, comments below:
> diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td
> index 3eb5d4e..3f8dcaa 100644
> --- a/include/clang/Basic/Attr.td
> +++ b/include/clang/Basic/Attr.td
> @@ -1652,9 +1652,8 @@ def DLLImport : InheritableAttr, TargetSpecificAttr<TargetX86Win> {
> let Documentation = [Undocumented];
> }
>
> -def SelectAny : InheritableAttr {
> - let Spellings = [Declspec<"selectany">];
> - let LangOpts = [MicrosoftExt];
I believe this is still a Microsoft extension, at least when used as a
declspec. Not certain that we have support for spelling-specific
language options though...
> +def SelectAny : InheritableAttr, TargetSpecificAttr<TargetX86Win> {
I don't think this is correct -- according to the GCC docs, this is
valid for any Windows target regardless of architecture (so, for
instance, ARM). So I think there needs to be a new TargetArch called
TargetAnyWindows which uses a wildcard for the architecture and Win32,
MinGW32 for the OSes. Note: I don't think there's currently any
support for a wildcard architecture in the tablegenning stuff, so this
may be a bit more involved.
> + let Spellings = [Declspec<"selectany">, GCC<"selectany">];
> let Documentation = [Undocumented];
> }
>
> diff --git a/test/SemaCXX/attr-selectany.cpp b/test/SemaCXX/attr-selectany.cpp
> index c27a915..7cf85f7 100644
> --- a/test/SemaCXX/attr-selectany.cpp
> +++ b/test/SemaCXX/attr-selectany.cpp
> @@ -1,4 +1,4 @@
> -// RUN: %clang_cc1 -fms-extensions -fsyntax-only -verify -std=c++11 %s
> +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
> // MSVC produces similar diagnostics.
>
> __declspec(selectany) void foo() { } // expected-error{{'selectany' can only be applied to data items with external linkage}}
>
Missing test cases demonstrating that this works as a GNU-style and
C++11 style attribute. Also missing test cases that this will
pass/fail based on the target.
Thanks!
~Aaron
More information about the cfe-commits
mailing list