forked from OSchip/llvm-project
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:
parent
81eb66c992
commit
796a772617
|
@ -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
|
||||||
|
|
|
@ -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}}
|
||||||
|
|
Loading…
Reference in New Issue