diff options
| author | Nico Weber <nicolasweber@gmx.de> | 2015-04-17 09:50:28 +0000 |
|---|---|---|
| committer | Nico Weber <nicolasweber@gmx.de> | 2015-04-17 09:50:28 +0000 |
| commit | 796a772617aced0de3a4a85aad9063d94a9a3e81 (patch) | |
| tree | 8b9eb3f01422cccf4c83c42a46c842d275838ba2 /clang | |
| parent | 81eb66c992105ac442d0cea92b4ffbbfc18425ed (diff) | |
| download | bcm5719-llvm-796a772617aced0de3a4a85aad9063d94a9a3e81.tar.gz bcm5719-llvm-796a772617aced0de3a4a85aad9063d94a9a3e81.zip | |
Follow-up to r235046: selectany only causes a definition if it's not inherited.
(For example needed to parse system header inputscope.h, which first has
an extern "C" selectany IID and then later an extern "C" declaration of that
same IID.)
llvm-svn: 235174
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/AST/Decl.cpp | 3 | ||||
| -rw-r--r-- | clang/test/SemaCXX/attr-selectany.cpp | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 628c9b053ea..b532d3bb34e 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -1915,7 +1915,8 @@ VarDecl::isThisDeclarationADefinition(ASTContext &C) const { if (hasInit()) return Definition; - if (hasAttr<AliasAttr>() || hasAttr<SelectAnyAttr>()) + if (hasAttr<AliasAttr>() || + (hasAttr<SelectAnyAttr>() && !getAttr<SelectAnyAttr>()->isInherited())) return Definition; // A variable template specialization (other than a static data member diff --git a/clang/test/SemaCXX/attr-selectany.cpp b/clang/test/SemaCXX/attr-selectany.cpp index 7d9cf7aea4e..058f2fcb84a 100644 --- a/clang/test/SemaCXX/attr-selectany.cpp +++ b/clang/test/SemaCXX/attr-selectany.cpp @@ -42,5 +42,9 @@ __declspec(selectany) auto x8 = Internal(); // expected-error {{'selectany' can struct SomeStruct {}; extern const __declspec(selectany) SomeStruct some_struct; // expected-warning {{default initialization of an object of const type 'const SomeStruct' without a user-provided default constructor is a Microsoft extension}} +// It should be possible to redeclare variables that were defined +// __declspec(selectany) previously. +extern const SomeStruct some_struct; + // Without selectany, this should stay an error. const SomeStruct some_struct2; // expected-error {{default initialization of an object of const type 'const SomeStruct' without a user-provided default constructor}} |

