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
This commit is contained in:
Nico Weber 2015-04-17 09:50:28 +00:00
parent 81eb66c992
commit 796a772617
2 changed files with 6 additions and 1 deletions

View File

@ -1915,7 +1915,8 @@ VarDecl::isThisDeclarationADefinition(ASTContext &C) const {
if (hasInit()) if (hasInit())
return Definition; return Definition;
if (hasAttr<AliasAttr>() || hasAttr<SelectAnyAttr>()) if (hasAttr<AliasAttr>() ||
(hasAttr<SelectAnyAttr>() && !getAttr<SelectAnyAttr>()->isInherited()))
return Definition; return Definition;
// A variable template specialization (other than a static data member // A variable template specialization (other than a static data member

View File

@ -42,5 +42,9 @@ __declspec(selectany) auto x8 = Internal(); // expected-error {{'selectany' can
struct SomeStruct {}; 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}} 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. // 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}} const SomeStruct some_struct2; // expected-error {{default initialization of an object of const type 'const SomeStruct' without a user-provided default constructor}}