mirror of
https://github.com/intel/llvm.git
synced 2026-02-05 22:17:23 +08:00
Fix 'section' warning behavior with tentatively-defined values
As reported on cfe-commits, r314262 resulted in tentatively-defined variables not being excluded for the warning. Patch By: Elizabeth Andrews llvm-svn: 314939
This commit is contained in:
@@ -2627,7 +2627,7 @@ void Sema::mergeDeclAttributes(NamedDecl *New, Decl *Old,
|
||||
// This redeclaration adds a section attribute.
|
||||
if (New->hasAttr<SectionAttr>() && !Old->hasAttr<SectionAttr>()) {
|
||||
if (auto *VD = dyn_cast<VarDecl>(New)) {
|
||||
if (VD->isThisDeclarationADefinition() != VarDecl::Definition) {
|
||||
if (VD->isThisDeclarationADefinition() == VarDecl::DeclarationOnly) {
|
||||
Diag(New->getLocation(), diag::warn_attribute_section_on_redeclaration);
|
||||
Diag(Old->getLocation(), diag::note_previous_declaration);
|
||||
}
|
||||
|
||||
@@ -23,3 +23,12 @@ enum __attribute__((section("NEAR,x"))) e { one }; // expected-error {{'section'
|
||||
extern int a; // expected-note {{previous declaration is here}}
|
||||
int *b = &a;
|
||||
extern int a __attribute__((section("foo,zed"))); // expected-warning {{section attribute is specified on redeclared variable}}
|
||||
|
||||
// Not a warning.
|
||||
int c;
|
||||
int c __attribute__((section("foo,zed")));
|
||||
|
||||
// Also OK.
|
||||
struct r_debug {};
|
||||
extern struct r_debug _r_debug;
|
||||
struct r_debug _r_debug __attribute__((nocommon, section(".r_debug,bar")));
|
||||
|
||||
Reference in New Issue
Block a user