diff options
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 33f02c5b7f4..c99dbd944b0 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -2607,6 +2607,16 @@ 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) { + Diag(New->getLocation(), diag::warn_attribute_section_on_redeclaration); + Diag(Old->getLocation(), diag::note_previous_declaration); + } + } + } + if (!Old->hasAttrs()) return; |