From d8199c9eaa2e16c7b64b6c18fe88d4339321496e Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 14 Nov 2017 02:38:20 +0000 Subject: Merging r313278: ------------------------------------------------------------------------ r313278 | prazek | 2017-09-14 10:33:08 -0700 (Thu, 14 Sep 2017) | 11 lines Enable __declspec(selectany) on any platform 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/branches/release_50@318133 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/Attr.td | 4 ++-- include/clang/Basic/AttrDocs.td | 15 +++++++++++++++ test/Sema/attr-selectany.c | 2 ++ test/SemaCXX/attr-selectany.cpp | 3 +++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td index f13e13b010..5c69635b94 100644 --- a/include/clang/Basic/Attr.td +++ b/include/clang/Basic/Attr.td @@ -2459,9 +2459,9 @@ def DLLImport : InheritableAttr, TargetSpecificAttr { let Documentation = [DLLImportDocs]; } -def SelectAny : InheritableAttr, TargetSpecificAttr { +def SelectAny : InheritableAttr { let Spellings = [Declspec<"selectany">, GCC<"selectany">]; - let Documentation = [Undocumented]; + let Documentation = [SelectAnyDocs]; } def Thread : Attr { diff --git a/include/clang/Basic/AttrDocs.td b/include/clang/Basic/AttrDocs.td index 33ef3ea4ca..567c7a3a53 100644 --- a/include/clang/Basic/AttrDocs.td +++ b/include/clang/Basic/AttrDocs.td @@ -3106,3 +3106,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 `_ +), allowing the linker to select any definition. + +For more information see +`gcc documentation `_ +or `msvc documentation `_. +}]; +} diff --git a/test/Sema/attr-selectany.c b/test/Sema/attr-selectany.c index 9fa2fcade5..9d574d524f 100644 --- a/test/Sema/attr-selectany.c +++ b/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++ diff --git a/test/SemaCXX/attr-selectany.cpp b/test/SemaCXX/attr-selectany.cpp index 62fca09ab3..4afcb8130a 100644 --- a/test/SemaCXX/attr-selectany.cpp +++ b/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}} -- cgit v1.2.3