As reported on cfe-commits, r314262 resulted in tentatively-defined
variables not being excluded for the warning.
Patch By: Elizabeth Andrews
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314939
91177308-0d34-0410-b5e6-
96231b3b80d8
// 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);
}
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")));