[PATCH] D33852: Enable __declspec(selectany) on linux
Piotr Padlewski via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 14 10:34:37 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313278: Enable __declspec(selectany) on any platform (authored by Prazek).
Repository:
rL LLVM
https://reviews.llvm.org/D33852
Files:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/test/Sema/attr-selectany.c
cfe/trunk/test/SemaCXX/attr-selectany.cpp
Index: cfe/trunk/include/clang/Basic/AttrDocs.td
===================================================================
--- cfe/trunk/include/clang/Basic/AttrDocs.td
+++ cfe/trunk/include/clang/Basic/AttrDocs.td
@@ -3192,3 +3192,18 @@
ensure that this class cannot be subclassed.
}];
}
+
+
+def SelectAnyDocs : Documentation {
+ let Category = DocCatType;
+ let Content = [{
+This attribute appertains to a global symbol, causing it to have a weak
+definition (
+`linkonce <https://llvm.org/docs/LangRef.html#linkage-types>`_
+), allowing the linker to select any definition.
+
+For more information see
+`gcc documentation <https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc/Microsoft-Windows-Variable-Attributes.html>`_
+or `msvc documentation <https://docs.microsoft.com/pl-pl/cpp/cpp/selectany>`_.
+}];
+}
Index: cfe/trunk/include/clang/Basic/Attr.td
===================================================================
--- cfe/trunk/include/clang/Basic/Attr.td
+++ cfe/trunk/include/clang/Basic/Attr.td
@@ -2472,9 +2472,9 @@
let Documentation = [DLLImportDocs];
}
-def SelectAny : InheritableAttr, TargetSpecificAttr<TargetWindows> {
+def SelectAny : InheritableAttr {
let Spellings = [Declspec<"selectany">, GCC<"selectany">];
- let Documentation = [Undocumented];
+ let Documentation = [SelectAnyDocs];
}
def Thread : Attr {
Index: cfe/trunk/test/Sema/attr-selectany.c
===================================================================
--- cfe/trunk/test/Sema/attr-selectany.c
+++ cfe/trunk/test/Sema/attr-selectany.c
@@ -1,5 +1,7 @@
// RUN: %clang_cc1 -triple x86_64-win32 -fdeclspec -verify %s
// RUN: %clang_cc1 -triple x86_64-mingw32 -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -verify -fdeclspec %s
+// RUN: %clang_cc1 -triple x86_64-win32-macho -verify -fdeclspec %s
extern __declspec(selectany) const int x1 = 1; // no warning, const means we need extern in C++
Index: cfe/trunk/test/SemaCXX/attr-selectany.cpp
===================================================================
--- cfe/trunk/test/SemaCXX/attr-selectany.cpp
+++ cfe/trunk/test/SemaCXX/attr-selectany.cpp
@@ -1,4 +1,7 @@
// RUN: %clang_cc1 -triple x86_64-win32 -fms-compatibility -fms-extensions -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -fms-compatibility -fms-extensions -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple x86_64-win32-macho -fms-compatibility -fms-extensions -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}}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33852.115244.patch
Type: text/x-patch
Size: 2657 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170914/6457954b/attachment.bin>
More information about the cfe-commits
mailing list