]> granicus.if.org Git - clang/commitdiff
Enable __declspec(selectany) on any platform
authorPiotr Padlewski <piotr.padlewski@gmail.com>
Thu, 14 Sep 2017 17:33:08 +0000 (17:33 +0000)
committerPiotr Padlewski <piotr.padlewski@gmail.com>
Thu, 14 Sep 2017 17:33:08 +0000 (17:33 +0000)
Summary:
This feature was disabled probably by mistake in rL300562
This fixes bug https://bugs.llvm.org/show_bug.cgi?id=33285

Reviewers: davide, rnk

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D33852

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@313278 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/Attr.td
include/clang/Basic/AttrDocs.td
test/Sema/attr-selectany.c
test/SemaCXX/attr-selectany.cpp

index 8b7eb930044b9da68f1ef670ad7b1eb5678d21bd..894e0a0ed17be64753e84f45760819627b5fe96a 100644 (file)
@@ -2472,9 +2472,9 @@ def DLLImport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
   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 46d6b24bc2d9629e1d1d99ae71f56e80025769e4..6a7bbbcffd8a2fb82e91552f8c93d36a07ec22b0 100644 (file)
@@ -3192,3 +3192,18 @@ This attribute can be added to an Objective-C ``@interface`` declaration to
 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 9fa2fcade539f21eadfc26291273257bff886879..9d574d524f0ad0abf9daa8ab06463ffe5b7e0a58 100644 (file)
@@ -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 62fca09ab36411d75b181a6b91802f6742ed3433..4afcb8130a14c490631da5c090b7a36aa8dd3541 100644 (file)
@@ -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}}