Skip to content

Commit

Permalink
mingw-w64: enable support for __declspec(selectany)
Browse files Browse the repository at this point in the history
Add selectany as a GCC spelling for mingw-w64

Reviewers: rnk

Differential revision: https://reviews.llvm.org/D32083

llvm-svn: 300562
  • Loading branch information
martell committed Apr 18, 2017
1 parent 855ef45 commit 3e573be
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
5 changes: 2 additions & 3 deletions clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -2351,9 +2351,8 @@ def DLLImport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
let Documentation = [DLLImportDocs];
}

def SelectAny : InheritableAttr {
let Spellings = [Declspec<"selectany">];
let LangOpts = [MicrosoftExt];
def SelectAny : InheritableAttr, TargetSpecificAttr<TargetWindows> {
let Spellings = [Declspec<"selectany">, GCC<"selectany">];
let Documentation = [Undocumented];
}

Expand Down
3 changes: 2 additions & 1 deletion clang/test/Sema/attr-selectany.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fms-compatibility -fms-extensions -verify %s
// RUN: %clang_cc1 -triple x86_64-win32 -fdeclspec -verify %s
// RUN: %clang_cc1 -triple x86_64-mingw32 -verify %s

extern __declspec(selectany) const int x1 = 1; // no warning, const means we need extern in C++

Expand Down
2 changes: 1 addition & 1 deletion clang/test/SemaCXX/attr-selectany.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fms-compatibility -fms-extensions -fsyntax-only -verify -std=c++11 %s
// RUN: %clang_cc1 -triple x86_64-win32 -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}}
Expand Down

0 comments on commit 3e573be

Please sign in to comment.